diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 6d7f46d8393..a6cc2ed6892 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -8409,6 +8409,72 @@ TEST_P(StoreTestSpecificAUSize, BluestoreBrokenZombieRepairTest) { bstore->mount(); } +TEST_P(StoreTestSpecificAUSize, BluestoreZombiesOverwriteLegacyOmapRepairTest) { + if (string(GetParam()) != "bluestore") + return; + + SetVal(g_conf(), "bluestore_fsck_on_mount", "false"); + SetVal(g_conf(), "bluestore_fsck_on_umount", "false"); + SetVal(g_conf(), "bluestore_fsck_error_on_no_per_pool_omap", "true"); + SetVal(g_conf(), "bluestore_fsck_error_on_no_per_pg_omap", "true"); + + StartDeferred(0x10000); + + BlueStore* bstore = dynamic_cast (store.get()); + + int r; + + cerr << "initializing" << std::endl; + { + ObjectStore::CollectionHandle ch; + ghobject_t hoid; + + unique_ptr cid; + + auto pool = 123; + cid.reset(new coll_t(spg_t(pg_t(0, 123), shard_id_t::NO_SHARD))); + ch = store->create_new_collection(*cid); + hoid = make_object("objectname", pool); + + { + ObjectStore::Transaction t; + t.create_collection(*cid, 0); + r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + } + cerr << "onode preparing" << std::endl; + { + bufferlist bl; + string s(0x1000, 'a'); + bl.append(s); + + map omap; + omap["omap_key"].append("omap value"); + + ObjectStore::Transaction t; + t.write(*cid, hoid, bl.length(), bl.length(), bl); + t.omap_setkeys(*cid, hoid, omap); + r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + } + cerr << "Errors injection" << std::endl; + + sleep(5); + + bstore->inject_zombie_spanning_blob(*cid, hoid, 12345); + bstore->inject_legacy_omap(*cid, hoid); + + cerr << "fscking/fixing" << std::endl; + bstore->umount(); + ASSERT_EQ(bstore->fsck(false), 2); + ASSERT_LE(bstore->quick_fix(), 0); + ASSERT_EQ(bstore->fsck(false), 0); + } + + cerr << "Completing" << std::endl; + bstore->mount(); +} + TEST_P(StoreTest, BluestoreRepairGlobalStats) { if (string(GetParam()) != "bluestore") return;