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

Fixed assertion triggered when fetching from empty topics with transactions enabled #3159

Merged
merged 5 commits into from
Dec 6, 2021

Conversation

mmaslankaprv
Copy link
Member

Cover letter

It may happen that last stable offset is equal to log start offset.
In this case when consumer requests a read with a read_committed
isolation level it should receive no batches since the log is empty.
Otherwise when records are present in the log we need to read up to
LSO-1 since batch pointed by LSO is the first offset for which
transactions may not be resolved.

Added explicit check to partition read code path to return fast
when requested max offset is smaller than start offset indicating no
data should be returned.

@@ -134,7 +134,9 @@ static ss::future<read_result> read_from_partition(
auto lso = part.last_stable_offset();
auto start_o = part.start_offset();
// if we have no data read, return fast
if (hw < config.start_offset || config.skip_read) {
if (
hw < config.start_offset || config.skip_read
Copy link
Contributor

Choose a reason for hiding this comment

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

test for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

added ducktape test, took me some time to reproduce this

@mmaslankaprv mmaslankaprv modified the milestones: v21.10.3, v21.11.1 Dec 5, 2021
It may happen that last stable offset is equal to log start offset.
In this case when consumer requests a read with a `read_committed`
isolation level it should receive no batches since the log is empty.
Otherwise when records are present in the log we need to read up to
LSO-1  since batch pointed by LSO is the first offset for which
transactions may not be resolved.

Added explicit check to partition read code path to return fast
when requested max offset is smaller than start offset indicating no
data should be returned.

Signed-off-by: Michal Maslanka <michal@vectorized.io>
…verity

When using trace log severity we should log more info to facilitate
Fetch request debugging. The same level of logging is used in produce
request, fetch handler is now consistent.

Signed-off-by: Michal Maslanka <michal@vectorized.io>
Signed-off-by: Michal Maslanka <michal@vectorized.io>
Signed-off-by: Michal Maslanka <michal@vectorized.io>
Signed-off-by: Michal Maslanka <michal@vectorized.io>

def consume(n=1):

out = rpk.consume(self.topic, group=consumer_group, n=n)
Copy link
Contributor

Choose a reason for hiding this comment

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

rpk now supports -f '%o'\n if you want to have offsets printed with newlines.

@mmaslankaprv mmaslankaprv modified the milestones: v21.10.3, v21.11.1 Dec 6, 2021
Copy link
Member

@dotnwat dotnwat left a comment

Choose a reason for hiding this comment

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

lgtm.

Can you add an explanation of how this is related to transactions? transactions is in the PR title, but there doesn't seem to be any connection with transactions in the code nor the commit messages.

EDIT: just realized I missed since batch pointed by LSO is the first offset for which transactions may not be resolved.

All good!

@mmaslankaprv mmaslankaprv merged commit b7289cb into redpanda-data:dev Dec 6, 2021
dotnwat added a commit that referenced this pull request Dec 7, 2021
dotnwat added a commit that referenced this pull request Dec 7, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment