From: Adam Kupczyk Date: Fri, 6 Mar 2026 12:26:52 +0000 (+0000) Subject: os/bluestore: Remove assert from NCB recovery X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=380563b1fcd8ad0bb3375dd77c7dede832d6482f;p=ceph.git os/bluestore: Remove assert from NCB recovery Now instead of assert print error message. Fixes: https://tracker.ceph.com/issues/74645 Signed-off-by: Adam Kupczyk --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 7d44a9590d00..5e64dd5282ce 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -20509,7 +20509,12 @@ int BlueStore::read_allocation_from_onodes(SimpleBitmap *sbmap, read_alloc_stats << dendl; return -EIO; } - ceph_assert(oid == edecoder.get_oid()); + if (oid != edecoder.get_oid()) { + derr << __func__ << " shard " << pretty_binary_string(okey) + << " oid: " << oid + << " not from current oid: " << edecoder.get_oid() << dendl; + continue; + } edecoder.decode_some(it->value(), nullptr); ++stats.shard_count; } diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index b9996b914b48..176eecbad3ed 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -307,6 +307,63 @@ public: int r = queue_transaction(store, ch, std::move(t)); return r; } + + coll_t cid; + ObjectStore::CollectionHandle ch; + + void prepare_store() + { + static constexpr uint64_t _1G = uint64_t(1024)*1024*1024; + static constexpr uint64_t _1M = uint64_t(1) * 1024 * 1024; + SetVal(g_conf(), "bluestore_block_size", stringify(101 * _1G).c_str()); + g_conf().apply_changes(nullptr); + DeferredSetup(); + + cid = coll_t(spg_t(pg_t(1, 222), shard_id_t::NO_SHARD)); + + ghobject_t hoid1(hobject_t(sobject_t("aaaa_Object 1", CEPH_NOSNAP), "", 1, 222, "")); + ghobject_t hoid_special(hobject_t(sobject_t("my_special_object", CEPH_NOSNAP), "", 1, 222, "")); + ghobject_t hoid2(hobject_t(sobject_t("zzzz_Object 2", CEPH_NOSNAP), "", 1, 222, "")); + //set hashes to have special object in the middle + hoid1.hobj. set_hash(0x00000000); //0 + hoid_special.hobj.set_hash(0x80000000); //1 + hoid2.hobj. set_hash(0x40000000); //2 + + ch = store->create_new_collection(cid); + { + ObjectStore::Transaction t; + t.create_collection(cid, 0); + int r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + } + + write_object(cid, ch, hoid1, 4 * _1M); + write_object(cid, ch, hoid_special, 4 * _1M); + write_object(cid, ch, hoid2, 4 * _1M); + + ch.reset(); + umount(); + } + + void cleanup_store() + { + ghobject_t hoid1(hobject_t(sobject_t("aaaa_Object 1", CEPH_NOSNAP),"", 1, 222,"")); + ghobject_t hoid_special(hobject_t(sobject_t("my_special_object", CEPH_NOSNAP),"", 1, 222,"")); + ghobject_t hoid2(hobject_t(sobject_t("zzzz_Object 2", CEPH_NOSNAP),"", 1, 222,"")); + mount(); + ch = store->open_collection(cid); + { + ObjectStore::Transaction t; + t.remove(cid, hoid1); + t.remove(cid, hoid_special); + t.remove(cid, hoid2); + t.remove_collection(cid); + int r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + } + ch.reset(); + umount(); + } }; #endif // WITH_BLUESTORE @@ -11408,39 +11465,10 @@ TEST_P(MultiLabelTest, UpgradeToMultiLabelCollisionWithObjects) { ASSERT_EQ(label.meta["multi"], "yes"); } -TEST_P(CorruptedOnodesTest, Recover_TolerateMissingHeadShard) { - static constexpr uint64_t _1G = uint64_t(1024)*1024*1024; - static constexpr uint64_t _1M = uint64_t(1)*1024*1024; +TEST_P(CorruptedOnodesTest, Recover_TolerateMissingHeadShard) +{ SetVal(g_conf(), "bluestore_debug_inject_allocation_from_file_failure", "0"); - SetVal(g_conf(), "bluestore_block_size", stringify(101 * _1G).c_str()); - g_conf().apply_changes(nullptr); - DeferredSetup(); - - coll_t cid(spg_t(pg_t(1,222), shard_id_t::NO_SHARD)); - ObjectStore::CollectionHandle ch; - - ghobject_t hoid1(hobject_t(sobject_t("aaaa_Object 1", CEPH_NOSNAP),"", 1, 222,"")); - ghobject_t hoid_special(hobject_t(sobject_t("my_special_object", CEPH_NOSNAP),"", 1, 222,"")); - ghobject_t hoid2(hobject_t(sobject_t("zzzz_Object 2", CEPH_NOSNAP),"", 1, 222,"")); - //set hashes to have special object in the middle - hoid1.hobj. set_hash(0x00000000); //0 - hoid_special.hobj.set_hash(0x80000000); //1 - hoid2.hobj. set_hash(0x40000000); //2 - int r; - ch = store->create_new_collection(cid); - { - ObjectStore::Transaction t; - t.create_collection(cid, 0); - r = queue_transaction(store, ch, std::move(t)); - ASSERT_EQ(r, 0); - } - - write_object(cid, ch, hoid1, 4 * _1M); - write_object(cid, ch, hoid_special, 4 * _1M); - write_object(cid, ch, hoid2, 4 * _1M); - - ch.reset(); - umount(); + prepare_store(); mount(); BlueStore* bs = dynamic_cast(store.get()); @@ -11464,19 +11492,7 @@ TEST_P(CorruptedOnodesTest, Recover_TolerateMissingHeadShard) { SetVal(g_conf(), "bluestore_debug_inject_allocation_from_file_failure", "1"); g_conf().apply_changes(nullptr); - mount(); - ch = store->open_collection(cid); - { - ObjectStore::Transaction t; - t.remove(cid, hoid1); - t.remove(cid, hoid_special); - t.remove(cid, hoid2); - t.remove_collection(cid); - r = queue_transaction(store, ch, std::move(t)); - ASSERT_EQ(r, 0); - } - ch.reset(); - umount(); + cleanup_store(); } #endif // WITH_BLUESTORE