From cb8e6b75b5f416c18ad09be5403858cefa066993 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Fri, 1 Dec 2023 10:06:18 -0600 Subject: [PATCH] DRIVERS-926 Make ReadConcernMajorityNotAvailableYet a retryable read error --- source/retryable-reads/retryable-reads.rst | 35 +++-- .../readConcernMajorityNotAvailableYet.json | 147 ++++++++++++++++++ .../readConcernMajorityNotAvailableYet.yml | 68 ++++++++ 3 files changed, 234 insertions(+), 16 deletions(-) create mode 100644 source/retryable-reads/tests/unified/readConcernMajorityNotAvailableYet.json create mode 100644 source/retryable-reads/tests/unified/readConcernMajorityNotAvailableYet.yml diff --git a/source/retryable-reads/retryable-reads.rst b/source/retryable-reads/retryable-reads.rst index 957aa69b51..e575f9799d 100644 --- a/source/retryable-reads/retryable-reads.rst +++ b/source/retryable-reads/retryable-reads.rst @@ -51,22 +51,23 @@ An error is considered retryable if it meets any of the following criteria: - a server error response with any the following codes: -=============================== ============== -**Error Name** **Error Code** -=============================== ============== -ExceededTimeLimit 262 -InterruptedAtShutdown 11600 -InterruptedDueToReplStateChange 11602 -NotWritablePrimary 10107 -NotPrimaryNoSecondaryOk 13435 -NotPrimaryOrSecondary 13436 -PrimarySteppedDown 189 -ShutdownInProgress 91 -HostNotFound 7 -HostUnreachable 6 -NetworkTimeout 89 -SocketException 9001 -=============================== ============== +================================== ============== +**Error Name** **Error Code** +================================== ============== +ExceededTimeLimit 262 +InterruptedAtShutdown 11600 +InterruptedDueToReplStateChange 11602 +NotWritablePrimary 10107 +NotPrimaryNoSecondaryOk 13435 +NotPrimaryOrSecondary 13436 +PrimarySteppedDown 189 +ReadConcernMajorityNotAvailableYet 134 +ShutdownInProgress 91 +HostNotFound 7 +HostUnreachable 6 +NetworkTimeout 89 +SocketException 9001 +================================== ============== - a `PoolClearedError`_ @@ -704,6 +705,8 @@ degraded performance can simply disable ``retryableReads``. Changelog ========= +:2023-11-30: Add to ReadConcernMajorityNotAvailableYet the list of error codes + that should be retried. :2023-11-28: Add ExceededTimeLimit to the list of error codes that should be retried. :2023-08-26: Require that in a sharded cluster the server on which the diff --git a/source/retryable-reads/tests/unified/readConcernMajorityNotAvailableYet.json b/source/retryable-reads/tests/unified/readConcernMajorityNotAvailableYet.json new file mode 100644 index 0000000000..8aa6a6b5e5 --- /dev/null +++ b/source/retryable-reads/tests/unified/readConcernMajorityNotAvailableYet.json @@ -0,0 +1,147 @@ +{ + "description": "ReadConcernMajorityNotAvailableYet is a retryable read", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "single", + "replicaset" + ] + }, + { + "minServerVersion": "4.1.7", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "retryable-reads-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "readconcernmajoritynotavailableyet_test" + } + } + ], + "initialData": [ + { + "collectionName": "readconcernmajoritynotavailableyet_test", + "databaseName": "retryable-reads-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ], + "tests": [ + { + "description": "Find succeeds on second attempt after ReadConcernMajorityNotAvailableYet", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "find" + ], + "errorCode": 134 + } + } + } + }, + { + "name": "find", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + } + }, + "object": "collection0", + "expectResult": [ + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "readconcernmajoritynotavailableyet_test", + "filter": { + "_id": { + "$gt": 1 + } + } + }, + "commandName": "find", + "databaseName": "retryable-reads-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "find": "readconcernmajoritynotavailableyet_test", + "filter": { + "_id": { + "$gt": 1 + } + } + }, + "commandName": "find", + "databaseName": "retryable-reads-tests" + } + } + ] + } + ] + } + ] +} diff --git a/source/retryable-reads/tests/unified/readConcernMajorityNotAvailableYet.yml b/source/retryable-reads/tests/unified/readConcernMajorityNotAvailableYet.yml new file mode 100644 index 0000000000..707a62acd7 --- /dev/null +++ b/source/retryable-reads/tests/unified/readConcernMajorityNotAvailableYet.yml @@ -0,0 +1,68 @@ +description: "ReadConcernMajorityNotAvailableYet is a retryable read" + +schemaVersion: "1.3" + +runOnRequirements: + - minServerVersion: "4.0" + topologies: [single, replicaset] + - minServerVersion: "4.1.7" + topologies: [sharded, load-balanced] + +createEntities: + - client: + id: &client0 client0 + # Ensure the `configureFailpoint` and `find` commands are run on the same mongos + useMultipleMongoses: false + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name "retryable-reads-tests" + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name "readconcernmajoritynotavailableyet_test" + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "Find succeeds on second attempt after ReadConcernMajorityNotAvailableYet" + operations: + - name: failPoint + object: testRunner + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ "find" ] + errorCode: 134 # ReadConcernMajorityNotAvailableYet + - name: find + arguments: + filter: { _id: { $gt: 1 } } + object: *collection0 + expectResult: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: { _id: { $gt: 1 } } + commandName: find + databaseName: *database0Name + - commandStartedEvent: + command: + find: *collection0Name + filter: { _id: { $gt: 1 } } + commandName: find + databaseName: *database0Name