Wait for prefetch complete before freeing pg_iter - #321
Conversation
6b9e3ec to
9f17292
Compare
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #321 +/- ##
==========================================
- Coverage 63.15% 60.75% -2.41%
==========================================
Files 32 35 +3
Lines 1900 4072 +2172
Branches 204 492 +288
==========================================
+ Hits 1200 2474 +1274
- Misses 600 1333 +733
- Partials 100 265 +165 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that the PGBlobIterator’s in-flight prefetch operations are properly drained before the iterator is freed, and it refactors iterator internals for naming consistency and thread-safety.
- Introduce
PGBlobIterator::stop()to wait for and drain pending prefetches before deletion - Rename iterator members (
cur_obj_id_,group_id_,pg_id_, etc.) and addconstcorrectness - Minor logging tweaks (removed trailing commas/newlines) and bump Conan package version
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/homestore_backend/replication_state_machine.cpp | Call stop() on the PGBlobIterator before deleting it; fix member access in logs |
| src/lib/homestore_backend/replication_message.hpp | Remove trailing newline from SyncMessageHeader::to_string() output |
| src/lib/homestore_backend/pg_blob_iterator.cpp | Refactor iterator internals: rename members, add stop() and locks, adjust const |
| src/lib/homestore_backend/hs_homeobject.hpp | Update class declaration for PGBlobIterator to match refactoring |
| conanfile.py | Bump version from 2.6.2 to 2.6.3 |
Comments suppressed due to low confidence (2)
src/lib/homestore_backend/replication_message.hpp:102
- [nitpick] Removed the trailing newline from the
to_string()output, which might cause log entries to run together; consider preserving the newline in the formatted string or adding it at the logging site to maintain readability.
return fmt::format("magic={:#x} version={} msg_type={} payload_size={} payload_crc={} header_crc={}",
src/lib/homestore_backend/pg_blob_iterator.cpp:435
- Added a new
stop()method to wait for and drain inflight prefetch operations; consider adding unit tests to verify correct stopping behavior and ensure no memory leaks or deadlocks occur.
void HSHomeObject::PGBlobIterator::stop() {
| if (hit_error) { | ||
| builder_.Clear(); | ||
| // drain the prefetched data before return which destroy the iterator. | ||
| for (auto& blob : prefetched_blobs) { |
There was a problem hiding this comment.
Did I understand correctly: if hit error here, let nuraft call clear_snapshot_sync_ctx to trigger 'stop'?
There was a problem hiding this comment.
Correct. The cleanup part will be done by stop().
No description provided.