diff options
author | Dianna Hohensee <dianna.hohensee@mongodb.com> | 2020-02-21 15:43:53 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-27 06:27:50 +0000 |
commit | ab2b0971d21bf8a208ee43312d91c4600b63ccc5 (patch) | |
tree | b8633dd59fff755ac686bb9986ad59f82cda5a38 /src/mongo/db/write_concern.cpp | |
parent | 20657a8a6e9d2ed4df9fd8fa3f8c54d12907761f (diff) | |
download | mongo-ab2b0971d21bf8a208ee43312d91c4600b63ccc5.tar.gz |
SERVER-44555 Replicate Before Journaling
Diffstat (limited to 'src/mongo/db/write_concern.cpp')
-rw-r--r-- | src/mongo/db/write_concern.cpp | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/mongo/db/write_concern.cpp b/src/mongo/db/write_concern.cpp index 1a7f4ee868e..85262273fc6 100644 --- a/src/mongo/db/write_concern.cpp +++ b/src/mongo/db/write_concern.cpp @@ -267,28 +267,34 @@ Status waitForWriteConcern(OperationContext* opCtx, WriteConcernOptions writeConcernWithPopulatedSyncMode = replCoord->populateUnsetWriteConcernOptionsSyncMode(writeConcern); - switch (writeConcernWithPopulatedSyncMode.syncMode) { - case WriteConcernOptions::SyncMode::UNSET: - LOGV2_FATAL(22550, "Attempting to wait on a WriteConcern with an unset sync option"); - fassertFailed(34410); - case WriteConcernOptions::SyncMode::NONE: - break; - case WriteConcernOptions::SyncMode::FSYNC: { - if (!storageEngine->isDurable()) { - storageEngine->flushAllFiles(opCtx, /*callerHoldsReadLock*/ false); - - // This field has had a dummy value since MMAP went away. It is undocumented. - // Maintaining it so as not to cause unnecessary user pain across upgrades. - result->fsyncFiles = 1; - } else { - // We only need to commit the journal if we're durable - storageEngine->waitForJournalFlush(opCtx); + // Waiting for durability (flushing the journal or all files to disk) can throw on interruption. + try { + switch (writeConcernWithPopulatedSyncMode.syncMode) { + case WriteConcernOptions::SyncMode::UNSET: + LOGV2_FATAL(22550, + "Attempting to wait on a WriteConcern with an unset sync option"); + fassertFailed(34410); + case WriteConcernOptions::SyncMode::NONE: + break; + case WriteConcernOptions::SyncMode::FSYNC: { + if (!storageEngine->isDurable()) { + storageEngine->flushAllFiles(opCtx, /*callerHoldsReadLock*/ false); + + // This field has had a dummy value since MMAP went away. It is undocumented. + // Maintaining it so as not to cause unnecessary user pain across upgrades. + result->fsyncFiles = 1; + } else { + // We only need to commit the journal if we're durable + storageEngine->waitForJournalFlush(opCtx); + } + break; } - break; + case WriteConcernOptions::SyncMode::JOURNAL: + storageEngine->waitForJournalFlush(opCtx); + break; } - case WriteConcernOptions::SyncMode::JOURNAL: - storageEngine->waitForJournalFlush(opCtx); - break; + } catch (const DBException& ex) { + return ex.toStatus(); } result->syncMillis = syncTimer.millis(); |