apoorvmittal10 opened a new pull request, #16274:
URL: https://github.com/apache/kafka/pull/16274

   The implementation for share-fetch `next-fetch-offset` in share partition 
and acquiring records from log.
   
   The Next Fetch Offset (NFO) determines where the Share Partition should 
initiate the next data read from the Replica Manager. While it typically aligns 
with the last offset of the most recently returned batch, last offset + 1, 
there are exceptions. Messages marked available again due to release 
acknowledgements or lock timeouts can cause the NFO to shift.
   
   The acquire method caches the batches as acquired in-memory and spawns a 
timer task for lock timeout.
   
   ### Cache
   1. `Per-offset Metadata`: Simple to implement but inefficient. Every offset 
requires in-memory storage and traversal, leading to high memory usage and 
processing overhead, especially for per-batch acknowledgements (mostly the way 
records would be acknowledged).
   
   2. `Per-Replica Fetch Batch`: This approach aligns with the Replica Manager 
fetch batches. Since a full Replica Manager batch is retrieved whenever the 
requested offset falls within that batch's boundaries, a single Share Fetch 
request will likely receive an entire Replica Manager batch. However, there's a 
trade-off. Replica Manager batches are based on producer batching. If producers 
don't batch effectively, the in-flight metadata becomes heavily reliant on the 
producer's batching behavior.
   
   For per-message acknowledgements, per-offset tracking will be necessary 
which again requires splitting in-flight batches based on state. Splitting 
bacthes is inefficient as it requires cache update wshich maintains sorted 
order. Therefore, we propose a hybrid approach:
   
   Implemented a combination of option 2 (per-in-flight batch tracking) with 
option 1 (per-offset tracking). This aligns well with Replica Manager batching.
   
   States shall be maintained per in-flight batch. If state inconsistencies 
arise within in-flight batches due to per-message acknowledgements, switch 
state tracking for the respective batch to option 1 (per-offset tracking).
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to