From d65d9a9e2169dc4bbb1802bbb605a8a664dd37f5 Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Mon, 15 Dec 2025 13:08:01 -0800 Subject: [PATCH 1/4] DRIVERS-3355: Fix Backpressure-related racy tests --- .../server-discovery-and-monitoring-tests.md | 10 +- ...ged-on-min-pool-size-population-error.json | 42 +++---- ...nged-on-min-pool-size-population-error.yml | 28 ++--- .../tests/unified/minPoolSize-error.json | 4 +- .../tests/unified/minPoolSize-error.yml | 4 +- .../pool-clear-min-pool-size-error.json | 114 +++++++----------- .../pool-clear-min-pool-size-error.yml | 75 ++++++------ 7 files changed, 127 insertions(+), 150 deletions(-) diff --git a/source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md b/source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md index 6e33aa890b..4fa6c6dec1 100644 --- a/source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md +++ b/source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md @@ -180,7 +180,9 @@ clear event. We create a setup client to enable the ingress connection establish connection storm. After the storm, we verify that some of the connections failed to checkout, but that the pool was not cleared. -This test requires MongoDB 7.0+. +This test requires MongoDB 8.0.12+. See the +[MongoDB Server Parameters](https://www.mongodb.com/docs/manual/reference/parameters/#mongodb-parameter-param.ingressConnectionEstablishmentRateLimiterEnabled) +for more details. 1. Create a test client that listens to CMAP events, with maxConnecting=100. The higher maxConnecting will help ensure contention for creating connections. @@ -205,7 +207,9 @@ This test requires MongoDB 7.0+. 6. Assert that 0 `PoolClearedEvent` occurred. -7. Sleep for 1 second to clear the rate limiter. +7. Ensure that the following steps run at test teardown even if the test fails: -8. Ensure that the following command runs at test teardown even if the test fails. + 7.1. Sleep for 1 second to clear the rate limiter. + + 7.2. Execute the following command: `client.admin("setParameter", 1, ingressConnectionEstablishmentRateLimiterEnabled=False)`. diff --git a/source/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.json b/source/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.json index 35a49c1323..f0597124b7 100644 --- a/source/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.json +++ b/source/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.json @@ -22,6 +22,27 @@ { "description": "the server description is not changed on handshake error during minPoolSize population", "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "skip": 1 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "authErrorTest", + "closeConnection": true + } + } + } + }, { "name": "createEntities", "object": "testRunner", @@ -46,27 +67,6 @@ ] } }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "skip": 1 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "authErrorTest", - "closeConnection": true - } - } - } - }, { "name": "waitForEvent", "object": "testRunner", diff --git a/source/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.yml b/source/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.yml index dd5029097d..e1d98dae20 100644 --- a/source/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.yml +++ b/source/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.yml @@ -12,6 +12,20 @@ createEntities: tests: - description: the server description is not changed on handshake error during minPoolSize population operations: + - name: failPoint + object: testRunner + arguments: + client: setupClient + failPoint: + configureFailPoint: failCommand + mode: + skip: 1 + data: + failCommands: + - hello + - isMaster + appName: authErrorTest + closeConnection: true - name: createEntities object: testRunner arguments: @@ -27,20 +41,6 @@ tests: maxConnecting: 1 serverMonitoringMode: poll heartbeatFrequencyMS: 1000000 - - name: failPoint - object: testRunner - arguments: - client: setupClient - failPoint: - configureFailPoint: failCommand - mode: - skip: 1 - data: - failCommands: - - hello - - isMaster - appName: authErrorTest - closeConnection: true - name: waitForEvent object: testRunner arguments: diff --git a/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json b/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json index bd9e9fcdec..555b37d0b9 100644 --- a/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json +++ b/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json @@ -27,7 +27,7 @@ ], "tests": [ { - "description": "Network error on minPoolSize background creation", + "description": "Server error on minPoolSize background creation", "operations": [ { "name": "failPoint", @@ -45,7 +45,7 @@ "isMaster" ], "appName": "SDAMminPoolSizeError", - "closeConnection": true + "errorCode": 91 } } } diff --git a/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml b/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml index 110e647c62..8a47187708 100644 --- a/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml +++ b/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml @@ -21,7 +21,7 @@ initialData: &initialData documents: [] tests: - - description: Network error on minPoolSize background creation + - description: Server error on minPoolSize background creation operations: # Configure the initial monitor handshake to succeed but the # first or second background minPoolSize establishments to fail. @@ -38,7 +38,7 @@ tests: - hello - isMaster appName: SDAMminPoolSizeError - closeConnection: true + errorCode: 91 - name: createEntities object: testRunner arguments: diff --git a/source/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.json b/source/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.json index 511a1fab7b..a0139bd033 100644 --- a/source/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.json +++ b/source/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.json @@ -56,7 +56,7 @@ "client": { "id": "client", "observeEvents": [ - "connectionCreatedEvent", + "poolReadyEvent", "poolClearedEvent", "connectionClosedEvent" ], @@ -75,7 +75,7 @@ "arguments": { "client": "client", "event": { - "poolClearedEvent": {} + "poolReadyEvent": {} }, "count": 1 } @@ -86,33 +86,48 @@ "arguments": { "client": "client", "event": { - "connectionClosedEvent": {} + "poolClearedEvent": {} }, "count": 1 } - } - ], - "expectEvents": [ + }, { - "client": "client", - "eventType": "cmap", - "events": [ - { - "connectionCreatedEvent": {} - }, - { - "poolClearedEvent": {} - }, - { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { "connectionClosedEvent": {} - } - ] + }, + "count": 1 + } } ] }, { "description": "Pool is not cleared on handshake error during minPoolSize population", "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "skip": 1 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "authErrorTest", + "closeConnection": true + } + } + } + }, { "name": "createEntities", "object": "testRunner", @@ -122,11 +137,9 @@ "client": { "id": "client", "observeEvents": [ - "topologyDescriptionChangedEvent", - "connectionCreatedEvent", + "poolReadyEvent", "poolClearedEvent", - "connectionClosedEvent", - "connectionReadyEvent" + "connectionClosedEvent" ], "uriOptions": { "appname": "authErrorTest", @@ -146,39 +159,11 @@ "arguments": { "client": "client", "event": { - "topologyDescriptionChangedEvent": { - "previousDescription": { - "type": "Unknown" - }, - "newDescription": { - "type": "Single" - } - } + "poolReadyEvent": {} }, "count": 1 } }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "authErrorTest", - "closeConnection": true - } - } - } - }, { "name": "waitForEvent", "object": "testRunner", @@ -189,26 +174,17 @@ }, "count": 1 } - } - ], - "expectEvents": [ + }, { - "client": "client", - "eventType": "cmap", - "events": [ - { - "connectionCreatedEvent": {} - }, - { - "connectionReadyEvent": {} - }, - { - "connectionCreatedEvent": {} + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} }, - { - "connectionClosedEvent": {} - } - ] + "count": 0 + } } ] } diff --git a/source/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.yml b/source/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.yml index 8b58f672d3..2c8e32a410 100644 --- a/source/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.yml +++ b/source/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.yml @@ -40,12 +40,21 @@ tests: - client: id: &client client observeEvents: - - connectionCreatedEvent + - poolReadyEvent - poolClearedEvent - connectionClosedEvent uriOptions: appname: authErrorTest minPoolSize: 1 + + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolReadyEvent: {} + count: 1 + - name: waitForEvent object: testRunner arguments: @@ -53,6 +62,7 @@ tests: event: poolClearedEvent: {} count: 1 + - name: waitForEvent object: testRunner arguments: @@ -60,16 +70,24 @@ tests: event: connectionClosedEvent: {} count: 1 - expectEvents: - - client: *client - eventType: cmap - events: - - connectionCreatedEvent: {} - - poolClearedEvent: {} - - connectionClosedEvent: {} - description: Pool is not cleared on handshake error during minPoolSize population operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + skip: 1 # skip one to let monitoring thread to move pool to ready state + data: + failCommands: + - hello + - isMaster + appName: authErrorTest + closeConnection: true + - name: createEntities object: testRunner arguments: @@ -77,11 +95,9 @@ tests: - client: id: &client client observeEvents: - - topologyDescriptionChangedEvent - - connectionCreatedEvent + - poolReadyEvent - poolClearedEvent - connectionClosedEvent - - connectionReadyEvent uriOptions: appname: authErrorTest minPoolSize: 5 @@ -96,28 +112,9 @@ tests: arguments: client: *client event: - topologyDescriptionChangedEvent: - previousDescription: - type: "Unknown" - newDescription: - type: "Single" + poolReadyEvent: {} count: 1 - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - hello - - isMaster - appName: authErrorTest - closeConnection: true - - name: waitForEvent object: testRunner arguments: @@ -125,11 +122,11 @@ tests: event: connectionClosedEvent: {} count: 1 - expectEvents: - - client: *client - eventType: cmap - events: - - connectionCreatedEvent: {} - - connectionReadyEvent: {} - - connectionCreatedEvent: {} - - connectionClosedEvent: {} + + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 0 From 530e27f30b758b4b34182b3ee7470da3bfc8de4e Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Mon, 15 Dec 2025 14:19:26 -0800 Subject: [PATCH 2/4] pr --- source/logging/logging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/logging/logging.md b/source/logging/logging.md index 6f7c36c200..8971dbcde7 100644 --- a/source/logging/logging.md +++ b/source/logging/logging.md @@ -95,7 +95,7 @@ Drivers MUST support configuring where log messages should be output, including > - If the value is "stdout" (case-insensitive), log to stdout. > - If the value is "stderr" (case-insensitive), log to stderr. > - Else, if direct logging to files is supported, log to a file at the specified path. If the file already exists, it - > MUST be appended to. + > MUST be appended to. > > If the variable is not provided or is set to an invalid value (which could be invalid for any reason, e.g. the path > does not exist or is not writeable), the driver MUST log to stderr and the driver MAY attempt to warn the user about From 43ddecb593b288a0e17ffc267a1daf0134857faa Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Tue, 16 Dec 2025 10:23:13 -0800 Subject: [PATCH 3/4] pr --- .../tests/unified/minPoolSize-error.json | 1 + .../tests/unified/minPoolSize-error.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json b/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json index 555b37d0b9..0ce2bdd6c1 100644 --- a/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json +++ b/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json @@ -68,6 +68,7 @@ "heartbeatFrequencyMS": 10000, "appname": "SDAMminPoolSizeError", "minPoolSize": 10, + "serverMonitoringMode": "poll", "serverSelectionTimeoutMS": 1000 } } diff --git a/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml b/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml index 8a47187708..1bbc0c376e 100644 --- a/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml +++ b/source/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml @@ -54,6 +54,7 @@ tests: heartbeatFrequencyMS: 10000 appname: SDAMminPoolSizeError minPoolSize: 10 + serverMonitoringMode: poll serverSelectionTimeoutMS: 1000 - database: id: &database database From fc6dca86e712c7960ecf858ee156adcd9dba60d2 Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Wed, 17 Dec 2025 09:29:10 -0800 Subject: [PATCH 4/4] Pr --- .../server-discovery-and-monitoring-tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md b/source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md index 4fa6c6dec1..5e3607628a 100644 --- a/source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md +++ b/source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md @@ -180,7 +180,7 @@ clear event. We create a setup client to enable the ingress connection establish connection storm. After the storm, we verify that some of the connections failed to checkout, but that the pool was not cleared. -This test requires MongoDB 8.0.12+. See the +This test requires MongoDB 7.0+. See the [MongoDB Server Parameters](https://www.mongodb.com/docs/manual/reference/parameters/#mongodb-parameter-param.ingressConnectionEstablishmentRateLimiterEnabled) for more details.