-
Notifications
You must be signed in to change notification settings - Fork 247
DRIVERS-3239: Add exponential backoff to operation retry loop for server overloaded errors #1862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: client-backpressure
Are you sure you want to change the base?
Changes from 13 commits
588f1f2
e467f5b
d55fdb9
8e74b41
072b453
52e2a35
391c951
92501c0
0fdef39
82acab8
b3a7b6c
60a87b8
399a56b
0545e15
ff5475a
6211624
c1001bc
def5fbd
08da5c4
034b85e
779e171
e5d4de6
1cd95fc
6912e45
88e6067
2019678
d3ce32b
de7e862
ab85a5b
eb10ddb
2b90697
0abf373
d07d49e
747c18c
be27bc0
92e479a
b674f13
03065ad
1b7f6df
eac90fc
0533acc
629aec9
9e4ad70
d4d0b38
530e727
c31f486
12ab836
1b32e00
a00a063
4fe6b74
fe4ff25
3e58204
b2b5a4d
39d752c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Client Backpressure Tests | ||
|
|
||
| ______________________________________________________________________ | ||
|
|
||
| ## Introduction | ||
|
|
||
| The YAML and JSON files in this directory are platform-independent tests meant to exercise a driver's implementation of | ||
| retryable reads. These tests utilize the [Unified Test Format](../../unified-test-format/unified-test-format.md). | ||
|
|
||
| Several prose tests, which are not easily expressed in YAML, are also presented in this file. Those tests will need to | ||
| be manually implemented by each driver. | ||
|
|
||
| ### Prose Tests | ||
|
|
||
| #### Test 1: Operation Retry Uses Exponential Backoff | ||
|
|
||
| Drivers should test that retries do not occur immediately when a SystemOverloadedError is encountered. | ||
|
|
||
| 1. let `client` be a `MongoClient` | ||
| 2. let `collection` be a collection | ||
| 3. Now, run transactions without backoff: | ||
| 1. Configure the random number generator used for jitter to always return `0` -- this effectively disables backoff. | ||
|
|
||
| 2. Configure the following failPoint: | ||
|
|
||
| ```javascript | ||
| { | ||
| configureFailPoint: 'failCommand', | ||
| mode: 'alwaysOn', | ||
| data: { | ||
| failCommands: ['insert'], | ||
jmikola marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| errorCode: 2, | ||
| errorLabels: ['SystemOverloadedError', 'RetryableError'] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 3. Execute the following command. Expect that the command errors. Measure the duration of the command execution. | ||
|
||
|
|
||
| ```javascript | ||
| const start = performance.now(); | ||
| expect( | ||
| await coll.insertOne({ a: 1 }).catch(e => e) | ||
| ).to.be.an.instanceof(MongoServerError); | ||
| const end = performance.now(); | ||
| ``` | ||
|
|
||
| 4. Configure the random number generator used for jitter to always return `1`. | ||
|
|
||
| 5. Execute step 3 again. | ||
|
|
||
| 6. Compare the two time between the two runs. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume the following lines should all appear under element six. If so, indentation is needed (check preview). |
||
| ```python | ||
| assertTrue(absolute_value(with_backoff_time - (no_backoff_time + 3.1 seconds)) < 1) | ||
| ``` | ||
Jibola marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| The sum of 5 backoffs is 3.1 seconds. There is a 1-second window to account for potential variance between the two | ||
| runs. | ||
|
|
||
| ## Changelog | ||
|
|
||
| - 2025-XX-XX: Initial version. | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.