fix: retry failed program subscriptions#1268
Conversation
📝 WalkthroughWalkthroughThis PR improves subscription retry logic across program subscription paths by ensuring in-memory state remains consistent when subscription operations fail. Mock factories ( 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai resume |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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-chainlink/src/submux/mod.rs`:
- Around line 1074-1078: The code currently calls .lock().expect("program_subs
lock poisoned") on program_subs which can panic; change this to handle
PoisonError and propagate it to the caller instead of panicking—acquire the
mutex with self.program_subs.lock() and map any PoisonError into your function's
Result (or a dedicated error variant) before calling .insert(program_id), e.g.,
use match or .map_err(|e| /* convert e */)? to convert the poison into an Err
return so insert is only called on a successful lock; update the function
signature to return Result if needed and follow the same error conversion
pattern used elsewhere for mutex poisoning.
🪄 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: 7863f2f3-aa69-4f4c-98aa-83890882405b
📒 Files selected for processing (4)
magicblock-chainlink/src/remote_account_provider/chain_laser_actor/mock.rsmagicblock-chainlink/src/remote_account_provider/chain_laser_actor/stream_manager.rsmagicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rsmagicblock-chainlink/src/submux/mod.rs
✅ Actions performedReviews resumed. |
GabrielePicco
left a comment
There was a problem hiding this comment.
LGTM in general, but I believe this introduce a reconnect race that can leave a reconnected client missing the program subscription. Should be fixed before merging
* master: chore: simplify, rename out_of_order_slot and add a comment (#1284) fix: execute post-delegation actions after clone (#1278) Handle oversized single-stage committor transactions (#1277) Reduce committor RPC confirmation calls (#1271) fix: preserve streams on optimize failure (#1273) perf: reduce TableMania ALT polling (#1276) feat: bundle session-key program in mb-test-validator (#1275) fix: limit pending intent recovery window (#1274)
Amp-Thread-ID: https://ampcode.com/threads/T-019e912c-faaf-76be-8755-7bd5a045af53 Co-authored-by: Amp <amp@ampcode.com>
2fb5dd2 to
fd10fed
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
magicblock-chainlink/src/remote_account_provider/chain_laser_actor/mock.rs (1)
205-208:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAvoid panic in mock subscribe when write-failure injection is enabled.
Line 207 unwraps
handle.write(request). Withfail_next_handle_writes(n), this path can now panic instead of returning an error, which breaks intended retry/failure-path testing.Suggested fix
- handle.write(request).await.unwrap(); + handle.write(request).await.map_err(|err| { + RemoteAccountProviderError::GrpcSubscriptionUpdateFailed( + "mock subscribe".to_string(), + 0, + err.to_string(), + ) + })?;🤖 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-chainlink/src/remote_account_provider/chain_laser_actor/mock.rs` around lines 205 - 208, The mock subscribe currently uses handle.write(request).await.unwrap(), which can panic when fail_next_handle_writes(n) injects write failures; change this to propagate the write error instead of panicking by handling the Result from handle.write(request).await and returning Err(...) (or forwarding with ? ) from the subscribe implementation so tests exercise retry/failure paths; update the subscribe/mock function around the handle.write(request).await call (and any surrounding return type) to return a proper Result and propagate the write error rather than calling unwrap.
🤖 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.
Outside diff comments:
In `@magicblock-chainlink/src/remote_account_provider/chain_laser_actor/mock.rs`:
- Around line 205-208: The mock subscribe currently uses
handle.write(request).await.unwrap(), which can panic when
fail_next_handle_writes(n) injects write failures; change this to propagate the
write error instead of panicking by handling the Result from
handle.write(request).await and returning Err(...) (or forwarding with ? ) from
the subscribe implementation so tests exercise retry/failure paths; update the
subscribe/mock function around the handle.write(request).await call (and any
surrounding return type) to return a proper Result and propagate the write error
rather than calling unwrap.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: f90637b7-d9b4-4533-868f-72996fd709eb
📒 Files selected for processing (3)
magicblock-chainlink/src/remote_account_provider/chain_laser_actor/mock.rsmagicblock-chainlink/src/remote_account_provider/chain_laser_actor/stream_manager.rsmagicblock-chainlink/src/submux/mod.rs
* master: fix: reject short account responses (#1290) fix: wait for pubsub listeners before reconnect (#1253) fix: retry failed program subscriptions (#1268) release: 0.12.0 (#1299) Ignore compute unit price in processor fees (#1298) Recover recent pending intents on restart (#1296) chore: adjust log level (#1297) release: v0.11.4 (#1292) fix(scheduler): remove block subscription in the scheduler (#1293) fix(committor): race-condition on cleanup (#1291) Handle ALT extend invalid instruction data (#1287) fix: use provided compute limits instead of defaults (#1289) feat: snapshot accountsdb even in the replica mode (#1282) feat: added vrf ephemeral test queue, delegation record and metadata for mb-test-validator (#1281) fix: use wire size (1232), not encoded size (1644), for tx fit checks! (#1285) chore: simplify, rename out_of_order_slot and add a comment (#1284) fix: execute post-delegation actions after clone (#1278) Handle oversized single-stage committor transactions (#1277) Reduce committor RPC confirmation calls (#1271) fix: preserve streams on optimize failure (#1273)
* master: fix: reject short account responses (#1290) fix: wait for pubsub listeners before reconnect (#1253) fix: retry failed program subscriptions (#1268) release: 0.12.0 (#1299) Ignore compute unit price in processor fees (#1298) Recover recent pending intents on restart (#1296) chore: adjust log level (#1297) release: v0.11.4 (#1292) fix(scheduler): remove block subscription in the scheduler (#1293) fix(committor): race-condition on cleanup (#1291) Handle ALT extend invalid instruction data (#1287) fix: use provided compute limits instead of defaults (#1289) feat: snapshot accountsdb even in the replica mode (#1282) feat: added vrf ephemeral test queue, delegation record and metadata for mb-test-validator (#1281) fix: use wire size (1232), not encoded size (1644), for tx fit checks! (#1285)
Summary
Fix program subscription bookkeeping so transient subscription failures remain retryable instead of being recorded as successful locally.
Details
magicblock-chainlink
Summary by CodeRabbit
Bug Fixes
Tests