Skip to content

Commit db86538

Browse files
committed
DRIVERS-2884: CSOT avoid connection churn when operations timeout
1 parent 49dbe97 commit db86538

File tree

4 files changed

+63
-33
lines changed

4 files changed

+63
-33
lines changed

source/client-side-operations-timeout/tests/pending-response.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ tests:
122122
events:
123123
- commandFailedEvent:
124124
commandName: insert
125-
# No second failed event since we timed out attempting to check out
126-
# the connection for the second operation.
127125
- commandSucceededEvent:
128126
commandName: find
129127
- client: *client

source/connection-monitoring-and-pooling/tests/README.md

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ non-auth, and non-compression connections.
3232

3333
#### Recover Partial Header Response
3434

35-
This test verifies that if only part of a response header arrives before a socket timeout, the driver can drain the rest
36-
of the response and reuse the connection for the next operation.
35+
This test verifies that if only part of a response header arrives before a timeout, the driver can drain the rest of the
36+
response and reuse the connection for the next operation.
3737

3838
1. Connect to the proxy server with `maxPoolSize=1` and `direct=true`, subscribing to the following CMAP events:
3939
- `PendingResponseStarted`
@@ -44,12 +44,14 @@ of the response and reuse the connection for the next operation.
4444
- `sendBytes`: any value between 1 and 3
4545
- `delayMS`: 400 ( to exceed the 200 ms timeout)
4646
- `sendAll`: `true`
47-
3. Issue any follow-up operation and assert that it does not return an error.
48-
4. Verify that we've received the following events from the `insertOne` step:
49-
- 1x`ConnectionPendingResponseStarted`
50-
- 0x`ConnectionPendingResponseFailed`
51-
- 1x`ConnectionPendingResponseSucceeded`
52-
- 0x`ConnectionClosed`
47+
3. Assert that the operation failed with timeout error.
48+
4. Issue another operation (e.g. another insert) and assert that it does not return an error.
49+
5. Verify that the following sequence of events was observed:
50+
- `ConnectionPendingResponseStarted`
51+
- `ConnectionPendingResponseSucceeded`
52+
6. Verify that NONE the following events was observed:
53+
- `ConnectionPendingResponseFailed`
54+
- `ConnectionClosed`
5355

5456
#### Recover Partial Body Response
5557

@@ -65,16 +67,18 @@ of the response and reuse the connection for the next operation.
6567
- `sendBytes`: Any value > 16
6668
- `delayMS`: 400 ( to exceed the 200 ms timeout)
6769
- `sendAll`: `true`
68-
3. Issue any follow-up operation and assert that it does not return an error.
69-
4. Verify that we've received the following events from the `insertOne` step:
70-
- 1x`ConnectionPendingResponseStarted`
71-
- 0x`ConnectionPendingResponseFailed`
72-
- 1x`ConnectionPendingResponseSucceeded`
73-
- 0x`ConnectionClosed`
70+
3. Assert that the operation failed with timeout error.
71+
4. Issue another operation (e.g. another insert) and assert that it does not return an error.
72+
5. Verify that the following sequence of events was observed:
73+
- `ConnectionPendingResponseStarted`
74+
- `ConnectionPendingResponseSucceeded`
75+
6. Verify that NONE the following events was observed:
76+
- `ConnectionPendingResponseFailed`
77+
- `ConnectionClosed`
7478

7579
#### Non-destructive Aliveness Check
7680

77-
This test verifies that if a connection idles past the driver's aliveness window (3 seconds) after a partial header, the
81+
This test verifies that if a connection idles past the pending response window (3 seconds) after a partial header, the
7882
aliveness check does not attempt to discard bytes from the TCP stream.
7983

8084
1. Connect to the proxy server with `maxPoolSize=1` and `direct=true`, subscribing to the following CMAP events:
@@ -86,13 +90,16 @@ aliveness check does not attempt to discard bytes from the TCP stream.
8690
- `sendBytes`: any value between 1 and 3
8791
- `delayMS`: 400 ( to exceed the 200 ms timeout)
8892
- `sendAll`: `true`
89-
3. Sleep for 3 seconds
90-
4. Issue any follow-up operation and assert that it does not return an error.
91-
5. Verify that we've received the following events from the `insertOne` step:
92-
- 2x`ConnectionPendingResponseStarted`
93-
- 1x`ConnectionPendingResponseFailed`
94-
- 1x`ConnectionPendingResponseSucceeded`
95-
- 0x`ConnectionClosed`
93+
3. Assert that the operation failed with timeout error.
94+
4. Sleep for 3 seconds
95+
5. Issue another operation (e.g. another insert) and assert that it does not return an error.
96+
6. Verify that the following sequence of events was observed:
97+
- `ConnectionPendingResponseStarted`
98+
- `ConnectionPendingResponseFailed`
99+
- `ConnectionPendingResponseStarted`
100+
- `ConnectionPendingResponseSucceeded`
101+
7. Verify that NONE the following events was observed:
102+
- `ConnectionClosed`
96103

97104
#### Exhaust Cursors
98105

source/connection-monitoring-and-pooling/tests/logging/connection-logging-csot.json

Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/connection-monitoring-and-pooling/tests/logging/connection-logging-csot.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ tests:
2222
uriOptions:
2323
retryReads: false
2424
appname: &clientAppName clientAppName
25+
maxPoolSize: 1
2526
# use a high heartbeatFrequencyMS to avoid a successful monitor check marking the pool as
2627
# ready (and emitting another event) during the course of test execution.
2728
heartbeatFrequencyMS: 10000
@@ -55,7 +56,7 @@ tests:
5556
data:
5657
failCommands: ["insert"]
5758
blockConnection: true
58-
blockTimeMS: 200
59+
blockTimeMS: 300
5960

6061
# Execute operation with timeout less than block time
6162
- name: insertOne
@@ -68,11 +69,11 @@ tests:
6869

6970
# Execute a subsequent operation which should time out during the
7071
# pending response read attempt.
71-
- name: findOne
72+
- name: find
7273
object: *collection
7374
arguments:
7475
filter: { _id: 1 }
75-
timeoutMS: 100
76+
timeoutMS: 75
7677
expectError:
7778
isTimeoutError: true
7879

@@ -81,10 +82,10 @@ tests:
8182
# operation.
8283
object: testRunner
8384
arguments:
84-
ms: 75
85+
ms: 200
8586

8687
# Execute a subsequent operation which should completed the pending read.
87-
- name: findOne
88+
- name: find
8889
object: *collection
8990
arguments:
9091
filter: { _id: 1 }
@@ -201,6 +202,13 @@ tests:
201202
requestId: { $$type: [int, long] }
202203
reason: "timeout"
203204

205+
- level: debug
206+
component: connection
207+
data:
208+
message: "Connection checkout failed"
209+
serverHost: { $$type: string }
210+
serverPort: { $$type: [ int, long ] }
211+
204212
# Second Find
205213
- level: debug
206214
component: connection

0 commit comments

Comments
 (0)