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 removing in flight write operations when processing stable offset updates #8409

Merged
merged 7 commits into from
Jan 31, 2023

Conversation

mmaslankaprv
Copy link
Member

@mmaslankaprv mmaslankaprv commented Jan 25, 2023

The absl::btree_map::erase function erases all elements in range
[start, end) (end is exclusive). In current implementation the iterator
used to update the stable offset wasn't removed as only all the elements
preceding it were removed.

Fixed the problem by removing the iterator related with currently
processed in-flight update.

Fixes: #8091

Backports Required

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

UX Changes

Release Notes

Bug Fixes

  • fixed spurious batch parse error messages emitted while reading

src/v/storage/parser.cc Outdated Show resolved Hide resolved
_inflight.erase(_inflight.begin(), it);
_inflight.erase(_inflight.begin(), std::next(it));
Copy link
Member

Choose a reason for hiding this comment

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

Fixed the problem by removing the iterator related with currently
processed in-flight update.

this looks correct, but despite the commit message claiming this is a problem, it doesn't seem problematic (e.g. it would have conservative semantics, presumably). perhaps stating why/what problem is fixed would be useful for others looking at git-blame in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Of course, i will include detailed description but briefly the problem is when truncation happens. the hard flush from segment appender should flush all the in flights but it does not as there is always that one which is not deleted. This one in-flight entry has physical offset larger than all subsequent ones because of truncation but the logical offset is smaller. This allow the reader to read past the stable offset.

Copy link
Member

@dotnwat dotnwat Jan 26, 2023

Choose a reason for hiding this comment

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

This allow the reader to read past the stable offset.

this last part is unclear to me. if we are not removing an inflight request which otherwise could be removed, then wouldn't the affect of that be that a reader couldn't read as far as would otherwise be safe to?

Copy link
Member Author

Choose a reason for hiding this comment

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

i think the problem is a little bit more complex and the issue still exists however the EOF returned from reader input stream is handed differently.

In a situation when we have batches exceeding single inflight write size there are multiple in flight operations for the same offset, but the first one already updates stable offset <-- this is incorrect.

Copy link
Member Author

Choose a reason for hiding this comment

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

this PR doesn't include the actual fix as it does not postpone updating the stable offset until last in flight operation pending for that offset finishes. I need to add this.

Removing inflight operation changes a way how input stream is created and instead of hitting file EOF we hit its internal logical limit causing short read.

Copy link
Member

Choose a reason for hiding this comment

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

very interesting, thanks. gonna look at the reproducer

Copy link
Member Author

Choose a reason for hiding this comment

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

So i looked at this once again, the behavior looks correct, the EOF errors we saw are the normal behavior when reader reaches end of file.

When batch parser returns an error indicating that batch read was
unsuccessful the probe should be updated.

Signed-off-by: Michal Maslanka <[email protected]>
The `absl::btree_map::erase` function erases all elements in range
[start, end) (end is exclusive). In current implementation the iterator
used to update the stable offset wasn't removed as only all the elements
preceding it were removed.

Fixed the problem by removing the iterator related with currently
processed in-flight update.

Signed-off-by: Michal Maslanka <[email protected]>
@mmaslankaprv mmaslankaprv requested a review from andijcr January 31, 2023 14:23
@mmaslankaprv mmaslankaprv merged commit 5661a28 into redpanda-data:dev Jan 31, 2023
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.

CI Failure (context:parser::consume_records) in PartitionMoveInterruption.test_cancelling_partition_move
3 participants