-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PG cleanup for moved out member #242
Conversation
pending on eBay/HomeStore#605 |
1b2870d
to
60dd987
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the crash recovery scenarios need more thinking and explanation.
chunk->m_pg_id = std::nullopt; | ||
chunk->m_v_chunk_id = std::nullopt; | ||
|
||
pdev_heap->m_heap.emplace(chunk); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we fine to open this chunk for re-use by other PG at this point??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe fine, another PG can pick these chunks but commit has to wait as commit is sequential
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a problem, at this point, maybe another create pg request is coming in and will reuse some chunks which belong to the destroyed pg. If a crash happened unfortunately, then recover HomeObject, there will be a situation that two pgs use some same chunks.
fixed it by resetting the chunks before destroying the pg super block, and only returning the chunks to the heap once the pg super block has been destroyed.
// destroy index table | ||
auto uuid_str = boost::uuids::to_string(hs_pg->index_table_->uuid()); | ||
index_table_pg_map_.erase(uuid_str); | ||
hs()->index_service().remove_index_table(hs_pg->index_table_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koujl @shosseinimotlagh could you confirm the remove_index_table
works like rm -rf
which will proper remove all index entries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove_index_table is a memory operation.
https://github.com/eBay/HomeStore/blob/69ea506d3c0cc07f16385ee5d0a9c8f28f64416a/src/lib/index/index_service.cpp#L108
Here is a form about crash recovery scenarios.
|
When a member is moved out of a PG, clean up the PG and reclaim resources: 1. Mark PG state destroyed. 2. Destroy PG shards and shards super block. 3. Reset all chunks. 4. Remove PG index table. 5. Destroy PG super block. 6. Return PG chunks to dev_heap. Additionally, enhance restart test scenarios.
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #242 +/- ##
==========================================
- Coverage 63.15% 62.79% -0.36%
==========================================
Files 32 32
Lines 1900 2086 +186
Branches 204 226 +22
==========================================
+ Hits 1200 1310 +110
- Misses 600 665 +65
- Partials 100 111 +11 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
// destroy pg super blk | ||
hs_pg->pg_sb_.destroy(); | ||
|
||
// return pg chunks to dev heap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you also explains if a crash happened here,what would be the process of recovering this chunks to heap?
Is that because we dont have pg superblock so these chunks are available by default during recovery?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right.If a crash happened here, then we do recovery, as we don't have the pg superblk, so these chunks will belongs to dev heap by default.
void HSHomeObject::reset_pg_chunks(pg_id_t pg_id) { | ||
bool res = chunk_selector_->reset_pg_chunks(pg_id); | ||
RELEASE_ASSERT(res, "Failed to reset all chunks in pg {}", pg_id); | ||
auto fut = homestore::hs()->cp_mgr().trigger_cp_flush(true /* force */); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why triggering a cp flush only after reset chunks, should we trigger flush when all the cleanup is done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other cleanups are metaService only, which do not rely on cp. I think the intent is to do the cp as early as possible but I am fine to move the cp to anywhere before delete the pg superblk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because only reset chunks rely on cp, other operation are metaService destroy only.
The reason why we need do cp before deleting pg superblk is if cp is after delete pg superblk, and a crash happened before do cp, when we do recovery we can't find the pg superblk anymore, and can not have the chance to reset chunks again.
Above all, I thought do cp after reset chunks can be good.
|
||
auto& pg = iter->second; | ||
for (auto& shard : pg->shards_) { | ||
// release open shard v_chunk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: remove this comment, we do not care about v_chunk here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally looks good,
When a member is moved out of a PG, clean up the PG and reclaim resources:
Additionally, enhance restart tests with pristine state validation, covering PG, shard, and blob tests.