Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-3030 Retry ReadConcernMajorityNotAvailableYet errors. #1893

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/integration/unified/unified_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
"command-monitoring/logging",
"connection-monitoring-and-pooling/logging",
"sessions",
"retryable-reads/unified",
"retryable-writes/unified",
"client-side-encryption/unified",
"client-side-operations-timeout",
Expand Down
2 changes: 1 addition & 1 deletion internal/integration/unified_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const dataPath string = "../../testdata/"
var directories = []string{
"transactions/legacy",
"convenient-transactions",
"retryable-reads",
"retryable-reads/legacy",
"read-write-concern/operation",
"server-discovery-and-monitoring/integration",
"atlas-data-lake-testing",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -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
17 changes: 16 additions & 1 deletion x/mongo/driver/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,22 @@ import (
const LegacyNotPrimaryErrMsg = "not master"

var (
retryableCodes = []int32{11600, 11602, 10107, 13435, 13436, 189, 91, 7, 6, 89, 9001, 262}
retryableCodes = []int32{
6, // HostUnreachable
7, // HostNotFound
89, // NetworkTimeout
91, // ShutdownInProgress
134, // ReadConcernMajorityNotAvailableYet
189, // PrimarySteppedDown
262, // ExceededTimeLimit
9001, // SocketException
10107, // NotWritablePrimary
11600, // InterruptedAtShutdown
11602, // InterruptedDueToReplStateChange
13435, // NotPrimaryNoSecondaryOk
13436, // NotPrimaryOrSecondary
}

nodeIsRecoveringCodes = []int32{11600, 11602, 13436, 189, 91}
notPrimaryCodes = []int32{10107, 13435, 10058}
nodeIsShuttingDownCodes = []int32{11600, 91}
Expand Down
Loading