-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Tools and Replicator
-
350
Problem Statement/Rationale
The MongoDB tools like mongodump and mongorestore are unable to handle URIs that start with `mongodb+srv://` if the DNS server applies compression on SRV records.
Please update the MongoDB tools to Go 1.23 so that everyone can easily access Mongo Atlas no matter what DNS server they are using.
Steps to Reproduce
Switch your computer to a DNS server that applies compression to SRV records and try to access a MongoDB Atlas cluster via a `mongodb+srv://` URI.
Expected Results
The mongo tools work successfully.
Actual Results
Tools like mongodump and mongorestore error out with cryptic messages like the following:
2024-10-17T14:57:10.088-0500 error parsing command line options: error parsing uri: lookup <redacted>.mongodb.net on 10.3.0.1:53: cannot unmarshal DNS message
2024-10-17T14:57:10.088-0500 try 'mongodump --help' for more information
At my office, we use the DNS server built into our MikroTik router. When mongodump or mongorestore try to lookup up the seed list, it provides a DNS response to the DNS SRV request. Wireshark shows that the SRV records in the response are compressed. Specifically, only the first response is complete in the hex view, while the other responses only have the first part of the host name, followed by a pointer (2-byte hex sequence typically "c0 xx" ) back to the first record.
After changing my computer to a different DNS server that does not apply compression to SRV records (e.g. Google's 8.8.8.8), the mongo tools work successfully.
Additional Notes
Here is my computer information, although it seems unlikely to be much help with this issue:
Intel MacBook Pro (2018)
macOS Ventura 13.6.9
I installed the latest version of the mongotools using Homebrew. Here is the output of "mongorestore --version".
mongorestore version: 100.9.5
git version: 90481484c1783826fe26ca18bbdcd30e933f3b88
Go version: go1.21.11
os: darwin
arch: amd64
compiler: gc
For several years, Go has been unable to handle DNS SRV records if the DNS server applied compression to these records. This has finally been fixed in Go 1.23 (see https://github.com/golang/go/issues/36718 ). In case you are really interested, here's the full history of the compressed SRV records debate:
- 1987 RFC describing DNS compression:
https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.4
- 2000 RFC that prohibited SRV compression:
https://www.rfc-editor.org/rfc/rfc2782.html
- 2003 RFC that required SRV decompression for backwards-compatibility:
https://www.rfc-editor.org/rfc/rfc3597#section-4
2015 Go issue to reject compressed SRV records:
https://github.com/golang/go/issues/10622
- 2018 Go PR to reject compressed SRV records:
https://go-review.googlesource.com/c/net/+/100055
- 2020 Go issue to being accepting compressed SRV records again:
https://github.com/golang/go/issues/36718 - 2021 MongoDB Atlas begins to default to mongodb
https://www.mongodb.com/developer/products/mongodb/srv-connection-strings/ - 2024 Go PR to revert the 2018 Go PR, so it again accepts compressed SRV records:
https://go-review.googlesource.com/c/net/+/540375
It appears that several others have also run into this issue over the years:
- https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#hdr-Potential_DNS_Issues
- https://jira.mongodb.org/browse/DOCS-15980
- https://jira.mongodb.org/browse/GODRIVER-829
- https://jira.mongodb.org/browse/GODRIVER-874
- https://jira.mongodb.org/browse/GODRIVER-875
- https://jira.mongodb.org/browse/GODRIVER-896
- https://jira.mongodb.org/browse/GODRIVER-1027
- https://jira.mongodb.org/browse/GODRIVER-2679