diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-03-10 15:45:42 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-03-10 17:13:48 -0500 |
commit | 335e647e165950a080cb2a5effdab64abd898be0 (patch) | |
tree | b60a7c7753755296140d9c702abda7e9a49451d2 | |
parent | 7676d097f1dde12c0a7ca9faa9f3e2f8e11a4b76 (diff) | |
download | mongo-335e647e165950a080cb2a5effdab64abd898be0.tar.gz |
SERVER-23068 Remove test usages of PrepareConfigsFailed
With the removal of SCCC (mirrored) config servers, this error will never
be returned so there is no need to test for it.
-rw-r--r-- | jstests/sharding/migration_failure.js | 23 | ||||
-rw-r--r-- | src/mongo/db/s/migration_impl.cpp | 45 |
2 files changed, 9 insertions, 59 deletions
diff --git a/jstests/sharding/migration_failure.js b/jstests/sharding/migration_failure.js index 97ab7ddf967..4ae6c880b84 100644 --- a/jstests/sharding/migration_failure.js +++ b/jstests/sharding/migration_failure.js @@ -2,9 +2,10 @@ // Tests that migration failures before and after commit correctly roll back // when possible // +(function() { +'use strict'; var st = new ShardingTest({shards: 2, mongos: 1}); -st.stopBalancer(); var mongos = st.s0; var admin = mongos.getDB("admin"); @@ -23,6 +24,7 @@ jsTest.log("Testing failed migrations..."); var version = null; var failVersion = null; +// failMigrationCommit assert.commandWorked(st.shard0.getDB("admin").runCommand( {configureFailPoint: 'failMigrationCommit', mode: 'alwaysOn'})); @@ -35,20 +37,7 @@ failVersion = st.shard0.getDB("admin").runCommand({getShardVersion: coll.toStrin assert.commandWorked(st.shard0.getDB("admin") .runCommand({configureFailPoint: 'failMigrationCommit', mode: 'off'})); -assert.commandWorked(st.shard0.getDB("admin").runCommand( - {configureFailPoint: 'failMigrationConfigWritePrepare', mode: 'alwaysOn'})); - -version = st.shard0.getDB("admin").runCommand({getShardVersion: coll.toString()}); - -assert.commandFailed(admin.runCommand({moveChunk: coll + "", find: {_id: 0}, to: shards[1]._id})); - -failVersion = st.shard0.getDB("admin").runCommand({getShardVersion: coll.toString()}); - -assert.eq(version.global, failVersion.global); - -assert.commandWorked(st.shard0.getDB("admin").runCommand( - {configureFailPoint: 'failMigrationConfigWritePrepare', mode: 'off'})); - +// failApplyChunkOps assert.commandWorked(st.shard0.getDB("admin") .runCommand({configureFailPoint: 'failApplyChunkOps', mode: 'alwaysOn'})); @@ -63,6 +52,6 @@ assert.neq(version.global, failVersion.global); assert.commandWorked(st.shard0.getDB("admin") .runCommand({configureFailPoint: 'failApplyChunkOps', mode: 'off'})); -jsTest.log("DONE!"); - st.stop(); + +})(); diff --git a/src/mongo/db/s/migration_impl.cpp b/src/mongo/db/s/migration_impl.cpp index 3a307e0c2be..873fc6c6f5c 100644 --- a/src/mongo/db/s/migration_impl.cpp +++ b/src/mongo/db/s/migration_impl.cpp @@ -70,7 +70,6 @@ BSONObj createRecvChunkCommitRequest(const MigrationSessionId& sessionId) { MONGO_FP_DECLARE(failMigrationCommit); MONGO_FP_DECLARE(hangBeforeLeavingCriticalSection); -MONGO_FP_DECLARE(failMigrationConfigWritePrepare); } // namespace @@ -386,47 +385,9 @@ Status ChunkMoveOperationState::commitMigration(const MigrationSessionId& sessio preCond.append(b.obj()); } - Status applyOpsStatus{Status::OK()}; - try { - // For testing migration failures - if (MONGO_FAIL_POINT(failMigrationConfigWritePrepare)) { - throw DBException("mock migration failure before config write", - ErrorCodes::PrepareConfigsFailed); - } - - applyOpsStatus = grid.catalogManager(_txn)->applyChunkOpsDeprecated( - _txn, updates.arr(), preCond.arr(), _nss.ns(), nextVersion); - - } catch (const DBException& ex) { - applyOpsStatus = ex.toStatus(); - } - - if (applyOpsStatus == ErrorCodes::PrepareConfigsFailed) { - // In the process of issuing the migrate commit, the SyncClusterConnection checks that - // the config servers are reachable. If they are not, we are sure that the applyOps - // command was not sent to any of the configs, so we can safely back out of the - // migration here, by resetting the shard version that we bumped up to in the - // donateChunk() call above. - log() << "About to acquire moveChunk coll lock to reset shard version from " - << "failed migration"; - - { - ScopedTransaction transaction(_txn, MODE_IX); - Lock::DBLock dbLock(_txn->lockState(), _nss.db(), MODE_IX); - Lock::CollectionLock collLock(_txn->lockState(), _nss.ns(), MODE_X); - - // Revert the metadata back to the state before "forgetting" about the chunk - shardingState->undoDonateChunk(_txn, _nss.ns(), getCollMetadata()); - } - - log() << "Shard version successfully reset to clean up failed migration"; - - const string msg = stream() << "Failed to send migrate commit to configs " - << causedBy(applyOpsStatus); - return Status(applyOpsStatus.code(), msg); - } else if (!applyOpsStatus.isOK()) { - fassertStatusOK(34431, applyOpsStatus); - } + fassertStatusOK(34431, + grid.catalogManager(_txn)->applyChunkOpsDeprecated( + _txn, updates.arr(), preCond.arr(), _nss.ns(), nextVersion)); MONGO_FAIL_POINT_PAUSE_WHILE_SET(hangBeforeLeavingCriticalSection); |