You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Shekhar Prasad Rajak (Jira)" <ji...@apache.org> on 2026/09/15 05:36:00 UTC

[jira] [Created] (KAFKA-21097) Avoid duplicate share-partition next-fetch offset scans

Shekhar Prasad Rajak created KAFKA-21097:
--------------------------------------------

             Summary: Avoid duplicate share-partition next-fetch offset scans
                 Key: KAFKA-21097
                 URL: https://issues.apache.org/jira/browse/KAFKA-21097
             Project: Kafka
          Issue Type: Improvement
          Components: core
            Reporter: Shekhar Prasad Rajak
            Assignee: Shekhar Prasad Rajak


Current flow : 

 DelayedShareFetch acquires the share-partition fetch lock, calls canAcquireRecords(), then calls nextFetchOffset() to build the log read.
  canAcquireRecords() already calls nextFetchOffset(), so a partition with released or timed-out records can scan cachedState and per-offset state twice
  under the write lock for one fetch.

 

 Proposed flow

  Add one atomic nextFetchOffsetIfAcquirable() call. Under one lock, it computes the next fetch offset once and decides whether the partition can fetch due
  to available redelivery records or remaining in-flight capacity. DelayedShareFetch uses that returned offset directly.

  This removes the duplicate scan and lock gap without changing share-record state transitions or introducing a new availability index.

 



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