Commit 78061b8
If the partition count or kafka IO size is large, then skip committin… (#37510)
* If the partition count or kafka IO size is large, then skip committing offsets that are not changed. Reduce kafka commit load
* Address PR review feedback for idle partition optimization
- Refactor commitCheckpointMark to use Java streams (per @johnjcasey)
Changed from explicit for-loop to streams-based filtering for better
code consistency with existing patterns
- Add debug logging for idle partitions (per @tomstepp)
Log the count of idle partitions skipped during each commit to aid
in monitoring and debugging the optimization
- Implement time-based periodic commits (per @tomstepp)
Track last commit time per partition and ensure commits happen at
least every 10 minutes even for idle partitions. This supports time
lag monitoring use cases where customers track time since last commit.
- Add unit test for idle partition behavior (per @tomstepp)
New test KafkaUnboundedReaderIdlePartitionTest verifies that:
* Idle partitions are not committed repeatedly
* Active partitions trigger commits correctly
* Uses mock consumer to track commit calls
All changes maintain backward compatibility and follow Apache Beam
coding standards (spotless formatting applied).
* Fix test to follow Beam patterns for MockConsumer initialization
Rewrote KafkaUnboundedReaderIdlePartitionTest to follow the exact
pattern used in KafkaIOTest.java:
- Proper MockConsumer initialization with partition metadata
- Correct setup of beginning/end offsets
- Consumer records with proper offsets and timestamps
- schedulePollTask for record enqueueing based on position
- Override commitSync to track commit calls
- Use reader.start() before reader.advance()
This ensures the test properly initializes the Kafka consumer and
doesn't fail with IllegalStateException during source.split().
---------
Co-authored-by: Kishore Pola <kpola@paloaltonetworks.com>1 parent 927ee2c commit 78061b8
2 files changed
Lines changed: 361 additions & 29 deletions
File tree
- sdks/java/io/kafka/src
- main/java/org/apache/beam/sdk/io/kafka
- test/java/org/apache/beam/sdk/io/kafka
Lines changed: 88 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
| |||
375 | 381 | | |
376 | 382 | | |
377 | 383 | | |
| 384 | + | |
| 385 | + | |
378 | 386 | | |
379 | 387 | | |
380 | 388 | | |
| |||
611 | 619 | | |
612 | 620 | | |
613 | 621 | | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
618 | 625 | | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
627 | 697 | | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
645 | 704 | | |
646 | 705 | | |
647 | 706 | | |
| |||
0 commit comments