summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/initial_syncer.cpp
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2017-04-06 15:30:59 -0400
committerEric Milkie <milkie@10gen.com>2017-08-22 13:45:12 -0400
commit77dc6917428ffad4b9ff2d54d78fa9b225f78a4b (patch)
treefa2483cb4214fd6858db09ca80523751f65888f5 /src/mongo/db/repl/initial_syncer.cpp
parentb1a36aaa34f48df1573d76439419552282f18cbf (diff)
downloadmongo-77dc6917428ffad4b9ff2d54d78fa9b225f78a4b.tar.gz
SERVER-28620 Adorn all oplog writes with timestamps
These timestamps are now used to implement oplog visibility rules, in place of the current in-memory vector of uncommitted ops that the WiredTiger glue code currently uses. This change also introduces a TimestampedBSONObj class, which encapsulates a BSONObject with its associated write timestamp.
Diffstat (limited to 'src/mongo/db/repl/initial_syncer.cpp')
-rw-r--r--src/mongo/db/repl/initial_syncer.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp
index 94997d45293..0cf95dfe417 100644
--- a/src/mongo/db/repl/initial_syncer.cpp
+++ b/src/mongo/db/repl/initial_syncer.cpp
@@ -801,6 +801,7 @@ void InitialSyncer::_databasesClonerCallback(const Status& databaseClonerFinishS
void InitialSyncer::_lastOplogEntryFetcherCallbackForStopTimestamp(
const StatusWith<Fetcher::QueryResponse>& result,
std::shared_ptr<OnCompletionGuard> onCompletionGuard) {
+ Timestamp oplogSeedDocTimestamp;
{
stdx::lock_guard<stdx::mutex> lock(_mutex);
auto status = _checkForShutdownAndConvertStatus_inlock(
@@ -817,7 +818,8 @@ void InitialSyncer::_lastOplogEntryFetcherCallbackForStopTimestamp(
return;
}
auto&& optimeWithHash = optimeWithHashStatus.getValue();
- _initialSyncState->stopTimestamp = optimeWithHash.opTime.getTimestamp();
+ oplogSeedDocTimestamp = _initialSyncState->stopTimestamp =
+ optimeWithHash.opTime.getTimestamp();
if (_initialSyncState->beginTimestamp == _initialSyncState->stopTimestamp) {
_lastApplied = optimeWithHash;
@@ -835,7 +837,7 @@ void InitialSyncer::_lastOplogEntryFetcherCallbackForStopTimestamp(
{
const auto& documents = result.getValue().documents;
invariant(!documents.empty());
- const auto& oplogSeedDoc = documents.front();
+ const BSONObj oplogSeedDoc = documents.front();
LOG(2) << "Inserting oplog seed document: " << oplogSeedDoc;
auto opCtx = makeOpCtx();
@@ -843,7 +845,10 @@ void InitialSyncer::_lastOplogEntryFetcherCallbackForStopTimestamp(
// override its behavior in tests. See InitialSyncerReturnsCallbackCanceledAndDoesNot-
// ScheduleRollbackCheckerIfShutdownAfterInsertingInsertOplogSeedDocument in
// initial_syncer_test.cpp
- auto status = _storage->insertDocument(opCtx.get(), _opts.localOplogNS, oplogSeedDoc);
+ auto status = _storage->insertDocument(
+ opCtx.get(),
+ _opts.localOplogNS,
+ TimestampedBSONObj{oplogSeedDoc, SnapshotName(oplogSeedDocTimestamp)});
if (!status.isOK()) {
stdx::lock_guard<stdx::mutex> lock(_mutex);
onCompletionGuard->setResultAndCancelRemainingWork_inlock(lock, status);