cloud_storage: Prevent misaligned segment reuploads #12966
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For normal segment uploads and reuploads we have strict checks that disallow any modifications if they're not safe. The check is done by the
partition_manifest::safe_segment_meta_to_add
method. This method checks if the new segment "connects" with the previous one in case of new segment upload. For reuploads it checks if the segment is aligned with the manifest.For compacted reuploads this check was simplified because originally we had a feature that allowed compacted segment reupload to fill the gap in the manifest. So the reupload could potentially break the rule if the segment begins or ends in a gap. This feature is not needed now because the manifest can't have gaps anymore due to consistency checks described above. But because the check is not strict enough we may end up with the following situation:
When the first reupload is added to the manifest the second reupload is no longer aligned and can't be added. The new binary manifest format can't handle this situation and triggers assertion.
This PR removes reupload gap tests since they're no longer needed. It also updates the
safe_segment_meta_to_add
method to support compacted segments.Backports Required
Release Notes
Bug Fixes