diff options
author | Marcos José Grillo Ramirez <marcos.grillo@mongodb.com> | 2021-02-22 18:06:16 +0100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-22 18:42:37 +0000 |
commit | 74925af232e58b0e89bb1f5db654668c59714f79 (patch) | |
tree | 4ef445aa7f0e832da3ced516338e39eaa54d3660 /jstests | |
parent | 2b2e7980f099068f47fc7a651a6edd99c6e1abb3 (diff) | |
download | mongo-74925af232e58b0e89bb1f5db654668c59714f79.tar.gz |
SERVER-54345 Remove shard collection leftover data
... of previous failed executions using uuid and wait for majority write concern after index creation on the shard collection legacy path
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/libs/override_methods/mongos_manual_intervention_actions.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/jstests/libs/override_methods/mongos_manual_intervention_actions.js b/jstests/libs/override_methods/mongos_manual_intervention_actions.js index b30de265f24..9e835ad38c3 100644 --- a/jstests/libs/override_methods/mongos_manual_intervention_actions.js +++ b/jstests/libs/override_methods/mongos_manual_intervention_actions.js @@ -13,34 +13,36 @@ var ManualInterventionActions = (function() { * Remove all the chunk documents from the given namespace. Deletes are performed one at a * time to bypass auto_retry_on_network_error.js multi remove check. */ - let removeChunks = function(mongosConn, ns) { + let removeChunks = function(mongosConn, ns, res) { let stillHasChunks = true; + let uuid = res.errmsg.split('uuid: ')[1]; + let query = uuid ? {uuid: UUID(uuid)} : {ns: ns}; while (stillHasChunks) { let writeRes = assert.commandWorked(mongosConn.getDB('config').chunks.remove( - {ns: ns}, {justOne: true, writeConcern: {w: 'majority'}})); + query, {justOne: true, writeConcern: {w: 'majority'}})); stillHasChunks = writeRes.nRemoved > 0; } }; - this.removePartiallyWrittenChunks = function(mongosConn, ns, cmdObj, numAttempts) { + this.removePartiallyWrittenChunks = function(mongosConn, ns, cmdObj, numAttempts, res) { print("command " + tojson(cmdObj) + " failed after " + numAttempts + " attempts due to seeing partially written chunks for collection " + ns + ", probably due to a previous failed shardCollection attempt. Manually" + " deleting chunks for " + ns + " from config.chunks and retrying the command."); - removeChunks(mongosConn, ns); + removeChunks(mongosConn, ns, res); }; this.removePartiallyWrittenChunksAndDropCollection = function( - mongosConn, ns, cmdObj, numAttempts) { + mongosConn, ns, cmdObj, numAttempts, res) { print("command " + tojson(cmdObj) + " failed after " + numAttempts + " attempts due to seeing partially written chunks for collection " + ns + ", probably due to a previous failed shardCollection attempt. Manually" + " deleting chunks for " + ns + " from config.chunks" + ", dropping the collection, and retrying the command."); - removeChunks(mongosConn, ns); + removeChunks(mongosConn, ns, res); const [dbName, collName] = ns.split("."); assert.commandWorked( mongosConn.getDB(dbName).runCommand({"drop": collName, writeConcern: {w: "majority"}})); @@ -80,7 +82,8 @@ Mongo.prototype.runCommand = function runCommand(dbName, cmdObj, options) { if (cmdName === "shardCollection" || cmdName === "shardcollection") { const ns = cmdObj[cmdName]; - ManualInterventionActions.removePartiallyWrittenChunks(this, ns, cmdObj, numAttempts); + ManualInterventionActions.removePartiallyWrittenChunks( + this, ns, cmdObj, numAttempts, res); } else if (cmdName === "mapReduce" || cmdName === "mapreduce") { const out = cmdObj.out; @@ -105,7 +108,7 @@ Mongo.prototype.runCommand = function runCommand(dbName, cmdObj, options) { const ns = outDbName + "." + outCollName; ManualInterventionActions.removePartiallyWrittenChunksAndDropCollection( - this, ns, cmdObj, numAttempts); + this, ns, cmdObj, numAttempts, res); } } return res; |