-
Notifications
You must be signed in to change notification settings - Fork 736
kafka: foundation for ListOffsets leader epoch fix (CORE-12505) #30347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nguyen-andrew
wants to merge
4
commits into
redpanda-data:dev
Choose a base branch
from
nguyen-andrew:listoffsets-fix-foundation
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e46818c
config: add enable_listoffsets_historical_leader_epoch dev property
nguyen-andrew 8f7b8e2
kafka: fix empty-partition timequery leader_epoch in ListOffsets
nguyen-andrew 05400a2
kafka: fix timequery-match leader_epoch in ListOffsets
nguyen-andrew 2dda91d
kafka: add TODO marker for ListOffsets earliest-path fix handoff
nguyen-andrew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| from rptest.services.rpk_consumer import RpkConsumer | ||
| from rptest.tests.redpanda_test import RedpandaTest | ||
| from rptest.util import wait_until_result | ||
| from ducktape.mark import parametrize | ||
|
|
||
|
|
||
| # --- ListOffsets v4 (API key 2) --- | ||
|
|
@@ -371,14 +372,20 @@ def _get_committed(self, cluster, group, topic, partition): | |
|
|
||
| return (-1, -1) | ||
|
|
||
| def _test_list_offsets_epoch(self, cluster, expect_incorrect_behavior): | ||
| def _test_list_offsets_epoch( | ||
| self, cluster, expect_incorrect_earliest, expect_incorrect_timequery | ||
| ): | ||
| """Verify ListOffsets returns the correct leader epoch for each | ||
| timestamp query type. | ||
|
|
||
| All records are produced before leadership is transferred 3 | ||
| times. The earliest and timequery paths should return the | ||
| initial epoch (the record epoch), while the latest path should | ||
| return the current leader epoch (correct per Kafka). | ||
|
|
||
| Earliest and timequery are gated by separate flags because | ||
| Redpanda's partial fix (CORE-12505) addresses timequery before | ||
| earliest — the earliest-path lookup ships in a follow-up. | ||
| """ | ||
| initial_epoch, current_epoch = self._setup_topic_with_epoch_gap(cluster) | ||
|
|
||
|
|
@@ -387,7 +394,7 @@ def _test_list_offsets_epoch(self, cluster, expect_incorrect_behavior): | |
| self.logger.info( | ||
| f"Earliest: offset={offset}, epoch={epoch}, current_epoch={current_epoch}" | ||
| ) | ||
| if expect_incorrect_behavior: | ||
| if expect_incorrect_earliest: | ||
| assert epoch == current_epoch, ( | ||
| f"Bug expected: earliest epoch should be current " | ||
| f"({current_epoch}), got {epoch}" | ||
|
|
@@ -415,7 +422,7 @@ def _test_list_offsets_epoch(self, cluster, expect_incorrect_behavior): | |
| self.logger.info( | ||
| f"Timequery: offset={offset}, epoch={epoch}, current_epoch={current_epoch}" | ||
| ) | ||
| if expect_incorrect_behavior: | ||
| if expect_incorrect_timequery: | ||
| assert epoch == current_epoch, ( | ||
| f"Bug expected: timequery epoch should be current " | ||
| f"({current_epoch}), got {epoch}" | ||
|
|
@@ -637,13 +644,36 @@ def _apply_throwaway_hack(self, real_group, throwaway_group, topic, partition): | |
| ) | ||
|
|
||
| @cluster(num_nodes=3) | ||
| def test_list_offsets_epoch(self): | ||
| self._test_list_offsets_epoch(self.redpanda, expect_incorrect_behavior=True) | ||
| @parametrize(correct_epoch=False) | ||
| @parametrize(correct_epoch=True) | ||
| def test_list_offsets_epoch(self, correct_epoch): | ||
| if correct_epoch: | ||
| # enable_listoffsets_historical_leader_epoch is gated as a | ||
| # development feature; opt in to dev features before flipping it. | ||
| self.redpanda.enable_development_feature_support() | ||
| self.redpanda.set_cluster_config( | ||
| {"enable_listoffsets_historical_leader_epoch": True} | ||
| ) | ||
| self._test_list_offsets_epoch( | ||
| self.redpanda, | ||
| expect_incorrect_earliest=True, # earliest still buggy until follow-up PR | ||
| expect_incorrect_timequery=not correct_epoch, | ||
| ) | ||
|
|
||
| @cluster(num_nodes=3) | ||
| def test_list_offsets_epoch_empty_partition(self): | ||
| @parametrize(correct_epoch=False) | ||
| @parametrize(correct_epoch=True) | ||
| def test_list_offsets_epoch_empty_partition(self, correct_epoch): | ||
| if correct_epoch: | ||
| # enable_listoffsets_historical_leader_epoch is gated as a | ||
| # development feature; opt in to dev features before flipping it. | ||
| self.redpanda.enable_development_feature_support() | ||
| self.redpanda.set_cluster_config( | ||
| {"enable_listoffsets_historical_leader_epoch": True} | ||
| ) | ||
| self._test_empty_partition_list_offsets_epoch( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing coverage for earliest/latest queries with empty partition? These return leader_epoch()
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| self.redpanda, expect_incorrect_behavior=True | ||
| self.redpanda, | ||
| expect_incorrect_behavior=not correct_epoch, | ||
| ) | ||
|
|
||
| @cluster(num_nodes=4) | ||
|
|
@@ -860,7 +890,11 @@ def _restart_leader(self, cluster, topic, partition): | |
| @ducktape_cluster(num_nodes=4) | ||
| def test_list_offsets_epoch(self): | ||
| # Kafka defines the correct behavior we compare against. | ||
| self._test_list_offsets_epoch(self.kafka, expect_incorrect_behavior=False) | ||
| self._test_list_offsets_epoch( | ||
| self.kafka, | ||
| expect_incorrect_earliest=False, | ||
| expect_incorrect_timequery=False, | ||
| ) | ||
|
|
||
| @ducktape_cluster(num_nodes=4) | ||
| def test_list_offsets_epoch_empty_partition(self): | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should error out if topic_cfg is missing. Suggest making is_rr an optional and use it in the per partition conditional below
Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I added a check for topic_cfg in the existing per-partition not-found branch. After that point, we can use
is_read_replicaas a plainbool.