Skip to content

Commit 11c17e4

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

File tree

2 files changed

+6
-31
lines changed

2 files changed

+6
-31
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ response data is drained and the connection is ready to send the next command.
593593

594594
1. **Persist and update timestamp**: The connection must record the current time immediately after the original timeout.
595595
This timestamp MUST be updated to the current time whenever any bytes are successfully read, received, or consumed
596-
while draining of the pending response as part of checking out the connection.
596+
while draining of the pending response.
597597
2. **Aliveness check**: If driver uses synchronous read from the socket and the timestamp is older than 3 seconds, the
598598
driver MUST perform aliveness check either performing a non-blocking read or using the minimal possible timeout to
599599
check if at least one byte can be read/received. If at least one byte can be read the timestamp must be updated and

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

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ The following tests have not yet been automated, but MUST still be tested:
2323

2424
### Pending Response
2525

26-
If a connection with a pending response is idle for > 3 seconds, then drivers are expected to perform an aliveness check
27-
by attempting a non-blocking read of 1 byte from the inbound TCP buffer. The following two cases test both a successful
28-
read and a failed one.
29-
3026
Due to the complexity of managing a proxy layer, the following qualifying tests should only be run for non-ssl,
3127
non-auth, and non-compression connections.
3228

33-
#### Recover Partial Header Response
29+
#### Recover Partially Read Response
3430

35-
This test verifies that if only part of a response header arrives before a timeout, the driver can drain the rest of the
31+
This test verifies that if only part of a response was read before the timeout, the driver can drain the rest of the
3632
response and reuse the connection for the next operation.
3733

3834
1. Connect to the proxy server with `maxPoolSize=1` and `direct=true`, subscribing to the following CMAP events:
@@ -41,30 +37,9 @@ response and reuse the connection for the next operation.
4137
- `PendingResponseFailed`
4238
- `ConnectionClosed`
4339
2. Send a command (e.g. an insert) with a 200 millisecond timeout and the following `proxyTest` actions:
44-
- `sendBytes`: any value between 1 and 3
45-
- `delayMS`: 400 ( to exceed the 200 ms timeout)
46-
- `sendAll`: `true`
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`
55-
56-
#### Recover Partial Body Response
57-
58-
This test verifies that if only part of a response body arrives before a socket timeout, the driver can drain the rest
59-
of the response and reuse the connection for the next operation.
60-
61-
1. Connect to the proxy server with `maxPoolSize=1` and `direct=true`, subscribing to the following CMAP events:
62-
- `PendingResponseStarted`
63-
- `PendingResponseSucceeded`
64-
- `PendingResponseFailed`
65-
- `ConnectionClosed`
66-
2. Send a command (e.g. an insert) with a 200 millisecond timeout and the following `proxyTest` actions:
67-
- `sendBytes`: Any value > 16
40+
- `sendBytes`: We have 3 possible states here: a) Message size was partially read: random value between 1 and 3
41+
inclusive b) Message size was read, body was not read at all: use 4 c) Message size was read, body read
42+
partially: random value between 5 and 100 inclusive
6843
- `delayMS`: 400 ( to exceed the 200 ms timeout)
6944
- `sendAll`: `true`
7045
3. Assert that the operation failed with timeout error.

0 commit comments

Comments
 (0)