Skip to content

Commit 3e60a7c

Browse files
authored
DRIVERS-1641: pre-4.4 mongos writeConcernError does not determine retryability (#1486)
Also clarify that pre-4.4 writeErrors[].code should never be used to determine retryability. This is intentionally untested because failCommand does not provide a way to mock writeErrors.
1 parent 2176bba commit 3e60a7c

File tree

3 files changed

+436
-3
lines changed

3 files changed

+436
-3
lines changed

source/retryable-writes/retryable-writes.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ The RetryableWriteError label might be added to an error in a variety of ways:
252252
errors that meet the following criteria if the retryWrites option is set to
253253
true on the client performing the relevant operation:
254254

255-
- a server error response with any the following codes:
255+
- a mongod or mongos response with any the following error codes in the
256+
top-level ``code`` field:
256257

257258
.. list-table::
258259
:header-rows: 1
@@ -284,8 +285,14 @@ The RetryableWriteError label might be added to an error in a variety of ways:
284285
* - ExceededTimeLimit
285286
- 262
286287

287-
- a server response with a write concern error response containing any of the
288-
previously listed codes
288+
- a mongod response with any of the previously listed codes in the
289+
``writeConcernError.code`` field.
290+
291+
Drivers MUST NOT add a RetryableWriteError label based on the following:
292+
293+
- any ``writeErrors[].code`` fields in a mongod or mongos response
294+
295+
- the ``writeConcernError.code`` field in a mongos response
289296

290297
The criteria for retryable errors is similar to the discussion in the SDAM
291298
spec's section on `Error Handling`_, but includes additional error codes. See
@@ -854,6 +861,9 @@ inconsistent with the server and potentially confusing to developers.
854861
Changelog
855862
=========
856863

864+
:2024-01-16: Do not use ``writeConcernError.code`` in pre-4.4 mongos response to
865+
determine retryability. Do not use ``writeErrors[].code`` in
866+
pre-4.4 server responses to determine retryability.
857867
:2023-12-06: Clarify that writes are not retried within transactions.
858868
:2023-12-05: Add that any server information associated with retryable
859869
exceptions MUST reflect the originating server, even in the

source/retryable-writes/tests/unified/insertOne-serverErrors.json

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

0 commit comments

Comments
 (0)