Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
read for review
  • Loading branch information
aditi-khare-mongoDB committed Jun 17, 2024
commit d3d4df0cfb9537c78e58486e385a1b82ba72a608
6 changes: 4 additions & 2 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export const MONGODB_ERROR_CODES = Object.freeze({
MaxTimeMSExpired: 50,
UnknownReplWriteConcern: 79,
UnsatisfiableWriteConcern: 100,
Reauthenticate: 391
Reauthenticate: 391,
ReadConcernMajorityNotAvailableYet: 134
} as const);

// From spec@https://github.com/mongodb/specifications/blob/f93d78191f3db2898a59013a7ed5650352ef6da8/source/change-streams/change-streams.rst#resumable-error
Expand Down Expand Up @@ -1221,7 +1222,8 @@ const RETRYABLE_READ_ERROR_CODES = new Set<number>([
MONGODB_ERROR_CODES.InterruptedDueToReplStateChange,
MONGODB_ERROR_CODES.NotPrimaryNoSecondaryOk,
MONGODB_ERROR_CODES.NotPrimaryOrSecondary,
MONGODB_ERROR_CODES.ExceededTimeLimit
MONGODB_ERROR_CODES.ExceededTimeLimit,
MONGODB_ERROR_CODES.ReadConcernMajorityNotAvailableYet
]);

// see: https://github.com/mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.rst#terms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { loadSpecTests } from '../../spec';
import { generateTopologyTests, TestRunnerContext } from '../../tools/spec-runner';
import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';

describe('Retryable Reads (legacy)', function () {
describe.only('Retryable Reads (legacy)', function () {
const testContext = new TestRunnerContext();
const testSuites = loadSpecTests(path.join('retryable-reads', 'legacy'));

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