summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergi Mateo Bellido <sergi.mateo-bellido@mongodb.com>2020-11-16 13:02:43 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-17 13:08:55 +0000
commit9b0e366a75a9cc25705969932b3374d21d4d13c9 (patch)
treec9e7a4686e177cbdf5ea1a07882bdace722e5f20
parent44378647c03277ad1c0a4c389292360aa39b2bb9 (diff)
downloadmongo-9b0e366a75a9cc25705969932b3374d21d4d13c9.tar.gz
SERVER-51834 Race in moveChunk tests
-rw-r--r--src/mongo/db/s/move_chunk_command.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mongo/db/s/move_chunk_command.cpp b/src/mongo/db/s/move_chunk_command.cpp
index e1e7ef7248d..8ee27e56362 100644
--- a/src/mongo/db/s/move_chunk_command.cpp
+++ b/src/mongo/db/s/move_chunk_command.cpp
@@ -85,7 +85,6 @@ MONGO_FAIL_POINT_DEFINE(moveChunkHangAtStep3);
MONGO_FAIL_POINT_DEFINE(moveChunkHangAtStep4);
MONGO_FAIL_POINT_DEFINE(moveChunkHangAtStep5);
MONGO_FAIL_POINT_DEFINE(moveChunkHangAtStep6);
-MONGO_FAIL_POINT_DEFINE(moveChunkHangAtStep7);
class MoveChunkCommand : public BasicCommand {
public:
@@ -145,6 +144,11 @@ public:
.then([moveChunkRequest,
scopedMigration = std::move(scopedMigration),
serviceContext = opCtx->getServiceContext()]() mutable {
+ // This local variable is created to enforce that the scopedMigration is
+ // destroyed before setting the shared state as ready.
+ // Note that captured objects of the lambda are destroyed by the executor
+ // thread after setting the shared state as ready.
+ auto scopedMigrationLocal(std::move(scopedMigration));
ThreadClient tc("MoveChunk", serviceContext);
{
stdx::lock_guard<Client> lk(*tc.get());
@@ -168,7 +172,7 @@ public:
.countDonorMoveChunkLockTimeout.addAndFetch(1);
}
} catch (const std::exception& e) {
- scopedMigration.signalComplete(
+ scopedMigrationLocal.signalComplete(
{ErrorCodes::InternalError,
str::stream()
<< "Severe error occurred while running moveChunk command: "
@@ -176,7 +180,7 @@ public:
throw;
}
- scopedMigration.signalComplete(status);
+ scopedMigrationLocal.signalComplete(status);
uassertStatusOK(status);
});
moveChunkComplete.get(opCtx);