summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2015-12-14 19:50:43 -0500
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2015-12-17 14:23:25 -0500
commitf785174734fcf309c6be9cbc5f8a3ae591ce4dfd (patch)
tree87ba2af009d335b0b10d57e31445e43793e7d34d
parent285f6dea0758ae28274615ac2d155c4b43929579 (diff)
downloadmongo-f785174734fcf309c6be9cbc5f8a3ae591ce4dfd.tar.gz
SERVER-21868 Shutdown may not be handled correctly in oplog application.
(cherry picked from commit ac70c5eb4d987702535ad6c00ab980de5873cdf4)
-rw-r--r--src/mongo/db/repl/sync_tail.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index fa495eb46ac..2ae54b06eaa 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -523,9 +523,11 @@ OpTime SyncTail::multiApply(OperationContext* txn, const OpQueue& ops) {
raws.emplace_back(op.raw);
}
lastOpTime = writeOpsToOplog(txn, raws);
- if (inShutdown()) {
- return OpTime();
- }
+ }
+
+ if (inShutdownStrict()) {
+ log() << "Cannot apply operations due to shutdown in progress";
+ return OpTime();
}
// We have now written all database writes and updated the oplog to match.
return lastOpTime;
@@ -743,8 +745,16 @@ void SyncTail::oplogApplication() {
setMinValid(&txn, {start, end});
lastWriteOpTime = multiApply(&txn, ops);
- setNewTimestamp(lastWriteOpTime.getTimestamp());
+ if (lastWriteOpTime.isNull()) {
+ // fassert if oplog application failed for any reasons other than shutdown.
+ error() << "Failed to apply " << ops.getDeque().size()
+ << " operations - batch start:" << start << " end:" << end;
+ fassert(34360, inShutdownStrict());
+ // Return without setting minvalid in the case of shutdown.
+ return;
+ }
+ setNewTimestamp(lastWriteOpTime.getTimestamp());
setMinValid(&txn, end, DurableRequirement::None);
minValidBoundaries.start = {};
minValidBoundaries.end = end;