Repository navigation
Don't record a cancelled marks-loading task in system.errors - #118928
Conversation
`MergeTreeMarksLoader::loadMarksAsync` throws `ASYNC_LOAD_CANCELED` from the pool task when `is_canceled` is set. That flag is set only by `~MergeTreeMarksLoader`, which then calls `future.wait` and drops the future without reading it, so the exception is never observed by anyone - it exists only to stop a task whose result has become useless. Constructing it, however, records the error code in `system.errors` and `system.error_log`. Since `load_marks_asynchronously` became enabled by default, this happens on any server whenever a reader is dropped before its marks are needed, so `ASYNC_LOAD_CANCELED` accumulates in `system.errors` during completely normal operation. `ProfileEvents::LoadingMarksTasksCanceled`, incremented right above, is the proper counter for the event. Construct the exception inside an `Exception::SuppressErrorCodesScope` so the control-flow signal is kept out of the error statistics. This also made `test_backup_restore_on_cluster/test_cancel_backup.py::test_cancel_restore` flaky: its `NoTrashChecker` asserts that no unexpected error codes appear in `system.errors` on the cluster nodes during the test, and the test's own `SELECT ... FROM system.query_log` query cancelled a queued marks task (`ProfileEvents['LoadingMarksTasksCanceled'] = 1` of 18 background tasks). CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=a63831d1ff39052ac6dfdce45bf38de316ab583e&name_0=MasterCI&name_1=Integration%20tests%20%28amd_msan%2C%201%2F8%29 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [bad6185] Summary: ❌
AI ReviewSummaryThis PR suppresses Findings
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit bad6185.
Changed lines: Changed C/C++ lines covered: 15/15 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing commit See the job log for details. |
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118928&sha=519e282a1862f06554a861bc1e202f89481b3458&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%206%2F6%29 ( |
|
Investigated. The failure is unrelated to this pull request (the diff is Root cause, in short: No fix pull request exists, and the reason is your own ruling on this defect on 2026-09-12: "That is a protocol addition and the Kafka owners' call, so please do not force it from this side", and that waiting on the Kafka owners on #116844 was the correct thing to do (comment). I have not forced it since. Every per-consumer and per-storage shape falls to the two defects you agreed with in that same comment (the abstention's only local bound is the incumbent's What has changed since that ruling:
If you want the demand-signal pull request from my side now, say go and I will open it against |
The `Finish Workflow` check rejects a bug-fix PR without a new test. The cancellation only happens when `~MergeTreeMarksLoader` wins the race against the marks-loading thread pool, which could not be forced from a test before. Add the test-only fail point `marks_loader_hold_task_until_canceled`, which holds the pool task (bounded, polling `is_canceled`) until the loader is destroyed, and the test `05223_marks_loader_canceled_task_not_in_system_errors` that drops a reader with its marks unread behind a `PREWHERE` filtering out every row, then checks `LoadingMarksTasksCanceled` in `system.query_log` and that no `ASYNC_LOAD_CANCELED` error was added to `system.errors`. Without the `Exception::SuppressErrorCodesScope` the test reports 2 new `ASYNC_LOAD_CANCELED` errors, with it 0 (checked locally, 12 passes with randomized settings). CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118928&sha=519e282a1862f06554a861bc1e202f89481b3458&name_0=PR&name_1=Finish%20Workflow PR: #118928 Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
|
||
| query_id="${CLICKHOUSE_DATABASE}_marks_canceled_$RANDOM" | ||
|
|
||
| $CLIENT -q "SYSTEM ENABLE FAILPOINT marks_loader_hold_task_until_canceled" |
There was a problem hiding this comment.
This enables a server-global failpoint but only clears it on the happy path. If the read below hangs/regresses or the test is interrupted while the failpoint is armed, later stateless tests on the same server inherit a forced stall in every MergeTreeMarksLoader::loadMarksAsync task and start failing for the wrong reason.
Please add the usual defensive EXIT cleanup here, e.g.
trap '$CLIENT -q "SYSTEM DISABLE FAILPOINT marks_loader_hold_task_until_canceled" >/dev/null 2>&1 || true' EXITand keep the explicit SYSTEM DISABLE FAILPOINT on the normal path if you want the post-query assertions to run with the failpoint already cleared.
|
I am taking the "Ok." as the sign-off on this pull request rather than the go-ahead for the StorageKafka2 change, so I am not opening the demand-signal pull request, and your position from 2026-09-12 stands (that is a protocol addition and the Kafka owners' call, so do not force it from this side): #118642 (comment) One thing did change since my comment above. #120111 replaces the registered-replica count in If you want that from my side now, one word on #119632 and I will open it against |
|
The red cited above ( |
Related: #118477
MergeTreeMarksLoader::loadMarksAsyncthrowsASYNC_LOAD_CANCELED("Background task for loading marks was canceled") from the pool task whenis_canceledis set. That flag is set only by~MergeTreeMarksLoader, which then callsfuture.waitand drops the future without ever reading it, so the exception is never observed by anyone - it exists only to stop a task whose result has become useless. Constructing aDB::Exception, however, records the error code insystem.errorsandsystem.error_log.Since
load_marks_asynchronouslybecame enabled by default, this happens on any server whenever a reader is dropped before its marks are needed, soASYNC_LOAD_CANCELEDaccumulates insystem.errorsduring completely normal operation, where it looks like a failure.ProfileEvents::LoadingMarksTasksCanceled, incremented right above the throw, is the proper counter for this event.The fix constructs the exception inside an
Exception::SuppressErrorCodesScope, so the control-flow signal is kept out of the error statistics and everything else stays as it was.This also made
test_backup_restore_on_cluster/test_cancel_backup.py::test_cancel_restoreflaky. ItsNoTrashCheckerasserts that no unexpected error code appears insystem.errorson the cluster nodes during the test, and the test's ownSELECT ... FROM system.query_logquery cancelled one queued marks task -ProfileEvents['LoadingMarksTasksCanceled'] = 1out of 18BackgroundLoadingMarksTasksfor query0e316a97-8cb4-4f63-b3f9-fd88e773ed43in the capturedquery_logofnode2:CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=a63831d1ff39052ac6dfdce45bf38de316ab583e&name_0=MasterCI&name_1=Integration%20tests%20%28amd_msan%2C%201%2F8%29
Test:
05223_marks_loader_canceled_task_not_in_system_errors. The cancellation happens only when the loader's destructor wins the race against the marks-loading thread pool, and no query shape could force that reliably, so the test uses the new test-only fail pointmarks_loader_hold_task_until_canceled, which holds the pool task (bounded) until the loader is destroyed. The query drops the reader of a column with its marks unread behind aPREWHEREthat filters out every row, and the test checksLoadingMarksTasksCanceledinsystem.query_logand thatsystem.errorsgained noASYNC_LOAD_CANCELED. Without the suppression the test reports 2 new errors.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Don't count a cancelled marks-loading background task as an error in
system.errorsandsystem.error_log. PreviouslyASYNC_LOAD_CANCELEDwas recorded during normal operation whenever a reader was dropped before its asynchronously loaded marks were needed.Workflow [PR]
Sync PR [sync-upstream/pr/118928]