Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .evergreen/resync-specs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ do
;;
cmap|CMAP|connection-monitoring-and-pooling)
cpjson connection-monitoring-and-pooling/tests cmap
rm $PYMONGO/test/cmap/wait-queue-fairness.json # PYTHON-1873
rm $PYMONGO/test/cmap/cmap-format/wait-queue-fairness.json # PYTHON-1873
rm $PYMONGO/test/cmap/cmap-format/pool-clear-interrupt-immediately.json # PYTHON-3175
rm $PYMONGO/test/cmap/cmap-format/pool-clear-interrupting-pending-connections.json # PYTHON-3175
rm $PYMONGO/test/cmap/cmap-format/pool-clear-schedule-run-interruptInUseConnections-false.json # PYTHON-3175
rm $PYMONGO/test/cmap/unified/connection-logging.json # PYTHON-3113
rm $PYMONGO/test/cmap/unified/connection-pool-options-logging.json # PYTHON-3113
;;
apm|APM|command-monitoring|command_monitoring)
cpjson command-logging-and-monitoring/tests/monitoring command_monitoring
Expand Down
6 changes: 5 additions & 1 deletion pymongo/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,8 @@ def connect(self, handler=None):
try:
sock = _configured_socket(self.address, self.opts)
except BaseException as error:
if handler:
handler.handle(type(error), error)
if self.enabled_for_cmap:
listeners.publish_connection_closed(
self.address, conn_id, ConnectionClosedReason.ERROR
Expand All @@ -1376,7 +1378,9 @@ def connect(self, handler=None):
handler.contribute_socket(sock_info, completed_handshake=False)

sock_info.authenticate()
except BaseException:
except BaseException as error:
if handler:
handler.handle(type(error), error)
sock_info.close_socket(ConnectionClosedReason.ERROR)
raise

Expand Down
File renamed without changes.
68 changes: 68 additions & 0 deletions test/cmap/cmap-format/pool-checkout-error-auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": 1,
"style": "integration",
"description": "must properly handle auth error on check out",
"runOn": [
{
"minServerVersion": "4.9.0",
"auth": true
}
],
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"saslContinue"
],
"appName": "poolCheckOutAuthErrorTest",
"errorCode": 18
}
},
"poolOptions": {
"appName": "poolCheckOutAuthErrorTest"
},
"operations": [
{
"name": "ready"
},
{
"name": "checkOut"
}
],
"error": {
"type": "AuthenticationError"
},
"events": [
{
"type": "ConnectionCheckOutStarted",
"address": 42
},
{
"type": "ConnectionCreated",
"connectionId": 1,
"address": 42
},
{
"type": "ConnectionPoolCleared",
"address": 42
},
{
"type": "ConnectionClosed",
"connectionId": 1,
"address": 42,
"reason": "error"
},
{
"type": "ConnectionCheckOutFailed",
"address": 42,
"reason": "connectionError"
}
],
"ignore": [
"ConnectionPoolCreated",
"ConnectionPoolReady"
]
}
97 changes: 97 additions & 0 deletions test/cmap/cmap-format/pool-checkout-error-checkin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"version": 1,
"style": "integration",
"description": "checking in a connection after checkout fails closes connection",
"runOn": [
{
"minServerVersion": "4.9.0",
"auth": true
}
],
"poolOptions": {
"appName": "poolCheckOutErrorCheckInTest"
},
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"skip": 1
},
"data": {
"failCommands": [
"saslContinue"
],
"closeConnection": true,
"appName": "poolCheckOutErrorCheckInTest"
}
},
"operations": [
{
"name": "ready"
},
{
"name": "checkOut",
"label": "conn"
},
{
"name": "start",
"target": "thread1"
},
{
"name": "checkOut",
"thread": "thread1"
},
{
"name": "waitForEvent",
"event": "ConnectionCheckOutFailed",
"count": 1
},
{
"name": "checkIn",
"connection": "conn"
}
],
"events": [
{
"type": "ConnectionCheckOutStarted"
},
{
"type": "ConnectionCreated"
},
{
"type": "ConnectionReady"
},
{
"type": "ConnectionCheckedOut"
},
{
"type": "ConnectionCheckOutStarted"
},
{
"type": "ConnectionCreated"
},
{
"type": "ConnectionPoolCleared"
},
{
"type": "ConnectionClosed",
"reason": "error",
"connectionId": 2
},
{
"type": "ConnectionCheckOutFailed",
"reason": "connectionError"
},
{
"type": "ConnectionCheckedIn"
},
{
"type": "ConnectionClosed",
"connectionId": 1,
"reason": "stale"
}
],
"ignore": [
"ConnectionPoolCreated",
"ConnectionPoolReady"
]
}
105 changes: 105 additions & 0 deletions test/cmap/cmap-format/pool-checkout-error-clears-waitqueue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"version": 1,
"style": "integration",
"description": "connection error during checkout clears wait queue",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 50
},
"data": {
"failCommands": [
"hello",
"isMaster"
],
"appName": "poolCheckOutErrorWaitQueueTest",
"closeConnection": true,
"blockConnection": true,
"blockTimeMS": 1000
}
},
"poolOptions": {
"maxPoolSize": 1,
"waitQueueTimeoutMS": 30000,
"appName": "poolCheckOutErrorWaitQueueTest"
},
"operations": [
{
"name": "ready"
},
{
"name": "start",
"target": "thread1"
},
{
"name": "checkOut",
"thread": "thread1"
},
{
"name": "start",
"target": "thread2"
},
{
"name": "checkOut",
"thread": "thread2"
},
{
"name": "start",
"target": "thread3"
},
{
"name": "checkOut",
"thread": "thread3"
},
{
"name": "waitForEvent",
"event": "ConnectionCheckOutStarted",
"count": 3
},
{
"name": "waitForEvent",
"event": "ConnectionCheckOutFailed",
"count": 3,
"timeout": 2000
}
],
"events": [
{
"type": "ConnectionCheckOutStarted",
"address": 42
},
{
"type": "ConnectionCheckOutStarted",
"address": 42
},
{
"type": "ConnectionCheckOutStarted",
"address": 42
},
{
"type": "ConnectionPoolCleared",
"address": 42
},
{
"type": "ConnectionCheckOutFailed",
"reason": "connectionError",
"address": 42
},
{
"type": "ConnectionCheckOutFailed",
"reason": "connectionError",
"address": 42
},
{
"type": "ConnectionCheckOutFailed",
"reason": "connectionError",
"address": 42
}
],
"ignore": [
"ConnectionPoolReady",
"ConnectionCreated",
"ConnectionPoolCreated",
"ConnectionClosed"
]
}
82 changes: 82 additions & 0 deletions test/cmap/cmap-format/pool-checkout-error-concurrent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"version": 1,
"style": "integration",
"description": "must properly handle multiple concurrent network errors on check out",
"runOn": [
{
"minServerVersion": "4.9.0"
}
],
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 50
},
"data": {
"failCommands": [
"isMaster",
"hello"
],
"closeConnection": true,
"appName": "poolCheckOutErrorTest"
}
},
"poolOptions": {
"appName": "poolCheckOutErrorTest"
},
"operations": [
{
"name": "ready"
},
{
"name": "start",
"target": "thread1"
},
{
"name": "start",
"target": "thread2"
},
{
"name": "start",
"target": "thread3"
},
{
"name": "checkOut",
"thread": "thread1"
},
{
"name": "checkOut",
"thread": "thread2"
},
{
"name": "checkOut",
"thread": "thread3"
},
{
"name": "waitForEvent",
"event": "ConnectionCheckOutFailed",
"count": 3
},
{
"name": "ready"
}
],
"events": [
{
"type": "ConnectionPoolReady"
},
{
"type": "ConnectionPoolCleared"
},
{
"type": "ConnectionPoolReady"
}
],
"ignore": [
"ConnectionCheckOutStarted",
"ConnectionCheckOutFailed",
"ConnectionPoolCreated",
"ConnectionCreated",
"ConnectionClosed"
]
}
Loading