diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-03-20 11:19:00 -0400 |
---|---|---|
committer | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-03-21 18:19:34 -0400 |
commit | daa7dbf7e4564fc38b946416e3240caeb3c59b3a (patch) | |
tree | 66fbd802be5504e1b0f2a5b3d3b830cca7b90752 /src | |
parent | fba785c14c3a5a45d85cf27a1af5be848b106342 (diff) | |
download | mongo-daa7dbf7e4564fc38b946416e3240caeb3c59b3a.tar.gz |
SERVER-33971 Generate session sentinel oplog entry with wall clock time
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/s/session_catalog_migration_source.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/s/session_catalog_migration_source_test.cpp | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/mongo/db/s/session_catalog_migration_source.cpp b/src/mongo/db/s/session_catalog_migration_source.cpp index 36190bf1cd4..952e536811d 100644 --- a/src/mongo/db/s/session_catalog_migration_source.cpp +++ b/src/mongo/db/s/session_catalog_migration_source.cpp @@ -78,6 +78,7 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime, const BSONObj& oField, const boost::optional<BSONObj>& o2Field, const OperationSessionInfo& sessionInfo, + Date_t wallClockTime, const boost::optional<StmtId>& statementId) { return repl::OplogEntry(opTime, // optime hash, // hash @@ -90,7 +91,7 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime, o2Field, // o2 sessionInfo, // session info boost::none, // upsert - boost::none, // wall clock time + wallClockTime, // wall clock time statementId, // statement id boost::none, // optime of previous write within same transaction boost::none, // pre-image optime @@ -100,13 +101,14 @@ repl::OplogEntry makeOplogEntry(repl::OpTime opTime, /** * Creates a special "write history lost" sentinel oplog entry. */ -repl::OplogEntry makeSentinelOplogEntry(OperationSessionInfo sessionInfo) { +repl::OplogEntry makeSentinelOplogEntry(OperationSessionInfo sessionInfo, Date_t wallClockTime) { return makeOplogEntry({}, // optime hashGenerator.nextInt64(), // hash repl::OpTypeEnum::kNoop, // op type {}, // o Session::kDeadEndSentinel, // o2 sessionInfo, // session info + wallClockTime, // wall clock time kIncompleteHistoryStmtId); // statement id } @@ -337,7 +339,8 @@ repl::OplogEntry SessionCatalogMigrationSource::SessionOplogIterator::getNext( OperationSessionInfo sessionInfo; sessionInfo.setSessionId(_record.getSessionId()); sessionInfo.setTxnNumber(_record.getTxnNum()); - auto oplog = makeSentinelOplogEntry(sessionInfo); + auto oplog = makeSentinelOplogEntry( + sessionInfo, opCtx->getServiceContext()->getFastClockSource()->now()); _writeHistoryIterator.reset(); diff --git a/src/mongo/db/s/session_catalog_migration_source_test.cpp b/src/mongo/db/s/session_catalog_migration_source_test.cpp index f4940cfad40..dc2ae5677de 100644 --- a/src/mongo/db/s/session_catalog_migration_source_test.cpp +++ b/src/mongo/db/s/session_catalog_migration_source_test.cpp @@ -596,6 +596,8 @@ TEST_F(SessionCatalogMigrationSourceTest, ReturnsDeadEndSentinelForIncompleteHis ASSERT_BSONOBJ_EQ(Session::kDeadEndSentinel, *oplog.getObject2()); ASSERT_TRUE(oplog.getStatementId()); ASSERT_EQ(kIncompleteHistoryStmtId, *oplog.getStatementId()); + ASSERT_TRUE(oplog.getWallClockTime()); + ASSERT_NE(Date_t{}, *oplog.getWallClockTime()); auto sessionInfo = oplog.getOperationSessionInfo(); ASSERT_TRUE(sessionInfo.getSessionId()); |