Skip to content

Commit b47a9e5

Browse files
committed
test/crimson/../test_transaction_manager: fix try_get_extent() to handle transaction conflicts
Outside interruptible future, transaction can become invalidated implicitly. Signed-off-by: Yingxin Cheng <[email protected]>
1 parent 8eab80d commit b47a9e5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/test/crimson/seastore/test_transaction_manager.cc

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,11 @@ struct transaction_manager_test_t :
543543
"get_extent got invalid error"
544544
}
545545
).get();
546+
if (t.t->is_conflicted()) {
547+
return nullptr;
548+
}
546549
if (ext) {
550+
ceph_assert(ext->is_valid());
547551
EXPECT_EQ(addr, ext->get_laddr());
548552
}
549553
return ext;
@@ -569,7 +573,11 @@ struct transaction_manager_test_t :
569573
"get_extent got invalid error"
570574
}
571575
).get();
576+
if (t.t->is_conflicted()) {
577+
return nullptr;
578+
}
572579
if (ext) {
580+
ceph_assert(ext->is_valid());
573581
EXPECT_EQ(addr, ext->get_laddr());
574582
}
575583
return ext;
@@ -1572,14 +1580,12 @@ struct transaction_manager_test_t :
15721580
last_pin = pin->duplicate();
15731581
}
15741582
auto last_ext = try_get_extent(t, last_pin.get_key());
1575-
if (last_ext) {
1576-
auto last_ext1 = mutate_extent(t, last_ext);
1577-
ASSERT_TRUE(last_ext1->is_exist_mutation_pending());
1578-
} else {
1579-
conflicted++;
1580-
return;
1583+
if (!last_ext) {
1584+
conflicted++;
1585+
return;
15811586
}
1582-
1587+
auto last_ext1 = mutate_extent(t, last_ext);
1588+
ASSERT_TRUE(last_ext1->is_exist_mutation_pending());
15831589
if (try_submit_transaction(std::move(t))) {
15841590
success++;
15851591
logger().info("transaction {} submit the transction",

0 commit comments

Comments
 (0)