diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2020-03-31 12:27:58 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-08 18:26:45 +0000 |
commit | 66a0bfe5c1afa5c73d2ce74ebe3eeef26703cb38 (patch) | |
tree | 6327f6247dd4c5126310d4cc950ab729c8c1f599 | |
parent | bd95eb4bdee9f3fe4abf74bbe23687f12fbefb10 (diff) | |
download | mongo-66a0bfe5c1afa5c73d2ce74ebe3eeef26703cb38.tar.gz |
SERVER-46818: Do untimestamped writes in idemptency tests
(cherry picked from commit 53f344385322f7e9a93779e4a515167e766182cc)
-rw-r--r-- | src/mongo/db/repl/idempotency_test_fixture.h | 12 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp | 11 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/mongo/db/repl/idempotency_test_fixture.h b/src/mongo/db/repl/idempotency_test_fixture.h index 6b188a0e9ba..89125d199bc 100644 --- a/src/mongo/db/repl/idempotency_test_fixture.h +++ b/src/mongo/db/repl/idempotency_test_fixture.h @@ -89,7 +89,17 @@ StringBuilderImpl<SharedBufferAllocator>& operator<<(StringBuilderImpl<SharedBuf class IdempotencyTest : public OplogApplierImplTest { public: - IdempotencyTest() : OplogApplierImplTest("wiredTiger"){}; + IdempotencyTest() : OplogApplierImplTest("wiredTiger") { + globalFailPointRegistry() + .find("doUntimestampedWritesForIdempotencyTests") + ->setMode(FailPoint::alwaysOn); + } + + ~IdempotencyTest() { + globalFailPointRegistry() + .find("doUntimestampedWritesForIdempotencyTests") + ->setMode(FailPoint::off); + } protected: enum class SequenceType : int { kEntireSequence, kAnyPrefix, kAnySuffix, kAnyPrefixOrSuffix }; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index 52eae581d8b..951e4a9405c 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -54,6 +54,8 @@ MONGO_FAIL_POINT_DEFINE(WTAlwaysNotifyPrepareConflictWaiters); logv2::LogSeverity kSlowTransactionSeverity = logv2::LogSeverity::Debug(1); +MONGO_FAIL_POINT_DEFINE(doUntimestampedWritesForIdempotencyTests); + } // namespace using Section = WiredTigerOperationStats::Section; @@ -354,7 +356,9 @@ void WiredTigerRecoveryUnit::_txnClose(bool commit) { // read timestamp. invariant(_readAtTimestamp.isNull() || _commitTimestamp >= _readAtTimestamp); - conf << "commit_timestamp=" << integerToHex(_commitTimestamp.asULL()) << ","; + if (MONGO_likely(!doUntimestampedWritesForIdempotencyTests.shouldFail())) { + conf << "commit_timestamp=" << integerToHex(_commitTimestamp.asULL()) << ","; + } _isTimestamped = true; } @@ -655,6 +659,11 @@ Status WiredTigerRecoveryUnit::setTimestamp(Timestamp timestamp) { // Starts the WT transaction associated with this session. getSession(); + if (MONGO_unlikely(doUntimestampedWritesForIdempotencyTests.shouldFail())) { + _isTimestamped = true; + return Status::OK(); + } + const std::string conf = "commit_timestamp=" + integerToHex(timestamp.asULL()); auto rc = session->timestamp_transaction(session, conf.c_str()); if (rc == 0) { |