Skip to content

hotfix: load failed intents on restart & reschedule#1371

Open
taco-paco wants to merge 1 commit into
masterfrom
hotfix/retry-failed-intents
Open

hotfix: load failed intents on restart & reschedule#1371
taco-paco wants to merge 1 commit into
masterfrom
hotfix/retry-failed-intents

Conversation

@taco-paco

@taco-paco taco-paco commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Loads failed intents on restart and reschedules them. Proper recovery is coming with introducion of outbox accounts following MIMD-0025

Breaking Changes

  • None
  • Yes — migration path described below

Test Plan

Summary by CodeRabbit

  • New Features

    • Recovery now loads and schedules eligible commit intents from persistence, including both pending and previously failed attempts.
    • Added support for retrieving failed commit records alongside existing pending records.
  • Bug Fixes

    • Improved recovery handling so recently failed commits can be retried when they fall within the recovery window.
    • Updated filtering and logging to better reflect commit intent recovery behavior.

@taco-paco taco-paco requested a review from GabrielePicco June 30, 2026 06:59
@taco-paco taco-paco marked this pull request as ready for review June 30, 2026 07:01
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change extends commit recovery to include failed (FailedFinalize, FailedProcess) commit status rows alongside pending ones. A new get_failed_commit_statuses(min_created_at) method is added to CommittsDb, the IntentPersister trait, IntentPersisterImpl, and the Option<T> blanket implementation. CommittorProcessor::pending_intent_bundles is renamed to load_recovery_intent_bundles and now aggregates both pending and failed rows before converting them into scheduled intent bundles. Internal helpers are renamed to remove the "pending" prefix. The CommittorActor message handler is updated to call the renamed method.

Suggested reviewers

  • GabrielePicco
  • snawaz
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/retry-failed-intents

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@magicblock-committor-service/src/committor_processor.rs`:
- Around line 183-185: The recovery path in committor_processor’s row loading is
incorrectly unioning separately filtered Pending and Failed* results, which can
reconstruct only part of a bundle for the same message_id. Update the logic
around self.persister.get_pending_commit_statuses and
self.persister.get_failed_commit_statuses so recovery eligibility is computed
once across the full recoverable-status set, then load all rows for eligible
message_ids together before passing them to rows_to_scheduled_intent_bundles.

In `@magicblock-committor-service/src/persist/commit_persister.rs`:
- Around line 264-272: The new recovery helper get_failed_commit_statuses
currently panics on a poisoned DB mutex via .expect(POISONED_MUTEX_MSG), which
violates the non-panicking persistence path requirement. Update
get_failed_commit_statuses in commit_persister.rs to handle the lock acquisition
failure explicitly by mapping it into a CommitPersistResult error instead of
aborting the committor. Reuse the existing CommitPersistResult and commits_db
access pattern used by the other persistence methods so the failure is reported
consistently, and only keep a panic if you add an explicit invariant comment
justifying it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8b5fee1a-dfd3-4ee9-9faa-e1be91cd721b

📥 Commits

Reviewing files that changed from the base of the PR and between 5e8a24a and df73ace.

📒 Files selected for processing (4)
  • magicblock-committor-service/src/committor_processor.rs
  • magicblock-committor-service/src/persist/commit_persister.rs
  • magicblock-committor-service/src/persist/db.rs
  • magicblock-committor-service/src/service.rs

Comment on lines +183 to +185
let mut rows =
self.persister.get_pending_commit_statuses(min_created_at)?;
rows.extend(self.persister.get_failed_commit_statuses(min_created_at)?);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Don't union independently filtered recovery rows.

Line 184 and Line 185 can recover a partial bundle. If one message_id has both Pending and Failed* rows with different created_at values, one query can include it while the other excludes it, and rows_to_scheduled_intent_bundles then rebuilds only the surviving subset of accounts. Compute recovery eligibility once across the full recoverable-status set and load all eligible rows together.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@magicblock-committor-service/src/committor_processor.rs` around lines 183 -
185, The recovery path in committor_processor’s row loading is incorrectly
unioning separately filtered Pending and Failed* results, which can reconstruct
only part of a bundle for the same message_id. Update the logic around
self.persister.get_pending_commit_statuses and
self.persister.get_failed_commit_statuses so recovery eligibility is computed
once across the full recoverable-status set, then load all rows for eligible
message_ids together before passing them to rows_to_scheduled_intent_bundles.

Comment on lines +264 to +272
fn get_failed_commit_statuses(
&self,
min_created_at: u64,
) -> CommitPersistResult<Vec<CommitStatusRow>> {
self.commits_db
.lock()
.expect(POISONED_MUTEX_MSG)
.get_failed_commit_statuses(min_created_at)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Avoid panicking on the DB mutex in this new method.

Line 270 uses .expect(POISONED_MUTEX_MSG), so a poisoned mutex aborts the committor instead of returning a persistence error from this recovery path. Please map the lock failure into CommitPersistResult or justify the panic invariant explicitly. As per path instructions, {magicblock-*,programs,storage-proto}/**: Treat any usage of .unwrap() or .expect() in production Rust code as a MAJOR issue.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@magicblock-committor-service/src/persist/commit_persister.rs` around lines
264 - 272, The new recovery helper get_failed_commit_statuses currently panics
on a poisoned DB mutex via .expect(POISONED_MUTEX_MSG), which violates the
non-panicking persistence path requirement. Update get_failed_commit_statuses in
commit_persister.rs to handle the lock acquisition failure explicitly by mapping
it into a CommitPersistResult error instead of aborting the committor. Reuse the
existing CommitPersistResult and commits_db access pattern used by the other
persistence methods so the failure is reported consistently, and only keep a
panic if you add an explicit invariant comment justifying it.

Source: Path instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants