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

[v23.3.x] Fix/inconsistent flushed offset #16501

Merged

Conversation

vbotbuildovich
Copy link
Collaborator

Backport of PR #16105
Fixes: #16500,

add extra logging to flush and truncate methods

(cherry picked from commit 1aef8ff)
Method returns the counter which is guaranteed to be incremented after
suffix truncation. It's not guaranteed to be incremented exactly once
per logical truncation. It can only be used to detect that truncation
actually happened.

(cherry picked from commit 8d781ab)
Use get_log_truncation_counter method in read_write_truncate test.

(cherry picked from commit 6a86a83)
Use get_truncation_counter method in write_truncate_compact method.

(cherry picked from commit af0e2c2)
The 'flush_log' method checks the dirty offset before and after flush.
If the truncation happened concurrently it detects this by comparing
offsets (the offset after flush is smaller than the offset before the
flush in this case). Then it uses assertion to check if the flushed
offset is not smaller than the committed offset.

This may not work as expected in case if there is a concurrent
truncation and append. For instance, before the truncation the dirty
offset is 32. The 'flush_log' method records flushed offset 32 and calls
log->flush. Before 'flush_log' is resumed the log gets truncated and
then new value gets added. So the committed offset of the log is now 31
but dirty offset is 32. Because of that the method won't be able to
detect the concurrent flush operation will trigger an assertion.

This commit fixes this problem by checking not only dirty offset but
also a truncation counter. If the counter was incremented then the
log was truncated and new data was added to the end of the log.

(cherry picked from commit 8a4b612)
@vbotbuildovich vbotbuildovich added this to the v23.3.x-next milestone Feb 6, 2024
@vbotbuildovich vbotbuildovich added the kind/backport PRs targeting a stable branch label Feb 6, 2024
@Lazin Lazin merged commit a03a4d4 into redpanda-data:v23.3.x Feb 6, 2024
18 checks passed
@piyushredpanda piyushredpanda modified the milestones: v23.3.x-next, v23.3.5 Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/redpanda kind/backport PRs targeting a stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants