Skip to content

Commit 34f3a15

Browse files
authored
PYTHON-3349 Don't clear entire load balanced pool when serviceId is unknown (#1001)
1 parent d2b95d1 commit 34f3a15

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CONTRIBUTING.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ Running Load Balancer Tests Locally
8383
-----------------------------------
8484
- Install ``haproxy`` (available as ``brew install haproxy`` on macOS).
8585
- Clone ``drivers-evergreen-tools``: ``git clone [email protected]:mongodb-labs/drivers-evergreen-tools.git``.
86-
- Start the servers using ``LOAD_BALANCER=true TOPOLOGY=sharded_cluster AUTH=noauth SSL=nossl MONGODB_VERSION=6.0 DRIVERS_TOOLS=./drivers-evergreen-tools MONGO_ORCHESTRATION_HOME=./drivers-evergreen-tools/.evergreen/orchestration ./drivers-evergreen-tools/.evergreen/run-orchestration.sh``.
87-
- Start the load balancer using: ``MONGODB_URI='mongodb://localhost:27017,localhost:27018/' .evergreen/run-load-balancer.sh start``.
88-
- Run the tests using: ``LOADBALANCER=1 TEST_LOADBALANCER=1 SINGLE_MONGOS_LB_URI='mongodb://127.0.0.1:8000/?loadBalanced=true' MULTI_MONGOS_LB_URI='mongodb://127.0.0.1:8001/?loadBalanced=true' MONGODB_URI='mongodb://localhost:27017,localhost:27018/' python setup.py test -s test.test_load_balancer``.
86+
- Start the servers using ``LOAD_BALANCER=true TOPOLOGY=sharded_cluster AUTH=noauth SSL=nossl MONGODB_VERSION=6.0 DRIVERS_TOOLS=$PWD/drivers-evergreen-tools MONGO_ORCHESTRATION_HOME=$PWD/drivers-evergreen-tools/.evergreen/orchestration $PWD/drivers-evergreen-tools/.evergreen/run-orchestration.sh``.
87+
- Start the load balancer using: ``MONGODB_URI='mongodb://localhost:27017,localhost:27018/' $PWD/drivers-evergreen-tools/.evergreen/run-load-balancer.sh start``.
88+
- Run the tests from the ``pymongo`` checkout directory using: ``LOADBALANCER=1 TEST_LOADBALANCER=1 SINGLE_MONGOS_LB_URI='mongodb://127.0.0.1:8000/?loadBalanced=true' MULTI_MONGOS_LB_URI='mongodb://127.0.0.1:8001/?loadBalanced=true' MONGODB_URI='mongodb://localhost:27017,localhost:27018/' python setup.py test -s test.test_load_balancer``.
8989

9090
Re-sync Spec Tests
9191
------------------

pymongo/topology.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,14 @@ def _handle_error(self, address, err_ctx):
644644
error = err_ctx.error
645645
exc_type = type(error)
646646
service_id = err_ctx.service_id
647+
648+
# Ignore a handshake error if the server is behind a load balancer but
649+
# the service ID is unknown. This indicates that the error happened
650+
# when dialing the connection or during the MongoDB handshake, so we
651+
# don't know the service ID to use for clearing the pool.
652+
if self._settings.load_balanced and not service_id and not err_ctx.completed_handshake:
653+
return
654+
647655
if issubclass(exc_type, NetworkTimeout) and err_ctx.completed_handshake:
648656
# The socket has been closed. Don't reset the server.
649657
# Server Discovery And Monitoring Spec: "When an application

0 commit comments

Comments
 (0)