Skip to content

HA: forwarded commands rejected with HTTP 401 'Invalid cluster token' around leader changes #9554

Closed

Description

@robfrank

Follow-up of #9547 ("Also seen in the same run" section, not investigated there).

During the #9547 HaChaosIT soak (seed -7841143843546363484, 3 nodes, all faults), node 1 logged forwarded commands that the leader rejected with HTTP 401 Invalid cluster token, around leader changes. The rejection surfaced through RaftReplicatedDatabase.forwardCommandToLeaderViaRaft -> reconstructLeaderException.

A forwarded command should never fail authentication because of a leader change. Possible causes to check:

  • the cluster token a node uses to forward is read from a stale or not-yet-initialized source while leadership moves;
  • the receiving node validates against a token it has not loaded yet (for example during an in-place restart or database replacement);
  • a 401 turned into a non-retryable client error, where a retry against the new leader would have succeeded.

The preserved logs of the #9547 run hold the occurrences. Replay command is in #9547.

Activity

  1. added this to the 26.11.1 milestone on Oct 9, 2026
  2. added
    ha
    on Oct 9, 2026
  3. added
    severity:major
    on Oct 9, 2026
  4. self-assigned this
    on Oct 9, 2026
  5. added
    in progress
    server
    on Oct 9, 2026
  6. added a commit that references this issue on Oct 9, 2026
  7. robfrank commented on Oct 9, 2026

    @robfrank
    CollaboratorAuthor

    Fixed by #9566. Nodes checked a peer's cluster token through the HA plugin, which had no usable token in two windows. At start, Ratis can already be elected leader (and receive forwarded commands) before the plugin registers itself, so the check fell back to the raw arcadedb.ha.clusterToken setting, which is empty when the token is derived. At stop, HA stops before the HTTP listener and dropped the token, so peers that still saw the node as leader got the same 401. The token is now found through the registered HA plugin when the usual lookup returns nothing, and the plugin keeps it after it stops. The snapshot download handler had its own copy of the lookup with the same defect and now shares the helper. A genuinely wrong token still gets a non-retryable 401, on purpose.

    The fix is complete for the cases in this issue. Not covered by an end-to-end test: the stop window (it is covered by a unit test).


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  8. removed
    in progress
    on Oct 9, 2026
  9. added a commit that references this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughaserverseverity:major

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions