Fix TruncateDataPage to handle empty pages and tail maintenance#212
Fix TruncateDataPage to handle empty pages and tail maintenance#212thweetkomputer merged 1 commit intomainfrom
Conversation
WalkthroughTruncation now detects whether keys exist past the truncation point and conditionally performs overflow-value deletions and TTL updates; empty pages may be freed and previous-page links updated. Iterator and region-member initializations were adjusted, changing when certain members are zeroed or left uninitialized until Reset(). Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
batch_write_task.cpp (1)
1687-1694: Variable shadowing oferris valid but reduces clarity.At line 1687,
auto [prev_page, err]creates a newerrthat shadows the outer one declared at line 1635 (and assigned at line 1665). While this is valid C++ and works correctly here, consider using a distinct name likeload_errfor improved readability.- auto [prev_page, err] = LoadDataPage(prev_page_id); - if (err != KvError::NoError) + auto [prev_page, load_err] = LoadDataPage(prev_page_id); + if (load_err != KvError::NoError) { - return {false, err}; + return {false, load_err}; } prev_page.SetNextPageId(MaxPageId); - err = WritePage(std::move(prev_page)); - return {false, err}; + KvError write_err = WritePage(std::move(prev_page)); + return {false, write_err};
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
batch_write_task.cpp(1 hunks)
🔇 Additional comments (2)
batch_write_task.cpp (2)
1644-1658: LGTM!The introduction of
has_trunc_tailcorrectly separates the "preserve keys" phase from the "cleanup truncated keys" phase. The loop properly breaks when finding the first key >=trunc_pos, leaving the iterator positioned at that key for subsequent cleanup processing.
1659-1674: Proper error handling added for overflow deletion.The conditional check ensures cleanup only runs when there's actually a tail to truncate (fixing the original bug). The do-while structure correctly processes the current iterator position first, then advances. The early return on
DelOverflowValueerror prevents continuing with corrupted state.
0979551 to
a4b36f2
Compare
Here are some reminders before you submit the pull request
fixes eloqdb/eloqstore#issue_idctest --test-dir build/tests/Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.