perkolatte opened a new pull request, #71154: URL: https://github.com/apache/doris/pull/71154
### Background `FileColumnIterator::_read_data_page()` reads a data page through `PageIO`, which can serve it from `StoragePageCache`, and then builds a `ParsedPage`. #70563 added `retry_original` there: on a read or parse failure it erases the page's cache entry and reads the page once more from the source. Only the read-ahead iterator arms it. ### What problem does this PR solve? Issue Number: close #71131 Related PR: #70563 (added `retry_original` for read-ahead) PR Type: Bugfix Problem Summary: The issue reports a tablet that one BE could not read for about 15 hours. Every query failed with `[INTERNAL_ERROR]Size information unmatched, _data.size:65570, _num_elements:16384, expected size is 65552`. Other BEs read the same tablet without errors. The remote object was intact, and the error cleared on its own, which points to a malformed `StoragePageCache` entry that stayed until LRU eviction. No recovery path ran, so each retry was served the same entry again. This PR adds the evict-and-reread-once step for any data page served from `StoragePageCache`. ### Details - **Frequency:** Rare, but long-lasting when it happens. The issue reports one occurrence that made one tablet unreadable on one BE for about 15 hours, until LRU eviction. Every query that read the page failed during that time. - **Root cause:** This PR does not find where the 18 extra bytes come from. What it fixes is that a malformed `StoragePageCache` entry has no recovery path. Decoder size checks return `INTERNAL_ERROR`, so `PageIO`'s `CORRUPTION`-only retry does not run. `retry_original` in `_read_data_page()` (#70563) would evict the entry and reread the page, but only the read-ahead iterator arms it, through `PageReadContext::retry_on_error`. For the plain iterator the flag is `false`, so every read is served the same entry again. - **Why existing tests missed it:** The tests for `retry_original` cover read-ahead pages. No test put a malformed entry into `StoragePageCache` and read it through the plain iterator. - **Fix:** `_read_data_page()` also arms `retry_on_error` when the first read was served from `StoragePageCache`. It detects that by comparing `OlapReaderStatistics::cached_pages_num` before and after the read. `PageIO` increments that counter only on a cache hit. A cache handle alone is not enough, because a page read from the source is also inserted and returned through a cache handle. The existing `retry_original` then erases that page's key, reads once with `use_page_cache = false`, and builds the `ParsedPage` again. If the fresh read also fails, that error is returned, so a page that is really corrupt still fails, after one extra read. The success path only adds two counter reads. - **Behavior change:** A data page served from the page cache that fails to read or parse is now evicted and read once more from storage, instead of returning the error. Pages read from the source behave as before. - **Other paths and branches:** This targets master, where `retry_original` exists. 4.1.5 (the reported version) has neither `retry_original` nor the read-ahead iterator, so a backport needs its own small version of the retry. Dictionary pages (`_read_dict_data()`) and index pages do not go through `_read_data_page()` and are unchanged. ### Testing - New `ColumnReaderTest.FileColumnIteratorRereadsMalformedPageCacheEntry` (`be/test/storage/segment/column_reader_test.cpp`). It writes a plain `INT` column file, reads it once through a plain iterator with the page cache on, and then replaces the cached first page with a copy whose body has 18 trailing bytes. The footer is left intact, so `PageIO` accepts the entry and the plain decoder rejects it with the same kind of `INTERNAL_ERROR` size check. The test reads again through a plain iterator. It checks that every value is correct and that the malformed entry is gone from the cache. - `./run-be-ut.sh --run --filter='ColumnReaderTest.*PageCache*:ColumnReaderTest.*ChecksumFailure*'` in `apache/doris:build-env-ldb-toolchain-latest` (ASAN, full BE and test build): all 4 tests pass, including the existing read-ahead page-cache and checksum-fallback tests. - Without the `column_reader.cpp` change, the new test fails with `[INTERNAL_ERROR]file corruption: unexpected data size.` - `clang-format` 16.0.6 on both changed files. ### Release note Fix a BE read failure that could persist until restart or cache eviction when a malformed data page was cached in the page cache: the page is now evicted and read again once from storage. ### Check List (For Author) - Behavior changed: Yes (a data page served from the page cache that fails to read or parse is evicted and read once more from storage) - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Claude Code (Claude Opus 5.5) - Generated: code, the unit test, this description - Human review: not stated - Prompts: The author asked for unclaimed Doris issues to work on and chose this one. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
