Skip to content

POST /api/v1/cluster/leader: NPE (500) on missing body, and success response when leadership did not actually transfer #5276

Closed

Description

@ruispereira

Two small bugs in the leadership-transfer management endpoint, hit while applying the #4696 workaround on 26.8.1-SNAPSHOT (full context in #5268):

  1. Missing body → NPE → 500. POST /api/v1/cluster/leader with an empty body returns a bare 500 Internal Server Error; server side logs:

    SEVER [PostTransferLeaderHandler] Error on command execution (PostTransferLeaderHandler):
      Cannot invoke "com.arcadedb.serializer.json.JSONObject.getString(String, String)" because "payload" is null
    

    Expected: 400 Bad Request with a message describing the required body ({"target": "<peerId>"}).

  2. False success. With a valid body ({"target": "<peer-id of a healthy, up-to-date follower>"}) the endpoint returned {"result":"Leadership transferred"} — but leadership never moved: the incumbent logged Leader churn: ... re-elected (term=4) seconds later and stayed leader; the target never became leader. The handler appears to report the transfer request as success rather than the transfer outcome. Expected: either wait/verify and report the actual outcome, or return an explicitly asynchronous "transfer initiated" response.

(In our case the target follower was HEALTHY with replicationLag 0, so eligibility wasn't the obvious explanation — but if the transfer was rejected for eligibility reasons, that rejection was also invisible to both the caller and the log.)

Activity

  1. ruispereira commented on Jul 14, 2026

    @ruispereira
    ContributorAuthor

    Related observation from a successful internal transfer during bootstrap (same snapshot build): the confirmation path logged RaftClusterManager: Leadership transferred to ... (confirmed after IOException) — i.e. even when the transfer succeeds, the manager appears to detect it by catching an IOException from the old channel rather than by a positive acknowledgement. Consistent with the false-success in this report: the outcome detection is indirect on both paths.

  2. self-assigned this
    on Jul 14, 2026
  3. added theissue type on Jul 14, 2026
  4. added this to the 26.8.1 milestone on Jul 14, 2026
  5. added a commit that references this issue on Jul 14, 2026
  6. lvca commented on Jul 14, 2026

    @lvca
    Member

    Fixed in main (commit 537db5a), shipping in 26.8.1.

    Both bugs are fixed, and we found a third that explains your "false success": the endpoint expects the field peerId, and your {"target": ...} was silently ignored - so the request was executed as "transfer to any peer", Ratis picked its own candidate, and leadership bounced back to the incumbent while the response reported success.

    Now:

    • a missing body returns 400 with the expected format ({"peerId": "<peer-id>", "timeoutMs": <ms, optional>}, or {} to let the cluster pick the target);
    • an unrecognized field returns 400 naming it, instead of being silently ignored;
    • a successful transfer response includes the confirmed leaderId, so you can verify the outcome instead of trusting a success string.

    ❤️ 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.

  7. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions