Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4001

SRV and TXT DNS Failures - Duplicated DNS Response Breaks Subsequent DNS Response Read

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.15.0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible

      Summary

      This issue only affects SRV and TXT lookups (mongodb+srv:// connection strings) in environments where DNS servers are incorrectly sending duplicate DNS responses for a single DNS request (Azure AKS in this reproduction).

      As a result, SRV lookups will "fail" in the driver, leading to a server selection timeout with an empty Servers [] list.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      MongoDB.Bson: 2.14.1
      MongoDB.Driver: 2.14.1
      MongoDB.Driver.Core: 2.14.1
      DnsClient: 1.4.0 (also tested 1.5.0)

      MongoDB Atlas 4.4.10 - M2 Replica Set

      How to Reproduce

      Deploy a C# dotnet application to an environment with a propensity for sending repeated/duplicated DNS responses to a single query. In this reproduction, we used Azure's AKS w/ CoreDNS (default) and k8s 1.21.
      Container tests were built from both Ubuntu 18.04 and Ubuntu 20.04 with .NET 5.0.
      Connect to the MongoDB deployment using mongodb+srv connection string. Repeat the connection attempts until DNS retransmissions are witnessed in a tcpdump. Expectation is a failure in SRV and/or TXT and followed by a server selection timeout.

      Additional Background

      The DnsClient response appears to be holding the second copy of the first request in queue. In this case, we are asking for TXT first followed by SRV, but the order of requests shouldn't matter as:
      When the response for SRV is requested, the TXT (second response) is returned instead, leading to a DNS header mismatch warning in the DnsClient verbose logs. When not testing DnsClient, it surfaces as a server selection timeout and no other details are logged by the MongoDB driver.

      I've linked CSHARP-3430 where I believe the root issue was not resolved. The exception was replaced with a warning, but the SRV to hosts list continues to fail.

      It's important to note that A and AAAA lookups in a similar environment do not cause issues. As a workaround, you may use the mongodb:// connection string to avoid SRV and TXT lookups.

        1. test-broken.pcap
          2 kB
        2. test-working.pcap
          108 kB

            Assignee:
            james.kovacs@mongodb.com James Kovacs
            Reporter:
            jack.alder@mongodb.com Jack Alder
            Votes:
            6 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: