fix: ignore error on delete in fat truncation. Case when the disk is …#924
Conversation
…full, so delete fails
Manual Deploy AvailableYou can trigger a manual deploy of this PR branch to testnet: Alternative: Comment
Comment updated automatically when the PR is synchronized. |
📝 WalkthroughWalkthroughThe change modifies error handling in the Suggested reviewers
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
magicblock-ledger/src/ledger_truncator.rs (2)
141-141:⚠️ Potential issue | 🟡 MinorApply the same error-handling fix here.
Per the PR objective (ignore delete errors when disk is full), this call should also swallow and log delete errors rather than propagating them with
?.Proposed fix
self.ledger.set_lowest_cleanup_slot(truncate_to_slot); - Self::delete_slots(&self.ledger, 0, truncate_to_slot)?; + if let Err(err) = Self::delete_slots(&self.ledger, 0, truncate_to_slot) { + error!(error = ?err, "Delete failed"); + }
438-444:⚠️ Potential issue | 🟠 MajorReplace
.expect()with proper error handling.The
.expect()at line 442 can panic in production if the runtime fails to build. As per coding guidelines,.unwrap()and.expect()in production Rust code should be treated as major issues requiring proper error handling or explicit justification.Consider logging the error and returning early, or propagating the error if the
startmethod's signature can be changed to return aResult.Proposed fix (log and return)
let worker_handle = thread::spawn(move || { - let runtime = Builder::new_current_thread() + let runtime = match Builder::new_current_thread() .enable_all() .build() - .expect("failed to build runtime for truncator"); - runtime.block_on(worker.run()); + { + Ok(rt) => rt, + Err(err) => { + error!(error = ?err, "Failed to build runtime for truncator"); + return; + } + }; + runtime.block_on(worker.run()); });
🤖 Fix all issues with AI agents
In `@magicblock-ledger/src/ledger_truncator.rs`:
- Around line 284-286: The delete_slots call is handled by logging and
swallowing errors in one place but is propagated with ? inside
truncate_fat_ledger; make them consistent by changing truncate_fat_ledger to
catch the Result from Self::delete_slots(...) instead of using ?, log the error
with the same error!(error = ?err, "Delete failed") pattern, and continue, so
both call sites handle delete failures identically (refer to truncate_fat_ledger
and delete_slots to locate the change).
- Around line 283-286: The code advances the cleanup marker before attempting
deletions (ledger.set_lowest_cleanup_slot) which can leave slots marked cleaned
if Self::delete_slots fails; reorder the operations so that you first call
Self::delete_slots(ledger, from_slot, to_slot) and only on Ok(...) call
ledger.set_lowest_cleanup_slot(to_slot), or if you must keep the current order
implement error recovery by capturing the previous lowest value and restoring it
on Err(err) from Self::delete_slots; update the block around
ledger.set_lowest_cleanup_slot and Self::delete_slots accordingly and add a
short comment explaining the chosen approach.
magicblock-labs#924) Co-authored-by: Gabriele Picco <piccogabriele@gmail.com>
* master: hotfix: integration tests (#983) hotfix: integration tests (#982) chore: revert offset change (#981) fix: stop setting loaded accounts data size limit (#980) Fix: flaky ledger reset integration test (#977) Feat: tui interface for the validator (#972) fix: slack ready-for-review reviewer display (#978) fix: SetLoadedAccountsDataSize (#976) feat: add call_handler_v2 support for ScheduleIntentBundle actions (#946) feat: implement ephemeral accounts (#915) fix: prevent overrides on subscription updates (#970) fix: ignore error on delete in fat truncation. Case when the disk is … (#924)
…full, so delete fails
Summary
Compatibility
Testing
Checklist
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.