You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Rui Wang (Jira)" <ji...@apache.org> on 2026/10/01 06:21:00 UTC

[jira] [Created] (RATIS-2722) PreAppend fails should release the acquired resources

Rui Wang created RATIS-2722:
-------------------------------

             Summary: PreAppend fails should release the acquired resources
                 Key: RATIS-2722
                 URL: https://issues.apache.org/jira/browse/RATIS-2722
             Project: Ratis
          Issue Type: Improvement
            Reporter: Rui Wang
            Assignee: Rui Wang


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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)