summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2018-06-05 16:44:52 -0400
committerBenety Goh <benety@mongodb.com>2018-06-07 09:37:43 -0400
commitdc357342405345ff53f4f60358f61fd3e2f718dd (patch)
treea4a863b0d33975ff58071e4644a5dbbd2cc0b121
parent33501a519cd737e2981bc3fd7cd03d5325f8edfa (diff)
downloadmongo-dc357342405345ff53f4f60358f61fd3e2f718dd.tar.gz
SERVER-32935 log exception during oplog application
This change uses the terminate handler to log unexpected exceptions thrown inside SyncTail::oplogApplication(). (cherry picked from commit 09ea5600193cee30260c4d0a114f6464b870ab84)
-rw-r--r--src/mongo/db/repl/sync_tail.cpp8
-rw-r--r--src/mongo/db/repl/sync_tail.h4
-rw-r--r--src/mongo/db/repl/sync_tail_test.cpp2
3 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index cc6343dd665..6565834f021 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -848,6 +848,12 @@ void SyncTail::oplogApplication(OplogBuffer* oplogBuffer, ReplicationCoordinator
OpQueueBatcher batcher(this, _storageInterface, oplogBuffer);
+ _oplogApplication(oplogBuffer, replCoord, &batcher);
+}
+
+void SyncTail::_oplogApplication(OplogBuffer* oplogBuffer,
+ ReplicationCoordinator* replCoord,
+ OpQueueBatcher* batcher) noexcept {
std::unique_ptr<ApplyBatchFinalizer> finalizer{
getGlobalServiceContext()->getStorageEngine()->isDurable()
? new ApplyBatchFinalizerForJournal(replCoord)
@@ -886,7 +892,7 @@ void SyncTail::oplogApplication(OplogBuffer* oplogBuffer, ReplicationCoordinator
long long termWhenBufferIsEmpty = replCoord->getTerm();
// Blocks up to a second waiting for a batch to be ready to apply. If one doesn't become
// ready in time, we'll loop again so we can do the above checks periodically.
- OpQueue ops = batcher.getNextBatch(Seconds(1));
+ OpQueue ops = batcher->getNextBatch(Seconds(1));
if (ops.empty()) {
if (ops.mustShutdown()) {
// Shut down and exit oplog application loop.
diff --git a/src/mongo/db/repl/sync_tail.h b/src/mongo/db/repl/sync_tail.h
index 233026c52f9..d5d08c0e1db 100644
--- a/src/mongo/db/repl/sync_tail.h
+++ b/src/mongo/db/repl/sync_tail.h
@@ -266,6 +266,10 @@ private:
class OpQueueBatcher;
+ void _oplogApplication(OplogBuffer* oplogBuffer,
+ ReplicationCoordinator* replCoord,
+ OpQueueBatcher* batcher) noexcept;
+
std::string _hostname;
OplogApplier::Observer* const _observer;
diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp
index 326108a41f3..144252c5b50 100644
--- a/src/mongo/db/repl/sync_tail_test.cpp
+++ b/src/mongo/db/repl/sync_tail_test.cpp
@@ -1125,7 +1125,7 @@ public:
DEATH_TEST_F(SyncTailTest,
OplogApplicationLogsExceptionFromSignalDrainCompleteBeforeAborting,
- "Invariant failure _isDead") {
+ "OperationFailed: failed to signal drain complete") {
// Leave oplog buffer empty so that SyncTail calls
// ReplicationCoordinator::signalDrainComplete() during oplog application.
auto oplogBuffer = std::make_unique<OplogBufferBlockingQueue>();