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

archival: start reupload range after log start #14816

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

andrwng
Copy link
Contributor

@andrwng andrwng commented Nov 8, 2023

After a delete-records request, when collecting segments to determine the next upload candidate, we could end up trying to build an upload candidate with a start offset lower than the local log. Consider the following sequence:

  • Segment [0, 200)[200-400) are merge compacted ==> [0, 400).
  • Delete records ==> start offset is now 1.
  • Reupload our first compacted segment so we look up offset 1, realign the collection start target to a remote segment 200.
  • We collect segments starting from 200, getting [0, 400).
  • Collector gets realigned to 0 since it's the first segment. The collector now thinks it should be uploading [0, 400).
  • In building the upload candidate, we try to translate the range start and fail because the range start 0 is lower than the translation range start 1.

This fixes this sequence to return [200, 400) as the start of the upload candidate.

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
  • v23.2.x
  • v23.1.x
  • v22.3.x

Release Notes

Bug Fixes

  • Fixes a bug in segment reupload that could cause the operation to fail after a delete-records request.

After a delete-records request, when collecting segments to determine
the next upload candidate, we could end up trying to build an upload
candidate with a start offset lower than the local log. Consider the
following sequence:

- Segment [0, 200)[200-400) are merge compacted ==> [0, 400).
- Delete records ==> start offset is now 1.
- Reupload our first compacted segment so we look up offset 1, realign the
  collection start target to a remote segment 200.
- We collect segments starting from 200, getting [0, 400).
- Collector gets realigned to 0 since it's the first segment. The collector now
  thinks it should be uploading [0, 400).
- In building the upload candidate, we try to translate the range start and
  fail because the range start 0 is lower than the translation range start 1.

This fixes this sequence to return [200, 400) as the start of the upload
candidate.
@vbotbuildovich
Copy link
Collaborator

@dotnwat dotnwat self-requested a review November 8, 2023 06:09
@abhijat
Copy link
Contributor

abhijat commented Nov 8, 2023

The change makes sense to me but I don't quite follow the scenario listed in the PR description:

We collect segments starting from 200, getting [0, 400).

wouldn't we only get the second segment if we start collecting at 200?

@andrwng
Copy link
Contributor Author

andrwng commented Nov 8, 2023

wouldn't we only get the second segment if we start collecting at 200?

In this case, our local log only has segment [0, 400) since [0, 200)[200, 400) have been compacted, so only [0, 400) is available to be collected

@andrwng andrwng self-assigned this Nov 8, 2023
@andrwng
Copy link
Contributor Author

andrwng commented Nov 8, 2023

CI failure: #13787

@andrwng andrwng merged commit 7b2facf into redpanda-data:dev Nov 8, 2023
25 checks passed
@vbotbuildovich
Copy link
Collaborator

/backport v23.2.x

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.

good stuffs

@@ -1039,6 +1040,87 @@ SEASTAR_THREAD_TEST_CASE(test_do_not_reupload_self_concatenated) {
}
}

SEASTAR_THREAD_TEST_CASE(test_do_not_reupload_prefix_truncated) {
Copy link
Member

Choose a reason for hiding this comment

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

🙇

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.

4 participants