[
https://issues.apache.org/jira/browse/RATIS-2722?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rui Wang updated RATIS-2722:
----------------------------
Description:
h2. Summary
Fix pending write capacity leak when leader rejects a client write in preAppend
(or otherwise fails appendLog before the request is queued).
h2. Problem
Leaders limit concurrent client writes with pending request quotas (element
count and approximate total message bytes). For each write, the server calls
tryAcquire to reserve capacity, then addPendingRequest once the entry is
appended and queued.
If the write fails after tryAcquire but before addPendingRequest, the
reservation was never released. Each failure permanently consumed quota even
though no request remained pending and the client already received an error.
After enough failures (e.g. repeated state-machine rejection in
preAppendTransaction), the leader still appeared healthy but new writes failed
with ResourceUnavailableException while the pending queue was empty.
h2. Root cause
PendingRequests.tryAcquire(Message) charges limits and registers a Permit in an
internal pre-queue map. Capacity is normally released when the request is
removed from the pending map after the client is replied to.
There was no release path when appendTransaction acquired a permit, then
state.appendLog(context) threw StateMachineException (including from
preAppendTransaction in the raft log). The code returned an error to the client
without calling releasePermit.
was:
h2. Summary
Fix pending write capacity leak when leader rejects a client write in preAppend
(or otherwise fails appendLog before the request is queued).
Problem
Leaders limit concurrent client writes with pending request quotas (element
count and approximate total message bytes). For each write, the server calls
tryAcquire to reserve capacity, then addPendingRequest once the entry is
appended and queued.
If the write fails after tryAcquire but before addPendingRequest, the
reservation was never released. Each failure permanently consumed quota even
though no request remained pending and the client already received an error.
After enough failures (e.g. repeated state-machine rejection in
preAppendTransaction), the leader still appeared healthy but new writes failed
with ResourceUnavailableException while the pending queue was empty.
Root cause
PendingRequests.tryAcquire(Message) charges limits and registers a Permit in an
internal pre-queue map. Capacity is normally released when the request is
removed from the pending map after the client is replied to.
There was no release path when appendTransaction acquired a permit, then
state.appendLog(context) threw StateMachineException (including from
preAppendTransaction in the raft log). The code returned an error to the client
without calling releasePermit.
> Fix pending write capacity leak when leader rejects a client write in
> preAppend
> -------------------------------------------------------------------------------
>
> Key: RATIS-2722
> URL: https://issues.apache.org/jira/browse/RATIS-2722
> Project: Ratis
> Issue Type: Improvement
> Reporter: Rui Wang
> Assignee: Rui Wang
> Priority: Major
>
> h2. Summary
> Fix pending write capacity leak when leader rejects a client write in
> preAppend (or otherwise fails appendLog before the request is queued).
> h2. Problem
> Leaders limit concurrent client writes with pending request quotas (element
> count and approximate total message bytes). For each write, the server calls
> tryAcquire to reserve capacity, then addPendingRequest once the entry is
> appended and queued.
> If the write fails after tryAcquire but before addPendingRequest, the
> reservation was never released. Each failure permanently consumed quota even
> though no request remained pending and the client already received an error.
> After enough failures (e.g. repeated state-machine rejection in
> preAppendTransaction), the leader still appeared healthy but new writes
> failed with ResourceUnavailableException while the pending queue was empty.
> h2. Root cause
> PendingRequests.tryAcquire(Message) charges limits and registers a Permit in
> an internal pre-queue map. Capacity is normally released when the request is
> removed from the pending map after the client is replied to.
> There was no release path when appendTransaction acquired a permit, then
> state.appendLog(context) threw StateMachineException (including from
> preAppendTransaction in the raft log). The code returned an error to the
> client without calling releasePermit.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)