[
https://issues.apache.org/jira/browse/RATIS-2849?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tsz-wo Sze updated RATIS-2849:
------------------------------
Attachment: 1721_review.patch
> Concurrent StartLeaderElection RPCs collide in Netty's pending-reply map
> ------------------------------------------------------------------------
>
> Key: RATIS-2849
> URL: https://issues.apache.org/jira/browse/RATIS-2849
> Project: Ratis
> Issue Type: Bug
> Components: election, Netty
> Reporter: Ivan Andika
> Assignee: Ivan Andika
> Priority: Major
> Attachments: 1721_review.patch
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> `StartLeaderElection` requests and replies previously left the RPC call ID at
> protobuf's default value of zero. Leadership transfer can send an immediate
> request and another request from an AppendEntries reply before the first
> response arrives.
> With Netty, both requests then occupy the same pending-reply slot.
> Integration CI exposed the resulting pending-request assertion in
> `testTransferLeader`.
> h2. Reproduction
> 1. Start a leadership transfer to a follower using Netty RPC.
> 2. Delay the first `StartLeaderElection` response.
> 3. Allow another transfer-triggered `StartLeaderElection` request to the same
> follower while the first remains pending.
> 4. Observe that both requests use call ID 0 and collide in the pending-reply
> map.
> The focused regressions avoid scheduling dependence: construct two requests
> and require distinct call IDs, then feed an explicit nonzero call ID through
> every election-handler outcome and require the reply to echo it.
> h2. Expected behavior
> Concurrent requests must have distinct call IDs, and every successful or
> rejected response must preserve its request's ID so the transport can
> complete the correct pending RPC.
> h2. Root cause
> The request builder omitted call-ID allocation, unlike `RequestVote`. Reply
> construction also omitted propagation of the request's ID on both acceptance
> and rejection paths.
> h2. Proposed fix
> Allocate request IDs using the shared `CallId` allocator and propagate the
> original ID through all `StartLeaderElection` reply paths.
> h2. Compatibility consideration
> Older Netty receivers still return call ID zero. They cannot correctly
> correlate a new nonzero-ID request with its response. Both endpoints need the
> fix for reliable replies with this patch, or the final upstream change needs
> an explicit mixed-version compatibility strategy. The gRPC unary path does
> not use Netty's pending-reply map.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)