summaryrefslogtreecommitdiff
path: root/jstests/replsets/txn_override_unittests.js
diff options
context:
space:
mode:
authorPavi Vetriselvan <pavithra.vetriselvan@mongodb.com>2020-08-24 12:25:14 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-30 14:31:38 +0000
commitcf080113fe8951ebb5a4795ad70494cbf5439493 (patch)
treefe2b0c717ad492ec844aba52ae126a51b13688b2 /jstests/replsets/txn_override_unittests.js
parent022d093fdba4f4b617c80048971ba6b3a6ad386a (diff)
downloadmongo-cf080113fe8951ebb5a4795ad70494cbf5439493.tar.gz
SERVER-50408 Change NotMaster error name to NotWritablePrimary
(cherry picked from commit 783e113bbb1bfa83630222de5b74fe95530692f0) (cherry picked from commit 91b24be9ce86be1001f3845393edcca72186ea79)
Diffstat (limited to 'jstests/replsets/txn_override_unittests.js')
-rw-r--r--jstests/replsets/txn_override_unittests.js202
1 files changed, 112 insertions, 90 deletions
diff --git a/jstests/replsets/txn_override_unittests.js b/jstests/replsets/txn_override_unittests.js
index f508afe2a99..b790af16cd1 100644
--- a/jstests/replsets/txn_override_unittests.js
+++ b/jstests/replsets/txn_override_unittests.js
@@ -339,28 +339,28 @@ const retryOnNetworkErrorTests = [
}
},
{
- name: "retry on NotMaster",
+ name: "retry on NotWritablePrimary",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
}
},
{
- name: "retry on NotMaster ordered",
+ name: "retry on NotWritablePrimary ordered",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandFailed(
testDB.runCommand({insert: collName1, documents: [{_id: 2}], ordered: true}));
}
},
{
- name: "retry on NotMaster with object change",
+ name: "retry on NotWritablePrimary with object change",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
let obj1 = {_id: 1, x: 5};
let obj2 = {_id: 2, x: 5};
assert.commandWorked(coll1.insert(obj1));
@@ -375,7 +375,7 @@ const retryOnNetworkErrorTests = [
name: "implicit collection creation with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -386,9 +386,10 @@ const retryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(
- ["insert"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["insert"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -399,8 +400,11 @@ const retryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError and normal stepdown error",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithErrorAndWCENoRun(
- "insert", ErrorCodes.NotMaster, "NotMaster", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithErrorAndWCENoRun("insert",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -413,8 +417,8 @@ const retryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("insert",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -443,7 +447,7 @@ const retryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError no success",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithWCENoRun("insert", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun("insert", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -454,7 +458,7 @@ const retryOnNetworkErrorTests = [
name: "update with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -487,7 +491,7 @@ const retryOnNetworkErrorTests = [
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
failCommandWithFailPoint(["update"],
- {errorCode: ErrorCodes.NotMaster, mode: {times: 2}});
+ {errorCode: ErrorCodes.NotWritablePrimary, mode: {times: 2}});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -500,10 +504,10 @@ const retryOnNetworkErrorTests = [
name: "update with chained stepdown errors",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
// Chain multiple update errors together.
attachPostCmdFunction("update", function() {
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
@@ -533,7 +537,7 @@ const retryOnNetworkErrorTests = [
const session = testDB.getSession();
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
@@ -541,7 +545,7 @@ const retryOnNetworkErrorTests = [
session.startTransaction();
assert.commandFailedWithCode(
testDB.runCommand({update: collName1, updates: [{q: {_id: 1}, u: {$inc: {x: 1}}}]}),
- ErrorCodes.NotMaster);
+ ErrorCodes.NotWritablePrimary);
assert.commandFailedWithCode(session.abortTransaction_forTesting(),
ErrorCodes.NoSuchTransaction);
@@ -577,7 +581,8 @@ const retryOnNetworkErrorTests = [
const session = testDB.getSession();
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["commitTransaction"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["commitTransaction"],
+ {errorCode: ErrorCodes.NotWritablePrimary});
session.startTransaction();
assert.commandWorked(coll1.insert({_id: 1}));
@@ -658,7 +663,8 @@ const retryOnNetworkErrorTests = [
const session = testDB.getSession();
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["abortTransaction"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["abortTransaction"],
+ {errorCode: ErrorCodes.NotWritablePrimary});
session.startTransaction();
assert.commandWorked(coll1.insert({_id: 1}));
@@ -743,7 +749,7 @@ const retryOnNetworkErrorTests = [
setCommandMockResponse("createIndexes", {
ok: 0,
raw: {
- shardOne: {code: ErrorCodes.NotMaster, errmsg: "dummy"},
+ shardOne: {code: ErrorCodes.NotWritablePrimary, errmsg: "dummy"},
shardTwo: {code: ErrorCodes.InternalError, errmsg: "dummy"}
}
});
@@ -767,7 +773,7 @@ const retryOnNetworkErrorTests = [
raw: {
// Raw responses only omit a top-level code if more than one error was
// returned from a shard, so a third shard is needed.
- shardOne: {code: ErrorCodes.NotMaster, errmsg: "dummy"},
+ shardOne: {code: ErrorCodes.NotWritablePrimary, errmsg: "dummy"},
shardTwo: {ok: 1},
shardThree: {code: ErrorCodes.InternalError, errmsg: "dummy"},
}
@@ -1063,7 +1069,7 @@ const txnOverrideTests = [
name: "update with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -1112,7 +1118,7 @@ const txnOverrideTests = [
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
failCommandWithFailPoint(["update"],
- {errorCode: ErrorCodes.NotMaster, mode: {times: 2}});
+ {errorCode: ErrorCodes.NotWritablePrimary, mode: {times: 2}});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -1128,10 +1134,10 @@ const txnOverrideTests = [
name: "update with chained stepdown errors",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
// Chain multiple update errors together.
attachPostCmdFunction("update", function() {
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
@@ -1147,24 +1153,28 @@ const txnOverrideTests = [
{
name: "implicit collection creation with stepdown",
test: function() {
- failCommandWithFailPoint(["create"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["create"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.throws(() => coll1.insert({_id: 1}));
}
},
{
name: "implicit collection creation with WriteConcernError",
test: function() {
- failCommandWithFailPoint(
- ["create"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["create"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
assert.throws(() => coll1.insert({_id: 1}));
}
},
{
name: "implicit collection creation with WriteConcernError and normal stepdown error",
test: function() {
- failCommandWithErrorAndWCENoRun(
- "create", ErrorCodes.NotMaster, "NotMaster", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithErrorAndWCENoRun("create",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.throws(() => coll1.insert({_id: 1}));
}
},
@@ -1174,8 +1184,8 @@ const txnOverrideTests = [
failCommandWithErrorAndWCENoRun("create",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.throws(() => coll1.insert({_id: 1}));
}
},
@@ -1196,7 +1206,7 @@ const txnOverrideTests = [
{
name: "implicit collection creation with WriteConcernError no success",
test: function() {
- failCommandWithWCENoRun("create", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun("create", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.throws(() => coll1.insert({_id: 1}));
}
},
@@ -1224,7 +1234,8 @@ const txnOverrideTests = [
name: "commit transaction with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["commitTransaction"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["commitTransaction"],
+ {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1234,9 +1245,10 @@ const txnOverrideTests = [
name: "commit transaction with WriteConcernError",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(
- ["commitTransaction"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["commitTransaction"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1247,10 +1259,10 @@ const txnOverrideTests = [
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
failCommandWithErrorAndWCENoRun("commitTransaction",
- ErrorCodes.NotMaster,
- "NotMaster",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1263,8 +1275,8 @@ const txnOverrideTests = [
failCommandWithErrorAndWCENoRun("commitTransaction",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1288,8 +1300,8 @@ const txnOverrideTests = [
failCommandWithErrorAndWCENoRun("commitTransaction",
ErrorCodes.NoSuchTransaction,
"NoSuchTransaction",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1322,7 +1334,8 @@ const txnOverrideTests = [
name: "commit transaction with WriteConcernError no success",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithWCENoRun("commitTransaction", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun(
+ "commitTransaction", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1386,10 +1399,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("drop",
ErrorCodes.NamespaceNotFound,
"NamespaceNotFound",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
coll1.drop();
- failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({a: 2, b: {c: 7, d: "d is good"}}));
const cursor = coll1.find({
@@ -1421,10 +1434,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
}
},
{
- name: "retry on NotMaster",
+ name: "retry on NotWritablePrimary",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1433,10 +1446,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
}
},
{
- name: "retry on NotMaster with object change",
+ name: "retry on NotWritablePrimary with object change",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
let obj1 = {_id: 1, x: 5};
let obj2 = {_id: 2, x: 5};
assert.commandWorked(coll1.insert(obj1));
@@ -1454,7 +1467,7 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "implicit collection creation with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["create"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["create"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1469,9 +1482,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(
- ["create"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["create"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1486,8 +1500,11 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError and normal stepdown error",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithErrorAndWCENoRun(
- "create", ErrorCodes.NotMaster, "NotMaster", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithErrorAndWCENoRun("create",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1504,8 +1521,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("create",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.throws(() => coll1.insert({_id: 1}));
}
},
@@ -1535,7 +1552,7 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError no success",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithWCENoRun("create", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun("create", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1550,7 +1567,7 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "update with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -1603,7 +1620,7 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
failCommandWithFailPoint(["update"],
- {errorCode: ErrorCodes.NotMaster, mode: {times: 2}});
+ {errorCode: ErrorCodes.NotWritablePrimary, mode: {times: 2}});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -1619,10 +1636,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "update with chained stepdown errors",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
// Chain multiple update errors together.
attachPostCmdFunction("update", function() {
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
@@ -1639,7 +1656,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "commit transaction with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["commitTransaction"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["commitTransaction"],
+ {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1654,9 +1672,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "commit transaction with WriteConcernError",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(
- ["commitTransaction"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["commitTransaction"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1672,10 +1691,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
failCommandWithErrorAndWCENoRun("commitTransaction",
- ErrorCodes.NotMaster,
- "NotMaster",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1693,8 +1712,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("commitTransaction",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1711,8 +1730,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("commitTransaction",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
// After commitTransaction fails, fail it again with just the ordinary error.
attachPostCmdFunction("commitTransaction", function() {
failCommandWithFailPoint(["commitTransaction"],
@@ -1745,8 +1764,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("commitTransaction",
ErrorCodes.NoSuchTransaction,
"NoSuchTransaction",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1791,7 +1810,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "commit transaction with WriteConcernError no success",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithWCENoRun("commitTransaction", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun(
+ "commitTransaction", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1806,9 +1826,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "commitTransaction fails with SERVER-38856",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(
- ["create"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["create"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
// After commitTransaction fails, abort the transaction and drop the collection
// as if the transaction were being retried on a different node.
@@ -1817,7 +1838,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
assert.commandWorked(mongoRunCommandOriginal.apply(testDB.getMongo(),
[dbName, {drop: collName2}, 0]));
});
- failCommandWithWCENoRun("commitTransaction", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun(
+ "commitTransaction", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1, x: 2}));
assert.commandWorked(coll2.insert({_id: 2}));
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 4}}));