Skip to content

Commit 343ff9a

Browse files
authored
DRIVERS-1807 Keep existing retry behavior unless CSOT is enabled (#1317)
Multiple retryable read/write attempts may occur only when CSOT is enabled. Adjust CSOT test timeouts to reduce flakiness.
1 parent 364761d commit 343ff9a

11 files changed

+380
-364
lines changed

source/client-side-operations-timeout/client-side-operations-timeout.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ timeoutMS
4747
~~~~~~~~~
4848

4949
This 64-bit integer option specifies the per-operation timeout value in
50-
milliseconds. The default value is unset. Both unset and an explicit value of
51-
0 mean infinite, though some client-side timeouts like
50+
milliseconds. The default value is unset which means this feature is not
51+
enabled, i.e. the existing timeout behavior is unchanged (including
52+
``serverSelectionTimeoutMS``, ``connectTimeoutMS``, ``socketTimeoutMS`` etc..).
53+
An explicit value of 0 means infinite, though some client-side timeouts like
5254
``serverSelectionTimeoutMS`` will still apply. Drivers MUST error if a
5355
negative value is specified. This value MUST be configurable at the level of
5456
a MongoClient, MongoDatabase, MongoCollection, or of a single operation.
@@ -347,7 +349,7 @@ Retryability
347349
~~~~~~~~~~~~
348350

349351
If an operation requires a retry per the retryable reads or writes
350-
specifications and ``timeoutMS`` is set to a non-zero value, drivers MUST
352+
specifications and ``timeoutMS`` is set, drivers MUST
351353
retry operations as many times as possible before the timeout expires or a
352354
retry attempt returns a non-retryable error. Once the timeout expires, a
353355
timeout error MUST be raised.

source/client-side-operations-timeout/etc/templates/retryability-legacy-timeouts.yml.template

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ createEntities:
1515
- client:
1616
id: &client client
1717
uriOptions:
18-
socketTimeoutMS: 50
18+
socketTimeoutMS: 100
1919
useMultipleMongoses: false
2020
observeEvents:
2121
- commandStartedEvent
@@ -38,8 +38,8 @@ initialData:
3838
tests:
3939
# For each retryable operation, run two tests:
4040
#
41-
# 1. Socket timeouts are retried once - Each test constructs a client entity with socketTimeoutMS=50, configures a
42-
# fail point to block the operation once for 55ms, and expects the operation to succeed.
41+
# 1. Socket timeouts are retried once - Each test constructs a client entity with socketTimeoutMS=100, configures a
42+
# fail point to block the operation once for 125ms, and expects the operation to succeed.
4343
#
4444
# 2. Operations fail after two consecutive socket timeouts - Same as (1) but the fail point is configured to block
4545
# the operation twice and the test expects the operation to fail.
@@ -57,7 +57,7 @@ tests:
5757
data:
5858
failCommands: ["{{operation.command_name}}"]
5959
blockConnection: true
60-
blockTimeMS: 55
60+
blockTimeMS: 125
6161
- name: {{operation.operation_name}}
6262
object: *{{operation.object}}
6363
{% if operation.arguments|length > 0 -%}
@@ -91,7 +91,7 @@ tests:
9191
data:
9292
failCommands: ["{{operation.command_name}}"]
9393
blockConnection: true
94-
blockTimeMS: 55
94+
blockTimeMS: 125
9595
- name: {{operation.operation_name}}
9696
object: *{{operation.object}}
9797
{% if operation.arguments|length > 0 -%}

source/client-side-operations-timeout/etc/templates/retryability-timeoutMS.yml.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ tests:
104104
- name: {{operation.operation_name}}
105105
object: *{{operation.object}}
106106
arguments:
107-
timeoutMS: 500
107+
timeoutMS: 1000
108108
{% for arg in operation.arguments -%}
109109
{{arg}}
110110
{% endfor %}

source/client-side-operations-timeout/tests/bulkWrite.json

+13-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
"useMultipleMongoses": false,
2020
"observeEvents": [
2121
"commandStartedEvent"
22-
]
22+
],
23+
"uriOptions": {
24+
"w": 1
25+
}
2326
}
2427
},
2528
{
@@ -48,6 +51,13 @@
4851
{
4952
"description": "timeoutMS applied to entire bulkWrite, not individual commands",
5053
"operations": [
54+
{
55+
"name": "insertOne",
56+
"object": "collection",
57+
"arguments": {
58+
"document": {}
59+
}
60+
},
5161
{
5262
"name": "failPoint",
5363
"object": "testRunner",
@@ -69,15 +79,6 @@
6979
}
7080
}
7181
},
72-
{
73-
"name": "find",
74-
"object": "collection",
75-
"arguments": {
76-
"filter": {
77-
"_id": 1
78-
}
79-
}
80-
},
8182
{
8283
"name": "bulkWrite",
8384
"object": "collection",
@@ -114,10 +115,10 @@
114115
"events": [
115116
{
116117
"commandStartedEvent": {
117-
"commandName": "find",
118+
"commandName": "insert",
118119
"databaseName": "test",
119120
"command": {
120-
"find": "coll"
121+
"insert": "coll"
121122
}
122123
}
123124
},

source/client-side-operations-timeout/tests/bulkWrite.yml

+10-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ createEntities:
1414
useMultipleMongoses: false
1515
observeEvents:
1616
- commandStartedEvent
17+
uriOptions:
18+
# Used to speed up the test
19+
w: 1
1720
- database:
1821
id: &database database
1922
client: *client
@@ -34,6 +37,11 @@ tests:
3437
# bulkWrite should fail with a timeout error.
3538
- description: "timeoutMS applied to entire bulkWrite, not individual commands"
3639
operations:
40+
# Do an operation without a timeout to ensure the servers are discovered.
41+
- name: insertOne
42+
object: *collection
43+
arguments:
44+
document: {}
3745
- name: failPoint
3846
object: testRunner
3947
arguments:
@@ -45,11 +53,6 @@ tests:
4553
failCommands: ["insert", "update"]
4654
blockConnection: true
4755
blockTimeMS: 120
48-
# Do an operation without a timeout to ensure the servers are discovered.
49-
- name: find
50-
object: *collection
51-
arguments:
52-
filter: { _id : 1 }
5356
- name: bulkWrite
5457
object: *collection
5558
arguments:
@@ -66,10 +69,10 @@ tests:
6669
- client: *client
6770
events:
6871
- commandStartedEvent:
69-
commandName: find
72+
commandName: insert
7073
databaseName: *databaseName
7174
command:
72-
find: *collectionName
75+
insert: *collectionName
7376
- commandStartedEvent:
7477
commandName: insert
7578
databaseName: *databaseName

0 commit comments

Comments
 (0)