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.
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.
Drivers should test that retries do not occur immediately when a SystemOverloadedError is encountered. This test MUST be
executed against a MongoDB 4.4+ server that has enabled the configureFailPoint command with the errorLabels option.
- Let
clientbe aMongoClient - Let
collectionbe a collection - Now, run transactions without backoff:
-
Configure the random number generator used for jitter to always return
0-- this effectively disables backoff. -
Configure the following failPoint:
{ configureFailPoint: 'failCommand', mode: 'alwaysOn', data: { failCommands: ['insert'], errorCode: 2, errorLabels: ['SystemOverloadedError', 'RetryableError'] } }
-
Insert the document
{ a: 1 }. Expect that the command errors. Measure the duration of the command execution.const start = performance.now(); expect( await coll.insertOne({ a: 1 }).catch(e => e) ).to.be.an.instanceof(MongoServerError); const end = performance.now();
-
Configure the random number generator used for jitter to always return a number as close as possible to
1. -
Execute step 3 again.
-
Compare the time between the two runs.
assertTrue(absolute_value(with_backoff_time - (no_backoff_time + 0.3 seconds)) < 0.3 seconds)
The sum of 2 backoffs is 0.3 seconds. There is a 0.3-second window to account for potential variance between the two runs.
-
Drivers should test that overload errors are retried a maximum of MAX_RETRIES times. This test MUST be executed against
a MongoDB 4.4+ server that has enabled the configureFailPoint command with the errorLabels option.
-
Let
clientbe aMongoClientwith command event monitoring enabled. -
Let
collbe a collection. -
Configure the following failpoint:
{ configureFailPoint: 'failCommand', mode: 'alwaysOn', data: { failCommands: ['find'], errorCode: 462, // IngressRequestRateLimitExceeded errorLabels: ['SystemOverloadedError', 'RetryableError'] } }
-
Perform a find operation with
collthat fails. -
Assert that the raised error contains both the
RetryableErrorandSystemOverloadedErrorerror labels. -
Assert that the total number of started commands is MAX_RETRIES + 1 (3).
Drivers should test that overload errors are retried a maximum of maxAdaptiveRetries times, when configured. This test
MUST be executed against a MongoDB 4.4+ server that has enabled the configureFailPoint command with the errorLabels
option.
-
Let
clientbe aMongoClientwithmaxAdaptiveRetries=1and command event monitoring enabled. -
Let
collbe a collection. -
Configure the following failpoint:
{ configureFailPoint: 'failCommand', mode: 'alwaysOn', data: { failCommands: ['find'], errorCode: 462, // IngressRequestRateLimitExceeded errorLabels: ['SystemOverloadedError', 'RetryableError'] } }
-
Perform a find operation with
collthat fails. -
Assert that the raised error contains both the
RetryableErrorandSystemOverloadedErrorerror labels. -
Assert that the total number of started commands is
maxAdaptiveRetries+ 1 (2).