davsclaus opened a new pull request, #24685:
URL: https://github.com/apache/camel/pull/24685

   ## Summary
   
   _Claude Code on behalf of davsclaus_
   
   Fixes the fourth bug reported in 
[CAMEL-23994](https://issues.apache.org/jira/browse/CAMEL-23994): 
`SyncCommitManager` and `AsyncCommitManager` stored `offset+1` in the offset 
repository, but `OffsetPartitionAssignmentAdapter.resumeFromOffset` adds `+1` 
when seeking (`state+1`). This double increment caused one message per 
partition to be lost on every restart when using an `offsetRepository`.
   
   **The round-trip before the fix:**
   - Record at offset 41 processed → repo stores 42 → on restart seeks to 
42+1=43 → record 42 is lost
   
   **After the fix:**
   - Record at offset 41 processed → repo stores 41 → on restart seeks to 
41+1=42 → correct
   
   **Changes:**
   - `SyncCommitManager`: save the raw record offset (`offset`) instead of 
`lastOffset` (offset+1) to the offset repository. The Kafka commit still 
correctly uses `offset+1` (Kafka convention).
   - `AsyncCommitManager`: save `committed offset - 1` (the raw record offset) 
to the repository instead of the already-incremented 
`OffsetAndMetadata.offset()`.
   - Updated `BaseManualCommitTestSupport` assertion from `"5"` to `"4"` to 
reflect the corrected stored value (last read offset, not next-to-read offset).
   
   Both managers now match the contract established by `CommitToOffsetManager` 
(which already stored the raw offset correctly) and the comment in 
`resumeFromOffset`: _"The state contains the last read offset, so you need to 
seek from the next one"_.
   
   **Bug present since:** CAMEL-18717 (Nov 2022).
   
   ## Test plan
   
   - [x] All 141 unit tests pass
   - [x] Updated `BaseManualCommitTestSupport` offset assertion to match new 
behavior
   - [ ] CI integration tests (`KafkaConsumerSyncWithOffsetRepoCommitIT`, 
`KafkaConsumerAsyncWithOffsetRepoCommitIT`) will validate the full round-trip
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   Co-Authored-By: Claude Opus 4.6 <[email protected]>


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to