summaryrefslogtreecommitdiff
path: root/src/mongo/db/session_catalog_test.cpp
diff options
context:
space:
mode:
authorCheahuychou Mao <mao.cheahuychou@gmail.com>2022-06-02 17:57:26 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-02 20:09:34 +0000
commit01938cf7239dc4eb6a2fa79b31743cd815d4d92c (patch)
tree6e8203edeb729ee459f2f687f63ad90bac6067a5 /src/mongo/db/session_catalog_test.cpp
parent3a9b68682397a1b5c9a49b5a7ebf668501d371ab (diff)
downloadmongo-01938cf7239dc4eb6a2fa79b31743cd815d4d92c.tar.gz
SERVER-66777 Ensure that internal transactions do not get interrupted by logical session reaper
Diffstat (limited to 'src/mongo/db/session_catalog_test.cpp')
-rw-r--r--src/mongo/db/session_catalog_test.cpp64
1 files changed, 59 insertions, 5 deletions
diff --git a/src/mongo/db/session_catalog_test.cpp b/src/mongo/db/session_catalog_test.cpp
index 1c03de4d26c..fff43463db6 100644
--- a/src/mongo/db/session_catalog_test.cpp
+++ b/src/mongo/db/session_catalog_test.cpp
@@ -1183,7 +1183,7 @@ TEST_F(SessionCatalogTest, KillSessionWhenChildSessionIsNotCheckedOut) {
runTest(parentLsid, makeLogicalSessionIdWithTxnUUIDForTest(parentLsid));
}
-TEST_F(SessionCatalogTest, KillingChildSessionInterruptsParentSession) {
+TEST_F(SessionCatalogTest, KillingChildSessionDoesNotInterruptParentSession) {
auto runTest = [&](const LogicalSessionId& parentLsid, const LogicalSessionId& childLsid) {
auto killToken = [this, &parentLsid, &childLsid] {
assertCanCheckoutSession(childLsid);
@@ -1194,9 +1194,8 @@ TEST_F(SessionCatalogTest, KillingChildSessionInterruptsParentSession) {
auto killToken = catalog()->killSession(childLsid);
- // Make sure the owning operation context is interrupted
- ASSERT_THROWS_CODE(
- opCtx->checkForInterrupt(), AssertionException, ErrorCodes::Interrupted);
+ // Make sure the owning operation context is not interrupted.
+ opCtx->checkForInterrupt();
// Make sure that the checkOutForKill call will wait for the owning operation context to
// check the session back in
@@ -1426,7 +1425,7 @@ TEST_F(SessionCatalogTest, MarkSessionAsKilledCanBeCalledMoreThanOnce) {
runTest(makeLogicalSessionIdWithTxnUUIDForTest());
}
-TEST_F(SessionCatalogTest, MarkSessionsAsKilledWhenSessionDoesNotExist) {
+TEST_F(SessionCatalogTest, MarkNonExistentSessionAsKilled) {
auto runTest = [&](const LogicalSessionId& nonExistentLsid) {
ASSERT_THROWS_CODE(
catalog()->killSession(nonExistentLsid), AssertionException, ErrorCodes::NoSuchSession);
@@ -1437,6 +1436,61 @@ TEST_F(SessionCatalogTest, MarkSessionsAsKilledWhenSessionDoesNotExist) {
runTest(makeLogicalSessionIdWithTxnUUIDForTest());
}
+TEST_F(SessionCatalogTest, MarkNonExistentChildSessionAsKilledWhenParentSessionExists) {
+ auto runTest = [&](const LogicalSessionId& parentLsid,
+ const LogicalSessionId& nonExistentChildLsid) {
+ createSession(parentLsid);
+ ASSERT_THROWS_CODE(catalog()->killSession(nonExistentChildLsid),
+ AssertionException,
+ ErrorCodes::NoSuchSession);
+ };
+
+ {
+ auto parentLsid = makeLogicalSessionIdForTest();
+ runTest(parentLsid, makeLogicalSessionIdWithTxnNumberAndUUIDForTest(parentLsid));
+ }
+
+ {
+ auto parentLsid = makeLogicalSessionIdForTest();
+ runTest(parentLsid, makeLogicalSessionIdWithTxnUUIDForTest(parentLsid));
+ }
+}
+
+
+TEST_F(SessionCatalogTest, MarkNonExistentChildSessionAsKilledWhenOtherChildSessionExists) {
+ auto runTest = [&](const LogicalSessionId& existentChildLsid,
+ const LogicalSessionId& nonExistentChildLsid) {
+ createSession(existentChildLsid);
+ ASSERT_THROWS_CODE(catalog()->killSession(nonExistentChildLsid),
+ AssertionException,
+ ErrorCodes::NoSuchSession);
+ };
+
+ {
+ auto parentLsid = makeLogicalSessionIdForTest();
+ runTest(makeLogicalSessionIdWithTxnNumberAndUUIDForTest(parentLsid),
+ makeLogicalSessionIdWithTxnNumberAndUUIDForTest(parentLsid));
+ }
+
+ {
+ auto parentLsid = makeLogicalSessionIdForTest();
+ runTest(makeLogicalSessionIdWithTxnUUIDForTest(parentLsid),
+ makeLogicalSessionIdWithTxnUUIDForTest(parentLsid));
+ }
+
+ {
+ auto parentLsid = makeLogicalSessionIdForTest();
+ runTest(makeLogicalSessionIdWithTxnNumberAndUUIDForTest(parentLsid),
+ makeLogicalSessionIdWithTxnUUIDForTest(parentLsid));
+ }
+
+ {
+ auto parentLsid = makeLogicalSessionIdForTest();
+ runTest(makeLogicalSessionIdWithTxnUUIDForTest(parentLsid),
+ makeLogicalSessionIdWithTxnNumberAndUUIDForTest(parentLsid));
+ }
+}
+
TEST_F(SessionCatalogTestWithDefaultOpCtx, SessionDiscarOperationContextAfterCheckIn) {
auto runTest = [&](const LogicalSessionId& lsid) {
_opCtx->setLogicalSessionId(lsid);