From d38f06172d8844341d56e1e7a7535ace7c3efe29 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Thu, 20 May 2021 02:15:32 +0300 Subject: [PATCH] test/bluestore: add test case to reproduce #50017 This issue is caused by the lack of multithreading sync when doing bluestore's quick-fix. Signed-off-by: Igor Fedotov (cherry picked from commit 339a4257a1bfb7dc5d47b019a8a6492affa05b7c) --- src/test/objectstore/store_test.cc | 70 ++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 92596dbf66474..13ece64799b80 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -7652,6 +7652,76 @@ TEST_P(StoreTestSpecificAUSize, BluestoreRepairTest) { } +TEST_P(StoreTestSpecificAUSize, BluestoreBrokenZombieRepairTest) { + if (string(GetParam()) != "bluestore") + return; + + SetVal(g_conf(), "bluestore_fsck_on_mount", "false"); + SetVal(g_conf(), "bluestore_fsck_on_umount", "false"); + + StartDeferred(0x10000); + + BlueStore* bstore = dynamic_cast (store.get()); + + int r; + + cerr << "initializing" << std::endl; + { + const size_t col_count = 16; + const size_t obj_count = 1024; + ObjectStore::CollectionHandle ch[col_count]; + ghobject_t hoid[col_count][obj_count]; + + unique_ptr cid[col_count]; + + for (size_t i = 0; i < col_count; i++) { + cid[i].reset(new coll_t(spg_t(pg_t(0, i), shard_id_t::NO_SHARD))); + ch[i] = store->create_new_collection(*cid[i]); + for (size_t j = 0; j < obj_count; j++) { + hoid[i][j] = make_object(stringify(j).c_str(), i); + } + } + + for (size_t i = 0; i < col_count; i++) { + ObjectStore::Transaction t; + t.create_collection(*cid[i], 0); + r = queue_transaction(store, ch[i], std::move(t)); + ASSERT_EQ(r, 0); + } + cerr << "onode preparing" << std::endl; + bufferlist bl; + string s(0x1000, 'a'); + bl.append(s); + + for (size_t i = 0; i < col_count; i++) { + for (size_t j = 0; j < obj_count; j++) { + ObjectStore::Transaction t; + t.write(*cid[i], hoid[i][j], bl.length(), bl.length(), bl); + r = queue_transaction(store, ch[i], std::move(t)); + ASSERT_EQ(r, 0); + } + } + cerr << "Zombie spanning blob injection" << std::endl; + + sleep(5); + + for (size_t i = 0; i < col_count; i++) { + for (size_t j = 0; j < obj_count; j++) { + bstore->inject_zombie_spanning_blob(*cid[i], hoid[i][j], 12345); + } + } + + cerr << "fscking/fixing" << std::endl; + bstore->umount(); + ASSERT_EQ(bstore->fsck(false), col_count * obj_count); + 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; -- 2.39.5