0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-21 12:39:08 +01:00

SERVER-89913 Add retries on retryable errors (#21610)

GitOrigin-RevId: 129bf89166920596d76c565894eb8e00f295ea20
This commit is contained in:
Abdul Qadeer 2024-04-30 17:45:51 +03:00 committed by MongoDB Bot
parent 7aefcc0039
commit d01cc077cd
2 changed files with 5 additions and 6 deletions

View File

@ -237,3 +237,4 @@ globals:
helloStatePrompt: true
_validateMemberIndex: true
help: true
retryOnRetryableError: true

View File

@ -42,18 +42,16 @@ assert.commandWorked(db.runCommand(updateCmd));
assert.commandWorked(coll.insertOne({x: -50}));
// Failover shard0 to cause it to forget the in memory txn state from being a txn participant.
const secondary = st.rs0.getSecondary();
ShardingStateTest.failoverToMember(st.rs0, secondary);
// Await until RS connection in shell is updated.
_awaitRSHostViaRSMonitor(secondary.name, {ok: true, ismaster: true}, st.rs0.name);
ShardingStateTest.failoverToMember(st.rs0, st.rs0.getSecondary());
// Retry the earlier retryable upsert.
db = st.s.getDB(jsTestName());
coll = db.coll;
// Insert a document matching the update query.
coll.insertOne({x: -50});
// Add retries on retryable error as the connections in ShardingTest may be stale and can fail with
// NotWritablePrimary
retryOnRetryableError(() => coll.insertOne({x: -50}), 10, 30);
// A retry of the update should fail.
assert.commandFailedWithCode(db.runCommand(updateCmd), ErrorCodes.IncompleteTransactionHistory);