diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2018-03-30 15:25:47 -0400 |
---|---|---|
committer | Justin Seyster <justin.seyster@mongodb.com> | 2018-04-12 16:05:53 -0400 |
commit | bc19d43fdc4aab85264def96f638128c0ddb8483 (patch) | |
tree | 09b5a9a15982edd4998d4665d6c67f8fbd7c83e7 /src/mongo/client/embedded | |
parent | c6620182aebd1b62d31879ce4d9456ff197aea22 (diff) | |
download | mongo-bc19d43fdc4aab85264def96f638128c0ddb8483.tar.gz |
SERVER-27534 All writing operations must fail if the term changes.
The description of this SERVER ticket describes a nasty race that can
occur if elections happen inbetween two batches during a large
update. (The included test confirms that the race is possible.)
To fix this, we want to check the operation context for interrupts
with each batch, and we need to make sure the check happens _after_
the collection lock gets taken and before the batch
inserts/updates/deletes execute.
A recent change to locking gives us almost exactly this for free: if a
collection lock has to wait, it throws an exception when the operation
context is interrupted, ending the operation. If the lock doesn't
wait, though, there is no check.
This patch adds that check in. Acquiring a lock now always throws if
the operation context is interrupted, which closes the race window in
this bug.
Diffstat (limited to 'src/mongo/client/embedded')
-rw-r--r-- | src/mongo/client/embedded/embedded.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/mongo/client/embedded/embedded.cpp b/src/mongo/client/embedded/embedded.cpp index 328217bd157..7fc8b1a8e14 100644 --- a/src/mongo/client/embedded/embedded.cpp +++ b/src/mongo/client/embedded/embedded.cpp @@ -140,6 +140,7 @@ void shutdown(ServiceContext* srvContext) { // Close all open databases, shutdown storage engine and run all deinitializers. auto shutdownOpCtx = serviceContext->makeOperationContext(client); { + UninterruptibleLockGuard noInterrupt(shutdownOpCtx->lockState()); Lock::GlobalLock lk(shutdownOpCtx.get(), MODE_X, Date_t::max()); dbHolder().closeAll(shutdownOpCtx.get(), "shutdown"); |