Skip to content

Commit

Permalink
add wait for all before validation for new member
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Nov 13, 2024
1 parent b605f4f commit 7082539
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/lib/homestore_backend/tests/homeobj_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,14 @@ class HomeObjectFixture : public ::testing::Test {
return false;
}

// wait for the last blob to be created locally, which means all the blob before this blob are created
void wait_for_all(shard_id_t shard_id, blob_id_t blob_id) {
while (true) {
if (blob_exist(shard_id, blob_id)) return;
std::this_thread::sleep_for(1s);
}
}

private:
bool pg_exist(pg_id_t pg_id) {
std::vector< pg_id_t > pg_ids;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TEST_F(HomeObjectFixture, ReplaceMember) {
std::map< pg_id_t, blob_id_t > pg_blob_id;
for (shard_id_t shard_id = 1; shard_id <= num_shards_per_pg; shard_id++) {
auto derived_shard_id = make_new_shard_id(pg_id, shard_id);
pg_shard_id_vec[1].emplace_back(derived_shard_id);
pg_shard_id_vec[pg_id].emplace_back(derived_shard_id);
}

// TODO:: if we add delete blobs case in baseline resync, we need also derive the last blob_id in this pg for spare
Expand All @@ -73,12 +73,15 @@ TEST_F(HomeObjectFixture, ReplaceMember) {
ASSERT_TRUE(r);
});

// the new member should wait until it joins the pg
// the new member should wait until it joins the pg and all the blobs are replicated to it
if (in_member_id == g_helper->my_replica_id()) {
while (!am_i_in_pg(pg_id)) {
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
LOGINFO("new member is waiting to become a member of pg {}", pg_id);
}

wait_for_all(pg_shard_id_vec[pg_id].back() /*the last shard id in this pg*/,
num_shards_per_pg * num_blobs_per_shard - 1 /*the last blob id in this pg*/);
}

// step 4: after completing replace member, verify the blob on all the members of this pg including the newly added
Expand Down

0 comments on commit 7082539

Please sign in to comment.