Conversation
|
pending on eBay/HomeStore#605 |
1b2870d to
60dd987
Compare
xiaoxichen
left a comment
There was a problem hiding this comment.
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.
are we fine to open this chunk for re-use by other PG at this point??
There was a problem hiding this comment.
maybe fine, another PG can pick these chunks but commit has to wait as commit is sequential
There was a problem hiding this comment.
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.
@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.
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. |
| // destroy pg super blk | ||
| hs_pg->pg_sb_.destroy(); | ||
|
|
||
| // return pg chunks to dev heap |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
NIT: remove this comment, we do not care about v_chunk here
JacksonYao287
left a comment
There was a problem hiding this comment.
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.