PYTHON-4016 making ReadConcernMajorityNotAvailableYet a retryable error (#1467)

This commit is contained in:
Casey Clements 2024-01-11 08:55:53 -05:00 committed by GitHub
parent dcec415771
commit 7adda818a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 150 additions and 2 deletions

View File

@ -83,6 +83,7 @@ _RETRYABLE_ERROR_CODES: frozenset = _NOT_PRIMARY_CODES | frozenset(
89, # NetworkTimeout
9001, # SocketException
262, # ExceededTimeLimit
134, # ReadConcernMajorityNotAvailableYet
]
)

View File

@ -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"
}
}
]
}
]
}
]
}

View File

@ -15,8 +15,8 @@
"""Test the Retryable Reads unified spec tests."""
from __future__ import annotations
import os
import sys
from pathlib import Path
sys.path[0:0] = [""]
@ -24,7 +24,7 @@ from test import unittest
from test.unified_format import generate_test_classes
# Location of JSON test specifications.
TEST_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "retryable_reads", "unified")
TEST_PATH = Path(__file__).parent / "retryable_reads/unified"
# Generate unified tests.
globals().update(generate_test_classes(TEST_PATH, module=__name__))