Skip to content

[Bug] Broker reconnect backoff has no jitter — every broker actor retries in lockstep after a broker restart #652

Description

@pathosDev

Problem

BrokerActor re-implements reconnect backoff by hand and without jitter: const delay = Math.min(initial * Math.pow(factor, this._reconnectAttempt - 1), maxDelay) (src/io/broker/BrokerActor.ts:566-586). DEFAULT_RECONNECT (src/io/broker/BrokerOptions.ts:63-68) has no jitter field.

Every broker actor on every node therefore retries in lockstep after a broker restart — textbook thundering herd. The framework already owns the fix 40 lines away: exponentialBackoff in src/pattern/BackoffPolicy.ts:56-77 has randomFactor (default 0.2) and an injectable random for deterministic tests.

Proposed behaviour

Delete the hand-rolled arithmetic; call exponentialBackoff({ minMs, maxMs, randomFactor }). Add reconnect.randomFactor to BrokerCommonOptionsType, readCommonOptions, BrokerOptionsValidator.commonRules and BrokerOptionsBuilder.withReconnect.

Acceptance criteria

  • Two actors started together do not retry at the same millisecond.
  • The random seam keeps the existing reconnect tests deterministic.

Related: #457, #458

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority: highTop priority — high impact, plan nextproduction-goalBlocks or defines the path to production readiness

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions