summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuhong Zhang <danielzhangyh@gmail.com>2021-04-22 20:01:45 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-26 20:11:16 +0000
commit3ef713143891fe627e3b41afdc4accd9a409bc7c (patch)
treed4e91b42d39ca62c1db4cb41d3184a7c672b37a7 /src
parentd68c96ef6c3a91b1c729344b10a0fc41ea834006 (diff)
downloadmongo-3ef713143891fe627e3b41afdc4accd9a409bc7c.tar.gz
SERVER-55263 Extend ReshardingOplogApplierRetryableTest to cover multiple statement ids per oplog entry
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/s/resharding/resharding_oplog_session_application_test.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/mongo/db/s/resharding/resharding_oplog_session_application_test.cpp b/src/mongo/db/s/resharding/resharding_oplog_session_application_test.cpp
index 2309a789162..14aed43039a 100644
--- a/src/mongo/db/s/resharding/resharding_oplog_session_application_test.cpp
+++ b/src/mongo/db/s/resharding/resharding_oplog_session_application_test.cpp
@@ -297,6 +297,46 @@ TEST_F(ReshardingOplogSessionApplicationTest, IncomingRetryableWriteForNewSessio
}
}
+TEST_F(ReshardingOplogSessionApplicationTest, IncomingRetryableWriteForNewSessionMultiStmtIds) {
+ auto lsid = makeLogicalSessionIdForTest();
+
+ TxnNumber incomingTxnNumber = 100;
+ StmtId incomingStmtId = 1;
+
+ auto opTime = [&] {
+ auto opCtx = makeOperationContext();
+ return insertSessionRecord(opCtx.get(), makeLogicalSessionIdForTest(), 100, {3, 4});
+ }();
+
+ auto oplogEntry = makeUpdateOp(
+ BSON("_id" << 1), lsid, incomingTxnNumber, {incomingStmtId, incomingStmtId + 1});
+
+ {
+ auto opCtx = makeOperationContext();
+ ReshardingOplogSessionApplication applier;
+ auto hitPreparedTxn = applier.tryApplyOperation(opCtx.get(), oplogEntry);
+ ASSERT_FALSE(bool(hitPreparedTxn));
+ }
+
+ {
+ auto opCtx = makeOperationContext();
+ auto foundOps = findOplogEntriesNewerThan(opCtx.get(), opTime.getTimestamp());
+ ASSERT_EQ(foundOps.size(), 1U);
+ checkGeneratedNoop(
+ foundOps[0], lsid, incomingTxnNumber, {incomingStmtId, incomingStmtId + 1});
+
+ auto sessionTxnRecord = findSessionRecord(opCtx.get(), lsid);
+ ASSERT_TRUE(bool(sessionTxnRecord));
+ checkSessionTxnRecord(*sessionTxnRecord, foundOps[0]);
+ }
+
+ {
+ auto opCtx = makeOperationContext();
+ checkStatementExecuted(opCtx.get(), lsid, incomingTxnNumber, incomingStmtId);
+ checkStatementExecuted(opCtx.get(), lsid, incomingTxnNumber, incomingStmtId + 1);
+ }
+}
+
TEST_F(ReshardingOplogSessionApplicationTest, IncomingRetryableWriteHasHigherTxnNumber) {
auto lsid = makeLogicalSessionIdForTest();
@@ -488,6 +528,39 @@ TEST_F(ReshardingOplogSessionApplicationTest, IncomingRetryableWriteStmtAlreadyE
}
}
+TEST_F(ReshardingOplogSessionApplicationTest, IncomingRetryableWriteStmtsAlreadyExecuted) {
+ auto lsid = makeLogicalSessionIdForTest();
+
+ TxnNumber txnNumber = 100;
+ StmtId stmtId = 3;
+
+ auto opTime = [&] {
+ auto opCtx = makeOperationContext();
+ return insertSessionRecord(opCtx.get(), lsid, txnNumber, {stmtId, stmtId + 1});
+ }();
+
+ auto oplogEntry = makeUpdateOp(BSON("_id" << 1), lsid, txnNumber, {stmtId, stmtId + 1});
+
+ {
+ auto opCtx = makeOperationContext();
+ ReshardingOplogSessionApplication applier;
+ auto hitPreparedTxn = applier.tryApplyOperation(opCtx.get(), oplogEntry);
+ ASSERT_FALSE(bool(hitPreparedTxn));
+ }
+
+ {
+ auto opCtx = makeOperationContext();
+ auto foundOps = findOplogEntriesNewerThan(opCtx.get(), opTime.getTimestamp());
+ ASSERT_EQ(foundOps.size(), 0U);
+
+ auto sessionTxnRecord = findSessionRecord(opCtx.get(), lsid);
+ ASSERT_TRUE(bool(sessionTxnRecord));
+ ASSERT_EQ(sessionTxnRecord->getSessionId(), lsid) << sessionTxnRecord->toBSON();
+ ASSERT_EQ(sessionTxnRecord->getTxnNum(), txnNumber) << sessionTxnRecord->toBSON();
+ ASSERT_EQ(sessionTxnRecord->getLastWriteOpTime(), opTime) << sessionTxnRecord->toBSON();
+ }
+}
+
TEST_F(ReshardingOplogSessionApplicationTest,
IncomingRetryableWriteHasHigherTxnNumberThanPreparedTxn) {
auto lsid = makeLogicalSessionIdForTest();