From f96844f150f342c44cf054f0f05f258239e12d28 Mon Sep 17 00:00:00 2001 From: Jilong Kou Date: Tue, 19 Nov 2024 12:01:16 +0800 Subject: [PATCH] Fix comments --- src/lib/homestore_backend/hs_homeobject.hpp | 1 - src/lib/homestore_backend/hs_pg_manager.cpp | 1 - .../snapshot_receive_handler.cpp | 21 ++++++++----------- .../homestore_backend/tests/hs_blob_tests.cpp | 2 ++ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/lib/homestore_backend/hs_homeobject.hpp b/src/lib/homestore_backend/hs_homeobject.hpp index 601495ea..507b4f0f 100644 --- a/src/lib/homestore_backend/hs_homeobject.hpp +++ b/src/lib/homestore_backend/hs_homeobject.hpp @@ -337,7 +337,6 @@ class HSHomeObject : public HomeObjectImpl { shard_id_t get_next_shard() const; shard_id_t shard_cursor_{invalid_shard_id}; - blob_id_t blob_cursor_{0}; snp_batch_id_t cur_batch_num_{0}; std::vector< shard_id_t > shard_list_; diff --git a/src/lib/homestore_backend/hs_pg_manager.cpp b/src/lib/homestore_backend/hs_pg_manager.cpp index 6e5176c0..b08d2ffa 100644 --- a/src/lib/homestore_backend/hs_pg_manager.cpp +++ b/src/lib/homestore_backend/hs_pg_manager.cpp @@ -105,7 +105,6 @@ HSHomeObject::HS_PG* HSHomeObject::local_create_pg(shared< ReplDev > repl_dev, P } // create index table and pg - // TODO create index table during create shard. auto index_table = create_index_table(); auto uuid_str = boost::uuids::to_string(index_table->uuid()); diff --git a/src/lib/homestore_backend/snapshot_receive_handler.cpp b/src/lib/homestore_backend/snapshot_receive_handler.cpp index 60ecf3fb..840109b3 100644 --- a/src/lib/homestore_backend/snapshot_receive_handler.cpp +++ b/src/lib/homestore_backend/snapshot_receive_handler.cpp @@ -23,7 +23,6 @@ void HSHomeObject::SnapshotReceiveHandler::process_pg_snapshot_data(ResyncPGMeta // Create local PG PGInfo pg_info(pg_meta.pg_id()); std::copy_n(pg_meta.replica_set_uuid()->data(), 16, pg_info.replica_set_uuid.begin()); - pg_info.size = pg_meta.members()->size(); for (unsigned int i = 0; i < pg_meta.members()->size(); i++) { const auto member = pg_meta.members()->Get(i); uuids::uuid id{}; @@ -88,7 +87,6 @@ int HSHomeObject::SnapshotReceiveHandler::process_shard_snapshot_data(ResyncShar // Now let's create local shard home_obj_.local_create_shard(shard_sb.info, chunk_id, blk_id.blk_count()); shard_cursor_ = shard_meta.shard_id(); - blob_cursor_ = 0; cur_batch_num_ = 0; return 0; } @@ -120,17 +118,18 @@ int HSHomeObject::SnapshotReceiveHandler::process_blobs_snapshot_data(ResyncBlob } auto blob_data = blob->data()->Data(); - auto header = r_cast< BlobHeader const* >(blob_data); - if (header->valid()) { - LOGE("Invalid header found for blob_id {}: [header={}]", blob->blob_id(), header->to_string()); - return INVALID_BLOB_HEADER; - } - std::string user_key = header->user_key_size - ? std::string(r_cast< const char* >(blob_data + sizeof(BlobHeader)), header->user_key_size) - : std::string{}; // Check integrity of normal blobs if (blob->state() != static_cast< uint8_t >(ResyncBlobState::CORRUPTED)) { + auto header = r_cast< BlobHeader const* >(blob_data); + if (!header->valid()) { + LOGE("Invalid header found for blob_id {}: [header={}]", blob->blob_id(), header->to_string()); + return INVALID_BLOB_HEADER; + } + std::string user_key = header->user_key_size + ? std::string(r_cast< const char* >(blob_data + sizeof(BlobHeader)), header->user_key_size) + : std::string{}; + uint8_t computed_hash[BlobHeader::blob_max_hash_len]{}; home_obj_.compute_blob_payload_hash(header->hash_algorithm, blob_data + header->data_offset, header->blob_size, uintptr_cast(user_key.data()), header->user_key_size, @@ -189,8 +188,6 @@ int HSHomeObject::SnapshotReceiveHandler::process_blobs_snapshot_data(ResyncBlob free_allocated_blks(); return ADD_BLOB_INDEX_ERR; } - - blob_cursor_ = blob->blob_id(); } return 0; diff --git a/src/lib/homestore_backend/tests/hs_blob_tests.cpp b/src/lib/homestore_backend/tests/hs_blob_tests.cpp index df2c3355..c00f33b5 100644 --- a/src/lib/homestore_backend/tests/hs_blob_tests.cpp +++ b/src/lib/homestore_backend/tests/hs_blob_tests.cpp @@ -207,3 +207,5 @@ TEST_F(HomeObjectFixture, PGBlobIterator) { // EXPECT_EQ(result.object_off, b.blob.object_off); // } } + +TEST_F(HomeObjectFixture, SnapshotReceiveHandler) {}