Repository navigation
Conversation
A query that is killed, or that hits `max_execution_time`, while it waits in `FileSegment::wait` for another query's cache download throws `TIMEOUT_EXCEEDED` or `QUERY_WAS_CANCELLED` from inside `MergeTreeReaderWide::readRows`. The reader treats every exception that is not retryable as a sign of a broken part, so a healthy part is enqueued for a full data check. On object storage such a check reads the whole part, and a replica restart blocks in `ReplicatedMergeTreePartCheckThread::stop` until it ends. The test pauses a downloader on the `file_segment_pause_before_write` failpoint, lets a second query time out inside the wait, and asserts that no part check is requested. Co-Authored-By: Claude Fable 5.1 <[email protected]>
`MergeTreeReaderWide`, `MergeTreeReaderCompactSingleBuffer` and `MergeTreeSequentialSource` report the part as broken for every exception that is not retryable. Since a killed query, or one that hit `max_execution_time`, can throw `QUERY_WAS_CANCELLED` or `TIMEOUT_EXCEEDED` from inside a read (`FileSegment::wait`, the S3 client, the marks loader), a healthy part was enqueued for a full data check each time that happened. On object storage such a check reads the whole part, which took 30 to 47 minutes per part in production, and a Keeper session loss during the check left the table read-only for as long, because `partialShutdown` waits in `ReplicatedMergeTreePartCheckThread::stop` for the running check. Add `isQueryCancellation` next to `isRetryableException` and skip `reportBroken` for a cancellation. The codes are kept out of `isRetryableException` on purpose: inside `checkDataPart` a retryable exception yields empty checksums, and a cancelled `CHECK TABLE` would then pass an unchecked part. Co-Authored-By: Claude Fable 5.1 <[email protected]>
A downloader that never writes to the cache left the test blocked in `SYSTEM WAIT FAILPOINT` until the test timeout; the wait is now bounded and reported. The check thread logs under the table name, so a repeated run in the same database counted the checks of the earlier runs; the `text_log` query is now bounded to the current run. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Related to #128199 |
|
Workflow [PR], commit [f9ddb75] Summary: ✅
AI ReviewSummaryThe PR prevents ordinary query cancellation and timeout exceptions from requesting integrity checks of healthy Findings
Tests
Missing context / blind spots
Final Verdict |
The style check flags a `catch (...)` that returns without handling the exception: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=128083&sha=c0777a3c36db63dcd3498c71663cf1f25e2c40ba&name_0=PR&name_1=Style%20check ClickHouse#128083 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…uery-cancellation
| return e.code() == ErrorCodes::QUERY_WAS_CANCELLED | ||
| || e.code() == ErrorCodes::QUERY_WAS_CANCELLED_BY_CLIENT | ||
| || e.code() == ErrorCodes::TIMEOUT_EXCEEDED; |
There was a problem hiding this comment.
[P2] Recognize cancellations that rethrow the original error
QueryStatus::throwQueryWasCancelled rethrows the exception supplied to cancelQuery, so a cancellation need not carry any of these three codes. For example, the background writer of PrettyBlockOutputFormat calls cancelQuery(CANCELLED_BY_ERROR, exception) when formatting fails; an out-of-range output_format_float_precision produces BAD_ARGUMENTS. If a read thread is in FileSegment::wait at that point, throwIfKilled rethrows that formatting error inside the reader. Both isRetryableException and this helper return false, so the reader still calls reportBroken and requests a full check of a healthy part. Please recognize the current query's stored cancellation error as well, preserving the distinction from an independent read error, and cover this cancellation path in a focused regression test.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units18 translation units recompiled, 189 s compile time in total, 18 of them have a recent master baseline. |
|
@evillique looks like CI is green here, is this good to merge? |
|
Also, what are the odds of getting this back ported to the LTS and getting a release for that? |
evillique
left a comment
There was a problem hiding this comment.
Thanks! One suggestion: the test is no-parallel and takes up to 95 s in CI, mostly in the polling loop. Polling isn't needed, because the reading thread logs Enqueueing ... for check under its own query id, so a single lookup by query_id is enough (see the suggestions below).
Co-authored-by: Nikolay Degterinsky <[email protected]>
…not-found-on-active-part-load Resolve the checkDataPart.cpp conflict: keep master's isQueryCancellation (ClickHouse#128083) and add isObjectStorageNotFoundException after it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lation-compact-reader-mark-loop Conflicts resolved: - MergeTreeReaderCompactSingleBuffer.cpp: master (ClickHouse#127287) moved the mark loop out of readRows into MergeTreeReaderCompact::readGranules, and ClickHouse#128083 already guards the reportBroken catch with isQueryCancellation. Took master's file as is; the per-granule checkTimeLimit moves to both loops of MergeTreeReaderCompact (readGranules and readGranulesWithColumnsCache). - checkDataPart.{cpp,h}: ClickHouse#128083 added isQueryCancellation under the same name. Kept master's function and declaration; dropped ours. Master accepts only the three cancellation codes on a DB::Exception, so isCodeOfCancelledQuery stays as an extra clause in both catch branches: a killed query can rethrow the error it was cancelled with, of any code and any exception type. - MergeTreeSequentialSource.cpp: master's catch line is identical to ours. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #128083 to 26.8: Part check ignore query cancellation
Cherry pick #128083 to 26.9: Part check ignore query cancellation
Cherry pick #128083 to 26.10: Part check ignore query cancellation
Backport #128083 to 26.8: Part check ignore query cancellation
Backport #128083 to 26.10: Part check ignore query cancellation
Backport #128083 to 26.9: Part check ignore query cancellation
Closes: #128199
Previously, query cancellation (either due to an explicit kill or a timeout) could trigger a part to be reported as broken, as those exceptions are not considered "retryable". It seems like the
isRetryableException(...)method is a little bit overloaded, so instead this PR chooses to introduce a newisQueryCancellation(...)call, and skip the broken reporting based on those within the merge tree reader.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Query cancellation and timeouts within the merge tree reader no longer mark parts as potentially broken and trigger part checks
Workflow [PR]
Sync PR [sync-upstream/pr/128083]
Version info
26.11.1.1433-master(included in26.11and later)