summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVesselina Ratcheva <vesselina.ratcheva@10gen.com>2018-07-31 21:46:46 -0400
committerVesselina Ratcheva <vesselina.ratcheva@10gen.com>2018-08-06 22:49:48 -0400
commitdff731c8d516a3d4fd57b411ba0600ba51b5b800 (patch)
tree99f56a9cb46efe7fea5c645368b89535dbacb668
parent78baf889e4fc760184fe66c100fcc44ec9763005 (diff)
downloadmongo-dff731c8d516a3d4fd57b411ba0600ba51b5b800.tar.gz
SERVER-35766 Prevent stepdowns from interrupting database commands
(cherry picked from commit 0a8dcd7e6bb85b91eca0d06cd987f8c76cbebd0b)
-rw-r--r--src/mongo/db/service_entry_point_mongod.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp
index 8886bfb018f..6e5e7731422 100644
--- a/src/mongo/db/service_entry_point_mongod.cpp
+++ b/src/mongo/db/service_entry_point_mongod.cpp
@@ -733,8 +733,16 @@ void execCommandDatabase(OperationContext* opCtx,
oss.setAllowImplicitCollectionCreation(allowImplicitCollectionCreationField);
- // Can throw
- opCtx->checkForInterrupt(); // May trigger maxTimeAlwaysTimeOut fail point.
+ // This may trigger the maxTimeAlwaysTimeOut failpoint.
+ auto status = opCtx->checkForInterruptNoAssert();
+
+ // We still proceed if the primary stepped down, but accept other kinds of interruptions.
+ // We defer to individual commands to allow themselves to be interruptible by stepdowns,
+ // since commands like 'voteRequest' should conversely continue executing.
+ if (status != ErrorCodes::PrimarySteppedDown &&
+ status != ErrorCodes::InterruptedDueToReplStateChange) {
+ uassertStatusOK(status);
+ }
bool retval = false;