Skip to content

Commit c48d7f4

Browse files
authored
DRIVERS-521 Allow custom SRV service names with srvServiceName URI option (#1067)
1 parent 344eed9 commit c48d7f4

File tree

7 files changed

+109
-15
lines changed

7 files changed

+109
-15
lines changed

source/initial-dns-seedlist-discovery/initial-dns-seedlist-discovery.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Initial DNS Seedlist Discovery
1010
:Authors: Derick Rethans
1111
:Status: Draft
1212
:Type: Standards
13-
:Last Modified: 2019-04-15
14-
:Version: 1.4.0
13+
:Last Modified: 2021-09-15
14+
:Version: 1.5.0
1515
:Spec Lead: Matt Broadstone
1616
:Advisory Group: \A. Jesse Jiryu Davis
1717
:Approver(s): Bernie Hackett, David Golden, Jeff Yemin, Matt Broadstone, A. Jesse Jiryu Davis
@@ -65,11 +65,13 @@ Seedlist Discovery
6565
------------------
6666

6767
In this preprocessing step, the driver will query the DNS server for SRV
68-
records on ``{hostname}.{domainname}``, prefixed with ``_mongodb._tcp.``:
69-
``_mongodb._tcp.{hostname}.{domainname}``. This DNS query is expected to
70-
respond with one or more SRV records. From the DNS result, the driver now MUST
71-
behave the same as if an ``mongodb://`` URI was provided with all the host
72-
names and port numbers that were returned as part of the DNS SRV query result.
68+
records on ``{hostname}.{domainname}``, prefixed with the SRV service name
69+
and protocol. The SRV service name is provided in the ``srvServiceName`` URI option and
70+
defaults to ``mongodb``. The protocol is always ``tcp``. After prefixing, the URI
71+
should look like: ``_{srvServiceName}._tcp.{hostname}.{domainname}``. This DNS query
72+
is expected to respond with one or more SRV records. The driver MUST add all the host
73+
names and port numbers that were returned as part of the DNS SRV query result to the
74+
seedlist.
7375

7476
The priority and weight fields in returned SRV records MUST be ignored.
7577

@@ -274,6 +276,10 @@ SRV records.
274276
ChangeLog
275277
=========
276278

279+
2021-09-15 - 1.5.0
280+
Clarify that service name only defaults to ``mongodb``, and should be
281+
defined by the ``srvServiceName`` URI option.
282+
277283
2021-04-15 - 1.4.0
278284
Adding in behaviour for load balancer mode.
279285

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"uri": "mongodb+srv://test1.test.build.10gen.cc/?srvServiceName=customname",
3+
"seeds": [
4+
"localhost.test.build.10gen.cc:27017",
5+
"localhost.test.build.10gen.cc:27018"
6+
],
7+
"hosts": [
8+
"localhost:27017",
9+
"localhost:27018",
10+
"localhost:27019"
11+
],
12+
"options": {
13+
"ssl": true,
14+
"srvServiceName": "customname"
15+
}
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
uri: "mongodb+srv://test1.test.build.10gen.cc/?srvServiceName=customname"
2+
seeds:
3+
- localhost.test.build.10gen.cc:27017
4+
- localhost.test.build.10gen.cc:27018
5+
hosts:
6+
- localhost:27017
7+
- localhost:27018
8+
- localhost:27019
9+
options:
10+
ssl: true
11+
srvServiceName: "customname"

source/polling-srv-records-for-mongos-discovery/polling-srv-records-for-mongos-discovery.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Polling SRV Records for mongos Discovery
99
:Author: Derick Rethans
1010
:Status: Accepted
1111
:Type: Standards
12-
:Last Modified: 2018-11-29
13-
:Version: 1.0
12+
:Last Modified: 2021-09-15
13+
:Version: 1.1.0
1414
:Spec Lead: David Golden
1515

1616
.. contents::
@@ -79,8 +79,10 @@ rescan is similar, but not identical to the behaviour of initial seedlist
7979
discovery. Periodic scan MUST follow these rules:
8080

8181
- The driver will query the DNS server for SRV records on
82-
``{hostname}.{domainname}``, prefixed with ``_mongodb._tcp.``:
83-
``_mongodb._tcp.{hostname}.{domainname}``.
82+
``{hostname}.{domainname}``, prefixed with the SRV service name
83+
and protocol. The SRV service name is provided in the ``srvServiceName`` URI option and
84+
defaults to ``mongodb``. The protocol is always ``tcp``. After prefixing, the URI
85+
should look like: ``_{srvServiceName}._tcp.{hostname}.{domainname}``.
8486

8587
- A driver MUST verify that the host names returned through SRV records have
8688
the same parent ``{domainname}``. When this verification fails, a driver:
@@ -227,4 +229,6 @@ No future work is expected.
227229
Changelog
228230
=========
229231

230-
No changes yet.
232+
2021-09-15 - 1.1.0
233+
Clarify that service name only defaults to ``mongodb``, and should be
234+
defined by the ``srvServiceName`` URI option.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"tests": [
3+
{
4+
"description": "SRV URI with custom srvServiceName",
5+
"uri": "mongodb+srv://test1.test.build.10gen.cc/?srvServiceName=customname",
6+
"valid": true,
7+
"warning": false,
8+
"hosts": null,
9+
"auth": null,
10+
"options": {
11+
"srvServiceName": "customname"
12+
}
13+
},
14+
{
15+
"description": "Non-SRV URI with custom srvServiceName",
16+
"uri": "mongodb://example.com/?srvServiceName=customname",
17+
"valid": false,
18+
"warning": true,
19+
"hosts": null,
20+
"auth": null,
21+
"options": {}
22+
}
23+
]
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
tests:
2+
- description: "SRV URI with custom srvServiceName"
3+
uri: "mongodb+srv://test1.test.build.10gen.cc/?srvServiceName=customname"
4+
valid: true
5+
warning: false
6+
hosts: ~
7+
auth: ~
8+
options:
9+
srvServiceName: "customname"
10+
- description: "Non-SRV URI with custom srvServiceName"
11+
uri: "mongodb://example.com/?srvServiceName=customname"
12+
valid: false
13+
warning: true
14+
hosts: ~
15+
auth: ~
16+
options: {}

source/uri-options/uri-options.rst

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ URI Options Specification
33
=========================
44

55
:Spec Title: URI Options Specification
6-
:Spec Version: 1.7.1
6+
:Spec Version: 1.8.0
77
:Author: Sam Rossi
88
:Spec Lead: Bernie Hackett
99
:Advisory Group: Scott L'Hommedieu
1010
:Approver(s): Cailin Nelson, Jeff Yemin, Matt Broadstone, Dan Pasette, Prashant Mital, Spencer Jackson
1111
:Informed: drivers@
1212
:Status: Accepted (Could be Draft, Accepted, Rejected, Final, or Replaced)
1313
:Type: Standards
14-
:Last Modified: 2021-09-13
14+
:Last Modified: 2021-09-15
1515

1616

1717
**Abstract**
@@ -71,6 +71,14 @@ is specified with an SRV URI, because the URI may resolve to multiple
7171
hosts. The driver MUST allow specifying ``directConnection=false`` URI
7272
option with an SRV URI.
7373

74+
Non-SRV URI with srvServiceName URI option
75+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76+
77+
The driver MUST report an error if the ``srvServiceName`` URI option is
78+
specified with a non-SRV URI (i.e. ``mongodb://``) because SRV lookup
79+
only occurs with SRV URIs. The driver MUST allow specifying the ``srvServiceName``
80+
URI option with an SRV URI.
81+
7482
Multiple seeds with directConnection URI option
7583
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7684

@@ -208,7 +216,7 @@ pertaining to URI options apply here.
208216
- non-negative integer
209217
- defined in the `Connection Pooling spec`_
210218
- required for drivers with connection pools
211-
- The number of connections the driver should create and maintain in the pool even when no operations are occurring. This count includes connections which are currently checked out.
219+
- The number of connections the driver should create and maintain in the pool even when no operations are occurring. This count includes connections which are currently checked out.
212220

213221
* - readConcernLevel
214222
- any string (`to allow for forwards compatibility with the server <https://github.com/mongodb/specifications/blob/master/source/read-write-concern/read-write-concern.rst#unknown-levels-and-additional-options-for-string-based-readconcerns>`_)
@@ -269,6 +277,14 @@ pertaining to URI options apply here.
269277
- no
270278
- Amount of time spent attempting to send or receive on a socket before timing out; note that this only applies to application operations, not SDAM
271279

280+
* - srvServiceName
281+
- a valid SRV service name according to `RFC 6335 <https://datatracker.ietf.org/doc/html/rfc6335#section-5.1>`_; can be longer than 15 characters as long as the 63 (62 with prepended underscore)
282+
character DNS query limit is not surpassed
283+
- "mongodb"
284+
- no
285+
- the service name to use for SRV lookup in `initial DNS seedlist discovery <../initial-dns-seedlist-discovery/initial-dns-seedlist-discovery.rst>`_
286+
and `SRV polling <../polling-srv-records-for-mongos-discovery/polling-srv-records-for-mongos-discovery.rst>`_
287+
272288
* - ssl
273289
- "true" or "false"
274290
- same as "tls"
@@ -455,6 +471,7 @@ this specification MUST be updated to reflect those changes.
455471
Changes
456472
-------
457473

474+
- 2021-09-15 Add srvServiceName option
458475
- 2021-09-13 Fix link to load balancer spec
459476
- 2021-04-15 Adding in behaviour for load balancer mode.
460477
- 2021-04-08 Updated to refer to hello and legacy hello

0 commit comments

Comments
 (0)