SERVER-107767 Router should retry CreateIndexes on retriable errors (#38747)
GitOrigin-RevId: 1e3da12ceb8f0f2c01396d2d37d72655f8e918ad
This commit is contained in:
parent
76f1fb6f34
commit
97867d5d20
@ -62,8 +62,7 @@ export const $config = (function() {
|
||||
* Checks that the createIndex cmd result either succeeded or failed in an acceptible manner.
|
||||
*/
|
||||
function processCreateIndex(createIndexRes, indexSpec) {
|
||||
assert(createIndexRes.ok == 1 || createIndexRes.code == ErrorCodes.IndexAlreadyExists ||
|
||||
createIndexRes.code == ErrorCodes.IndexBuildAborted ||
|
||||
assert(createIndexRes.ok == 1 || createIndexRes.code == ErrorCodes.IndexBuildAborted ||
|
||||
createIndexRes.code == ErrorCodes.NoMatchingDocument,
|
||||
"Create index for spec '" + indexSpec + "'failed: " + tojson(createIndexRes));
|
||||
}
|
||||
|
||||
@ -140,8 +140,7 @@ function isAcceptableRetryFailedResponse(cmdName, res) {
|
||||
// These codes are uniquely returned from user_management_commands.cpp
|
||||
const kErrorCodeRoleAlreadyExists = 51002;
|
||||
const kErrorCodeUserAlreadyExists = 51003;
|
||||
return ((cmdName === "createIndexes" && res.code === ErrorCodes.IndexAlreadyExists) ||
|
||||
(cmdName === "drop" && res.code === ErrorCodes.NamespaceNotFound) ||
|
||||
return ((cmdName === "drop" && res.code === ErrorCodes.NamespaceNotFound) ||
|
||||
((cmdName == "createUser") && (res.code === kErrorCodeUserAlreadyExists)) ||
|
||||
((cmdName == "createRole") && (res.code === kErrorCodeRoleAlreadyExists)) ||
|
||||
((cmdName === "dropIndexes" || cmdName === "deleteIndexes") &&
|
||||
|
||||
@ -942,23 +942,6 @@ const retryOnNetworkErrorTests = [
|
||||
assert.commandFailed(coll1.createIndex({x: 1}));
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "raw response w/ only acceptable errors",
|
||||
test: function() {
|
||||
setCommandMockResponse("createIndexes", {
|
||||
ok: 0,
|
||||
code: ErrorCodes.IndexAlreadyExists,
|
||||
raw: {
|
||||
shardOne: {code: ErrorCodes.IndexAlreadyExists, errmsg: "dummy"},
|
||||
shardTwo: {ok: 1},
|
||||
shardThree: {code: ErrorCodes.IndexAlreadyExists, errmsg: "dummy"}
|
||||
}
|
||||
});
|
||||
|
||||
assert.commandWorked(testDB.createCollection(collName1));
|
||||
assert.commandWorked(coll1.createIndex({x: 1}));
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "raw response w/ acceptable error and non-acceptable, non-retryable error",
|
||||
test: function() {
|
||||
|
||||
@ -157,7 +157,7 @@ public:
|
||||
CommandHelpers::filterCommandRequestForPassthrough(
|
||||
applyReadWriteConcern(opCtx, this, cmdToBeSent)),
|
||||
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
|
||||
Shard::RetryPolicy::kNoRetry,
|
||||
Shard::RetryPolicy::kIdempotent,
|
||||
BSONObj() /*query*/,
|
||||
BSONObj() /*collation*/,
|
||||
boost::none /*letParameters*/,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user