Skip to content

fix: race/order violation of intents#1217

Open
taco-paco wants to merge 2 commits into
masterfrom
fix/intent-execution-manager
Open

fix: race/order violation of intents#1217
taco-paco wants to merge 2 commits into
masterfrom
fix/intent-execution-manager

Conversation

@taco-paco
Copy link
Copy Markdown
Contributor

@taco-paco taco-paco commented May 19, 2026

Summary

Replaced the per-item loop with try_for_each. On the first Full error, the failed item and all remaining items are collected and stored to DB atomically (std::iter::once(el).chain(iter)). Since try_send is synchronous there are no yield points between iterations, making the interleave impossible.

Breaking Changes

  • None
  • Yes — migration path described below

Test Plan

Summary by CodeRabbit

  • Refactor

    • Improved batch scheduling of intents to send more efficiently and handle channel backpressure by persisting remaining bundles when needed.
  • Documentation

    • Clarified database docstring describing retrieval of the oldest (first stored) intent bundle.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 88728c2e-6a68-4a2b-a0ac-b41a58a01d8e

📥 Commits

Reviewing files that changed from the base of the PR and between 7c83bb5 and 39afe4a.

📒 Files selected for processing (1)
  • magicblock-committor-service/src/intent_execution_manager.rs

📝 Walkthrough

Walkthrough

The PR refactors the IntentExecutionManager::schedule method to batch multiple overflowing intents into a single database persist operation. Previously, the method would iterate through intents with try_send and immediately persist only the first overflowing item. The updated implementation uses try_for_each to collect the current overflowing element plus all remaining intents into a leftovers vector, then persists the entire batch to the database via store_intent_bundles. A documentation clarification in the DB trait specifies that the "pop oldest intent bundle" operation returns the oldest (first stored) item rather than the one with the smallest id.

Suggested reviewers

  • snawaz
  • GabrielePicco
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/intent-execution-manager

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 and usage tips.

Copy link
Copy Markdown
Contributor

@Dodecahedr0x Dodecahedr0x left a comment

Choose a reason for hiding this comment

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

LGTM

@taco-paco taco-paco marked this pull request as ready for review May 19, 2026 07:27
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