Skip to content

Commit c05cb8a

Browse files
authored
GODRIVER-2679 Elaborate on DNS issues docs and confusing DNS error. (#1158)
1 parent ef0c0ab commit c05cb8a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

mongo/doc.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,13 @@
9494
//
9595
// # Potential DNS Issues
9696
//
97-
// Building with Go 1.11+ and using connection strings with the "mongodb+srv"[1] scheme is
97+
// Building with Go 1.11+ and using connection strings with the "mongodb+srv"[1] scheme is unfortunately
9898
// incompatible with some DNS servers in the wild due to the change introduced in
99-
// https://github.com/golang/go/issues/10622. If you receive an error with the message "cannot
100-
// unmarshal DNS message" while running an operation, we suggest you use a different DNS server.
99+
// https://github.com/golang/go/issues/10622. You may receive an error with the message "cannot unmarshal DNS message"
100+
// while running an operation when using DNS servers that non-compliantly compress SRV records. Old versions of kube-dns
101+
// and the native DNS resolver (systemd-resolver) on Ubuntu 18.04 are known to be non-compliant in this manner. We suggest
102+
// using a different DNS server (8.8.8.8 is the common default), and, if that's not possible, avoiding the "mongodb+srv"
103+
// scheme.
101104
//
102105
// # Client Side Encryption
103106
//

x/mongo/driver/dns/dns.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ func (r *Resolver) fetchSeedlistFromSRV(host string, srvName string, stopOnErr b
8080
srvName = "mongodb"
8181
}
8282
_, addresses, err := r.LookupSRV(srvName, "tcp", host)
83-
if err != nil {
83+
if err != nil && strings.Contains(err.Error(), "cannot unmarshal DNS message") {
84+
return nil, fmt.Errorf("see https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#hdr-Potential_DNS_Issues: %w", err)
85+
} else if err != nil {
8486
return nil, err
8587
}
8688

0 commit comments

Comments
 (0)