Skip to content

fix(api-gateway): prevent rmb peer from wedging on failed (re)creation#2698

Merged
ashraffouda merged 1 commit into
mainfrom
fix-peer-creation
Jul 22, 2026
Merged

fix(api-gateway): prevent rmb peer from wedging on failed (re)creation#2698
ashraffouda merged 1 commit into
mainfrom
fix-peer-creation

Conversation

@ashraffouda

@ashraffouda ashraffouda commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Extract peer creation into spawnPeer(), which binds each peer to a fresh child context and retries NewPeer without cancelling that context on failure.

Both retry blocks previously created currentPeerCtx once and cancel()-ed it inside the retry on error. NewPeer starts its background goroutines only after all of its error paths, so a failed attempt has nothing to clean up while cancelling poisons the shared context: every subsequent retry (and the eventual live peer) then ran on an already-cancelled context and never received rmb calls until a manual restart.

Also unify the in-memory expiration to 6h on both the initial and the config-update reconnect paths (the reconnect path used 6*60 = 6 minutes with a misleading "1 hours" comment), and give each spawn its own backoff instead of sharing one instance across both paths.

Description

Describe the changes introduced by this PR and what does it affect

Changes

List of changes this PR includes

Related Issues

List of related issues

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring

Closes #2697

Extract peer creation into spawnPeer(), which binds each peer to a fresh
child context and retries NewPeer *without* cancelling that context on
failure.

Both retry blocks previously created currentPeerCtx once and cancel()-ed
it inside the retry on error. NewPeer starts its background goroutines
only after all of its error paths, so a failed attempt has nothing to
clean up while cancelling poisons the shared context: every subsequent
retry (and the eventual live peer) then ran on an already-cancelled
context and never received rmb calls until a manual restart.

Also unify the in-memory expiration to 6h on both the initial and the
config-update reconnect paths (the reconnect path used 6*60 = 6 minutes
with a misleading "1 hours" comment), and give each spawn its own
backoff instead of sharing one instance across both paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ashraffouda
ashraffouda merged commit 0ac0d53 into main Jul 22, 2026
24 checks passed
@ashraffouda
ashraffouda deleted the fix-peer-creation branch July 22, 2026 13:23
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.

api-gateway: peer startup backoff retries reuse a cancelled context and can never recover

2 participants