]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/osd: cover clear_omap tombstoning of cached keys 69777/head
authorSun Yuechi <sunyuechi@iscas.ac.cn>
Sat, 27 Jun 2026 07:23:51 +0000 (15:23 +0800)
committerSun Yuechi <sunyuechi@iscas.ac.cn>
Sat, 27 Jun 2026 07:44:06 +0000 (15:44 +0800)
Add a regression test that processes an insert so the keys are cached
in key_map, then processes a later clear_omap and asserts the cached
keys are returned as tombstones.

This would have caught the by-value bind in process_entries, where
clear_omap mutated copies and left already-cached keys untouched.

Signed-off-by: Sun Yuechi <sunyuechi@iscas.ac.cn>
src/test/osd/test_ec_omap_journal.cc

index 431acae72eb01446d1c11efbb034e6b50c720ead..58cb193c0cf7408ed4a8bd8dd22f61cc24f9fdf5 100644 (file)
@@ -519,6 +519,32 @@ TEST(ecomapjournal, ClearOmap) {
   EXPECT_TRUE(ranges.at("") == std::nullopt);
 }
 
+TEST(ecomapjournal, ClearOmapTombstonesCachedKeys) {
+  MockDoutPrefixProvider dpp;
+  ECOmapJournal journal(dpp);
+  const hobject_t hoid("obj_clear_cached", CEPH_NOSNAP, 1, 0, "nspace");
+
+  // Process an insert first so the keys land in the cached key_map.
+  journal.add_entry(hoid, create_insert_entry(eversion_t(1, 1), 1, 3));
+  {
+    auto [updates, ranges] = journal.get_value_updates(hoid);
+    ASSERT_TRUE(updates.at(make_key(1)).value.has_value());
+    ASSERT_TRUE(updates.at(make_key(2)).value.has_value());
+    ASSERT_TRUE(updates.at(make_key(3)).value.has_value());
+  }
+
+  // A later clear_omap must mark the already-cached keys as tombstones.
+  journal.add_entry(hoid, ECOmapJournalEntry(eversion_t(1, 2), true, std::nullopt, {}));
+
+  auto [updates, ranges] = journal.get_value_updates(hoid);
+  ASSERT_TRUE(updates.contains(make_key(1)));
+  ASSERT_TRUE(updates.contains(make_key(2)));
+  ASSERT_TRUE(updates.contains(make_key(3)));
+  EXPECT_FALSE(updates.at(make_key(1)).value.has_value());
+  EXPECT_FALSE(updates.at(make_key(2)).value.has_value());
+  EXPECT_FALSE(updates.at(make_key(3)).value.has_value());
+}
+
 TEST(ecomapjournal, append_delete_clears_maps)
 {
   MockDoutPrefixProvider dpp;