Skip to content
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

kafka: fix timequery failing for empty topics #19937

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

nvartolomei
Copy link
Contributor

@nvartolomei nvartolomei commented Jun 20, 2024

This bug was introduced accidentally while trying to fix another off-by-one bug in commit ref 8f2de96. I forgot to account that for an empty topic the "start offset" is equal to "last offset" so calling model::prev_offset would result in an offset below the start which is invalid and throws an exception if passed downstream.

To avoid the problem, we short-circuit with a "offset not found" response straight away if that's the case.

8f2de96

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v24.1.x
  • v23.3.x
  • v23.2.x

Release Notes

Bug Fixes

  • Fix timequery failing with exceptions when the queried partition is empty.

@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Jun 20, 2024

@nvartolomei
Copy link
Contributor Author

Failures unrelated:

Lazin
Lazin previously approved these changes Jun 21, 2024
auto min_offset = kafka_partition->start_offset();
auto max_offset = model::prev_offset(offset);

// Empty topic.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: empty partition

@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Jun 21, 2024

new failures in https://buildkite.com/redpanda/redpanda/builds/50492#019039a7-e1c9-4c3d-bde6-ae8fd8a700b3:

"rptest.tests.raft_availability_test.RaftAvailabilityTest.test_leadership_transfer"

new failures in https://buildkite.com/redpanda/redpanda/builds/50492#019039fe-e358-42eb-9329-96e673999845:

"rptest.tests.scaling_up_test.ScalingUpTest.test_moves_with_local_retention.use_topic_property=True"

WillemKauf
WillemKauf previously approved these changes Jun 21, 2024
This bug was introduced accidentally while trying to fix another
off-by-one bug in commit ref 8f2de96. I
forgot to account that for an empty topic the "start offset" is equal to
"last offset" so calling `model::prev_offset` would result in an offset
below the start which is invalid and throws an exception if passed
downstream.

To avoid the problem, we short-circuit with a "offset not found" response
straight away if that's the case.

redpanda-data@8f2de96
@nvartolomei nvartolomei dismissed stale reviews from WillemKauf and Lazin via 1a080ee June 21, 2024 13:03
@nvartolomei nvartolomei force-pushed the nv/timequery-emtpy-topic branch from 3e11d09 to 1a080ee Compare June 21, 2024 13:03
@nvartolomei
Copy link
Contributor Author

Force-pushed to add a new test case where the topic is empty as a result of trim-prefix command. Also rebased.

Forgot to re-enable after fixing a bunch of timequery bugs.
Comment on lines +138 to +142
co_return list_offsets_response::make_partition(
ktp.get_partition(),
model::timestamp(-1),
model::offset(-1),
kafka_partition->leader_epoch());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to push this check into cluster::partition too / instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to refactor this to use the bounded interval. Need to make it support Kafka offsets too first iirc.

Will merge it like this for now to make progress on the backports and will try to clean it up in a separate PR.

thanks for pointing it out!

@nvartolomei nvartolomei merged commit 656db4a into redpanda-data:dev Jun 21, 2024
19 checks passed
@vbotbuildovich
Copy link
Collaborator

/backport v24.1.x

@vbotbuildovich
Copy link
Collaborator

/backport v23.3.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants