summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/dbtests.cpp
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-08-16 11:20:22 -0400
committerDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-08-21 11:56:14 -0400
commitd63202a259f038a8a8ef1af6f67c8cec396de4e5 (patch)
tree0411bb29740214c0f09910a3ceb95df9d4d9f2a1 /src/mongo/dbtests/dbtests.cpp
parent10dd7ef95fab6b869818f54827d4e03924846432 (diff)
downloadmongo-d63202a259f038a8a8ef1af6f67c8cec396de4e5.tar.gz
SERVER-42497: Detect unintentional untimestamped writes to the durable catalog.
Diffstat (limited to 'src/mongo/dbtests/dbtests.cpp')
-rw-r--r--src/mongo/dbtests/dbtests.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mongo/dbtests/dbtests.cpp b/src/mongo/dbtests/dbtests.cpp
index 6f33b22ebe8..942678a87dd 100644
--- a/src/mongo/dbtests/dbtests.cpp
+++ b/src/mongo/dbtests/dbtests.cpp
@@ -105,7 +105,17 @@ Status createIndexFromSpec(OperationContext* opCtx, StringData ns, const BSONObj
}
MultiIndexBlock indexer;
ON_BLOCK_EXIT([&] { indexer.cleanUpAfterBuild(opCtx, coll); });
- Status status = indexer.init(opCtx, coll, spec, MultiIndexBlock::kNoopOnInitFn).getStatus();
+ Status status = indexer
+ .init(opCtx,
+ coll,
+ spec,
+ [opCtx](const std::vector<BSONObj>& specs) -> Status {
+ if (opCtx->recoveryUnit()->getCommitTimestamp().isNull()) {
+ return opCtx->recoveryUnit()->setTimestamp(Timestamp(1, 1));
+ }
+ return Status::OK();
+ })
+ .getStatus();
if (status == ErrorCodes::IndexAlreadyExists) {
return Status::OK();
}
@@ -123,6 +133,7 @@ Status createIndexFromSpec(OperationContext* opCtx, StringData ns, const BSONObj
WriteUnitOfWork wunit(opCtx);
ASSERT_OK(indexer.commit(
opCtx, coll, MultiIndexBlock::kNoopOnCreateEachFn, MultiIndexBlock::kNoopOnCommitFn));
+ ASSERT_OK(opCtx->recoveryUnit()->setTimestamp(Timestamp(1, 1)));
wunit.commit();
return Status::OK();
}