Commit fa956d8
fix: make committed offset accurate on partition assignment (confluentinc#893)
Cherry-pick of confluentinc#893 (author: sangreal).
Race condition in PartitionState: createOffsetAndMetadata() called
tryToEncodeOffsets() and getOffsetToCommit() separately. Between the
two calls, incompletes could drain, causing a higher offset to be
committed than intended. After rebalance, the consumer fetches a
non-existent offset and triggers auto.offset.reset (data loss or
replay).
Fix: tryToEncodeOffsets() now calls getOffsetToCommit() once at the
top and returns a Tuple<Optional<String>, Long> so the offset and
payload are computed atomically from the same state snapshot.
Upstream PR: confluentinc#893
Approved by Roman Kolesnev, run in production for >1 week.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 37e57fb commit fa956d8
1 file changed
Lines changed: 13 additions & 8 deletions
File tree
- parallel-consumer-core/src/main/java/io/confluent/parallelconsumer/state
Lines changed: 13 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
410 | 411 | | |
411 | 412 | | |
412 | 413 | | |
413 | | - | |
414 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
415 | 419 | | |
416 | 420 | | |
417 | 421 | | |
| |||
481 | 485 | | |
482 | 486 | | |
483 | 487 | | |
484 | | - | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
485 | 491 | | |
486 | 492 | | |
487 | | - | |
| 493 | + | |
488 | 494 | | |
489 | 495 | | |
490 | 496 | | |
491 | 497 | | |
492 | | - | |
493 | 498 | | |
494 | 499 | | |
495 | 500 | | |
496 | 501 | | |
497 | 502 | | |
498 | 503 | | |
499 | | - | |
| 504 | + | |
500 | 505 | | |
501 | | - | |
| 506 | + | |
502 | 507 | | |
503 | 508 | | |
504 | 509 | | |
505 | 510 | | |
506 | | - | |
| 511 | + | |
507 | 512 | | |
508 | 513 | | |
509 | 514 | | |
| |||
0 commit comments