From f2dc163e09ff242f258d281148d1e524003084eb Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 28 Nov 2023 08:29:54 -0600 Subject: [PATCH 1/4] add ExceededTimeLimit to the list of error codes that should receive a RetryableReadError label --- src/libmongoc/src/mongoc/mongoc-error.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libmongoc/src/mongoc/mongoc-error.c b/src/libmongoc/src/mongoc/mongoc-error.c index 38bb129803..1e1a78dfce 100644 --- a/src/libmongoc/src/mongoc/mongoc-error.c +++ b/src/libmongoc/src/mongoc/mongoc-error.c @@ -184,6 +184,7 @@ _mongoc_read_error_get_type (bool cmd_ret, } switch (error.code) { + case MONGOC_SERVER_ERR_EXCEEDEDTIMELIMIT: case MONGOC_SERVER_ERR_INTERRUPTEDATSHUTDOWN: case MONGOC_SERVER_ERR_INTERRUPTEDDUETOREPLSTATECHANGE: case MONGOC_SERVER_ERR_NOTPRIMARY: From 8f95ae74512a66dede14f45387fa97f0c78b1f92 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 28 Nov 2023 08:31:15 -0600 Subject: [PATCH 2/4] Add unified test that verifies ExceededTimeLimit is a retryable error --- .../unified/ExceededTimeLimit.json | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 src/libmongoc/tests/json/retryable_reads/unified/ExceededTimeLimit.json diff --git a/src/libmongoc/tests/json/retryable_reads/unified/ExceededTimeLimit.json b/src/libmongoc/tests/json/retryable_reads/unified/ExceededTimeLimit.json new file mode 100644 index 0000000000..4ac30c816a --- /dev/null +++ b/src/libmongoc/tests/json/retryable_reads/unified/ExceededTimeLimit.json @@ -0,0 +1,170 @@ +{ + "description": "ExceededTimeLimit is a retryable read", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "minServerVersion": "4.2", + "topologies": [ + "replicaset", + "sharded", + "load-balanced" + ], + "auth": true + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "find-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "find-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + }, + { + "_id": 5, + "x": 55 + }, + { + "_id": 6, + "x": 66 + } + ] + } + ], + "tests": [ + { + "description": "Find succeeds on second attempt after ExceededTimeLimit", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "find" + ], + "closeConnection": false, + "errorCode": 262 + } + } + } + }, + { + "name": "find", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "batchSize": 10 + }, + "object": "collection0", + "expectResult": [ + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + }, + { + "_id": 5, + "x": 55 + }, + { + "_id": 6, + "x": 66 + } + ] + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "coll0", + "filter": { + "_id": { + "$gt": 1 + } + }, + "batchSize": 10 + }, + "commandName": "find", + "databaseName": "find-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "find": "coll0", + "filter": { + "_id": { + "$gt": 1 + } + }, + "batchSize": 10 + }, + "commandName": "find", + "databaseName": "find-tests" + } + } + ] + } + ] + } + ] +} From 0a1a7e97218de4f53b6f17e36d7f7896cfa6fa20 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 28 Nov 2023 14:25:01 -0600 Subject: [PATCH 3/4] fix schema version, use 1.3 instead of 1.0 --- .../tests/json/retryable_reads/unified/ExceededTimeLimit.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libmongoc/tests/json/retryable_reads/unified/ExceededTimeLimit.json b/src/libmongoc/tests/json/retryable_reads/unified/ExceededTimeLimit.json index 4ac30c816a..dba29d53c5 100644 --- a/src/libmongoc/tests/json/retryable_reads/unified/ExceededTimeLimit.json +++ b/src/libmongoc/tests/json/retryable_reads/unified/ExceededTimeLimit.json @@ -1,6 +1,6 @@ { "description": "ExceededTimeLimit is a retryable read", - "schemaVersion": "1.0", + "schemaVersion": "1.3", "runOnRequirements": [ { "minServerVersion": "4.2", From 9982661b086ed2af868258530cb8df8e946d12c6 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 29 Nov 2023 14:46:58 -0600 Subject: [PATCH 4/4] implement suggestions from the spec PR --- .../unified/exceededTimeLimit.json | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 src/libmongoc/tests/json/retryable_reads/unified/exceededTimeLimit.json diff --git a/src/libmongoc/tests/json/retryable_reads/unified/exceededTimeLimit.json b/src/libmongoc/tests/json/retryable_reads/unified/exceededTimeLimit.json new file mode 100644 index 0000000000..8d090bbe3f --- /dev/null +++ b/src/libmongoc/tests/json/retryable_reads/unified/exceededTimeLimit.json @@ -0,0 +1,147 @@ +{ + "description": "ExceededTimeLimit 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": "exceededtimelimit-test" + } + } + ], + "initialData": [ + { + "collectionName": "exceededtimelimit-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 ExceededTimeLimit", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "find" + ], + "errorCode": 262 + } + } + } + }, + { + "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": "exceededtimelimit-test", + "filter": { + "_id": { + "$gt": 1 + } + } + }, + "commandName": "find", + "databaseName": "retryable-reads-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "find": "exceededtimelimit-test", + "filter": { + "_id": { + "$gt": 1 + } + } + }, + "commandName": "find", + "databaseName": "retryable-reads-tests" + } + } + ] + } + ] + } + ] +}