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)

Reply via email to