branch-4.1: [fix](cloud) fix segment footer CORRUPTION not triggering file cache retry #61386#61426
Open
github-actions[bot] wants to merge 1 commit intobranch-4.1from
Open
branch-4.1: [fix](cloud) fix segment footer CORRUPTION not triggering file cache retry #61386#61426github-actions[bot] wants to merge 1 commit intobranch-4.1from
github-actions[bot] wants to merge 1 commit intobranch-4.1from
Conversation
…retry (#61386) ## Proposed changes The three-tier retry logic in `Segment::_open()` (static method) was structured as `if-else-if`, so when `open_file()` succeeded but `_parse_footer()` returned `CORRUPTION`, the retry branch was unreachable. ### Root cause ```cpp // Before: if-else-if structure auto st = fs->open_file(path, &file_reader, &reader_options); if (st) { // open_file succeeded (almost always) segment->_file_reader = ...; st = segment->_open(stats); // _parse_footer() → CORRUPTION stored in st } else if (st.is<CORRUPTION>() && ...) { // UNREACHABLE: already entered `if` branch // Tier 1: clear cache, retry // Tier 2: bypass cache, read remote directly } RETURN_IF_ERROR(st); // CORRUPTION returned without any retry ``` `open_file()` only opens a file handle and rarely returns `CORRUPTION`. The actual footer checksum validation happens inside `_parse_footer()` (called via `segment->_open()`). Because the retry was in an `else if` guarded by the same `st` from `open_file()`, it was never reachable for the common `_parse_footer()` corruption case. ### Fix Change `else if` to a separate `if` block, so CORRUPTION from either `open_file()` or `_parse_footer()` triggers the three-tier retry: ```cpp // After: independent if blocks if (st) { segment->_file_reader = ...; st = segment->_open(stats); // _parse_footer() → CORRUPTION stored in st } // NOW reachable regardless of where CORRUPTION came from if (st.is<CORRUPTION>() && reader_options.cache_type == FILE_BLOCK_CACHE) { // Tier 1: clear file cache, re-download from remote // Tier 2: bypass cache entirely, read remote directly // Tier 3: remote source itself corrupt (logs warning) } ``` ### Issue Observed in cloud (S3) deployments: schema change fails with `CORRUPTION: Bad segment file footer checksum not match`. Log analysis confirmed that no retry log messages were ever emitted, consistent with this code bug. ## Tests - Added `TestFooterCorruptionTriggersRetry` to `segment_corruption_test.cpp` - Uses the existing `Segment::parse_footer:magic_number_corruption` sync point to corrupt the footer magic number on the first `_parse_footer()` call only (simulating file cache corruption) - Verifies the segment opens successfully via the retry path
Contributor
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
Contributor
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Cherry-picked from #61386