Skip to content

Commit 7a64cfc

Browse files
committed
PYTHON-1110 - Multihomed and round robin DNS addresses are not supported
1 parent c4e8d22 commit 7a64cfc

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

doc/examples/high_availability.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ the following connects to the replica set we just created::
9696
The addresses passed to :meth:`~pymongo.mongo_client.MongoClient` are called
9797
the *seeds*. As long as at least one of the seeds is online, MongoClient
9898
discovers all the members in the replica set, and determines which is the
99-
current primary and which are secondaries or arbiters.
99+
current primary and which are secondaries or arbiters. Each seed must be the
100+
address of a single mongod. Multihomed and round robin DNS addresses are
101+
**not** supported.
100102

101103
The :class:`~pymongo.mongo_client.MongoClient` constructor is non-blocking:
102104
the constructor returns immediately while the client connects to the replica
@@ -325,11 +327,12 @@ mongos Load Balancing
325327
---------------------
326328

327329
An instance of :class:`~pymongo.mongo_client.MongoClient` can be configured
328-
with a list of mongos servers:
330+
with a list of addresses of mongos servers:
329331

330332
>>> client = MongoClient('mongodb://host1,host2,host3')
331333

332-
Each member of the list must be a mongos server. The client continuously
334+
Each member of the list must be a single mongos server. Multihomed and round
335+
robin DNS addresses are **not** supported. The client continuously
333336
monitors all the mongoses' availability, and its network latency to each.
334337

335338
PyMongo distributes operations evenly among the set of mongoses within its
@@ -352,3 +355,7 @@ But it excuses host3: host3 is 20ms beyond the lowest-latency server.
352355
If we set ``localThresholdMS`` to 30 ms all servers are within the threshold:
353356

354357
>>> client = MongoClient('mongodb://host1,host2,host3/?localThresholdMS=30')
358+
359+
.. warning:: Do **not** connect PyMongo to a pool of mongos instances through a
360+
load balancer. A single socket connection must always be routed to the same
361+
mongos instance for proper cursor support.

pymongo/mongo_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,12 @@ def __init__(
107107
read :ref:`multiprocessing` first.
108108
109109
:Parameters:
110-
- `host` (optional): hostname or IP address of the
111-
instance to connect to, or a mongodb URI, or a list of
110+
- `host` (optional): hostname or IP address of a single mongod or
111+
mongos instance to connect to, or a mongodb URI, or a list of
112112
hostnames / mongodb URIs. If `host` is an IPv6 literal
113113
it must be enclosed in '[' and ']' characters following
114-
the RFC2732 URL syntax (e.g. '[::1]' for localhost)
114+
the RFC2732 URL syntax (e.g. '[::1]' for localhost). Multihomed
115+
and round robin DNS addresses are **not** supported.
115116
- `port` (optional): port number on which to connect
116117
- `document_class` (optional): default class to use for
117118
documents returned from queries on this client

0 commit comments

Comments
 (0)