Skip to content

Commit ac70c5e

Browse files
committed
SERVER-21868 Shutdown may not be handled correctly in oplog application.
1 parent 402c10f commit ac70c5e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/mongo/db/repl/sync_tail.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,11 @@ OpTime SyncTail::multiApply(OperationContext* txn, const OpQueue& ops) {
523523
raws.emplace_back(op.raw);
524524
}
525525
lastOpTime = writeOpsToOplog(txn, raws);
526-
if (inShutdown()) {
527-
return OpTime();
528-
}
526+
}
527+
528+
if (inShutdownStrict()) {
529+
log() << "Cannot apply operations due to shutdown in progress";
530+
return OpTime();
529531
}
530532
// We have now written all database writes and updated the oplog to match.
531533
return lastOpTime;
@@ -743,8 +745,16 @@ void SyncTail::oplogApplication() {
743745
setMinValid(&txn, {start, end});
744746

745747
lastWriteOpTime = multiApply(&txn, ops);
746-
setNewTimestamp(lastWriteOpTime.getTimestamp());
748+
if (lastWriteOpTime.isNull()) {
749+
// fassert if oplog application failed for any reasons other than shutdown.
750+
error() << "Failed to apply " << ops.getDeque().size()
751+
<< " operations - batch start:" << start << " end:" << end;
752+
fassert(34360, inShutdownStrict());
753+
// Return without setting minvalid in the case of shutdown.
754+
return;
755+
}
747756

757+
setNewTimestamp(lastWriteOpTime.getTimestamp());
748758
setMinValid(&txn, end, DurableRequirement::None);
749759
minValidBoundaries.start = {};
750760
minValidBoundaries.end = end;

0 commit comments

Comments
 (0)