Repository navigation
Fix flaky test_move_after_processing_preserve_path - #117066
Merged
Merged
Conversation
`StorageObjectStorageQueue::postProcess`, which performs the
`after_processing = 'move'` action, is called from
`StorageObjectStorageQueue::commit` and therefore runs only *after* the rows
have been committed to the materialized view target table.
Both `after_processing = 'move'` tests waited for `SELECT count()` on the
target table to reach its final value and then asserted on the object storage
immediately. Reaching the final row count does not imply the objects have been
moved yet, so a move still in flight was reported as a lost object:
assert count_objects(started_cluster, dst_bucket, expected_key) == 1
AssertionError: assert 0 == 1
+ where 0 = count_minio_objects(<ClickHouseCluster>, 'root',
'sink/move_after_processing_preserve_S3Queue_kudmif_data/a.csv')
Poll the object counts until they match the expectation instead of asserting
on them once. `test_move_after_processing` was racy in the same way; it only
never failed because it happens to issue `SYSTEM FLUSH LOGS` and several
`system.*_log` queries between the row-count wait and the object assertions.
Observed once in ~11950 `master` runs of
`test_storage_s3_queue/test_0.py::test_move_after_processing_preserve_path[True-same_bucket-S3Queue]`.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=dcf60013dc275ac8a3c4c8187e83ff95d58efcdc&name_0=MasterCI&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%204%2F4%29
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [60a323d] Summary: ✅ AI ReviewSummaryThis PR updates Missing context / blind spots
Final VerdictStatus: ✅ Approve No review findings in the current diff, so I did not post inline comments. |
This was referenced Sep 3, 2026
pull Bot
pushed a commit
to admariner/ClickHouse
that referenced
this pull request
Sep 4, 2026
`test_delete_after_processing`, `test_tag_after_processing` and `test_move_after_processing` wait for the destination materialized view table to reach its final row count, then issue a single `SYSTEM FLUSH LOGS` and assert on `system.s3queue_log` / `system.azure_queue_log` and the corresponding metadata cache. That is racy: `ObjectStorageQueueSource::appendLogElement` is called from `finalizeCommit`, after the rows have already been committed to the materialized view target, so the log entry may not have been queued yet when the flush happens, and the flush then flushes nothing. The assertion then sees `0` instead of `files_num * row_num`. Replace the one-shot flush and assert with `wait_for_queue_log_rows`, which flushes and polls until the expected counts are reported, in the same shape as `wait_for_object_counts` added in ClickHouse#117066 for the object-count race in the same tests. Observed on ClickHouse#116992 in `Integration tests (arm_binary, distributed plan, 4/4)`: `test_move_after_processing[another_bucket-AzureQueue]` failed with `assert 0 == (5 * 10)` on `SELECT sum(rows_processed) FROM system.azure_queue_log`.
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.
Fixes a rare flake of
test_storage_s3_queue/test_0.py::test_move_after_processing_preserve_path, seen once in ~11950masterruns:CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=dcf60013dc275ac8a3c4c8187e83ff95d58efcdc&name_0=MasterCI&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%204%2F4%29
StorageObjectStorageQueue::postProcess, which performs theafter_processing = 'move'action, is called fromStorageObjectStorageQueue::commit, andcommitruns only after the rows have been inserted into the materialized view target table. So reaching the final row count does not imply the objects have been moved yet — there is a window in which the rows are already visible and the copy-then-delete is still in flight.Both
after_processing = 'move'tests waited forSELECT count()on the target table to reach its final value and then asserted on the object storage immediately, so a move still in that window was reported as a lost object. They now poll the object counts until they match instead of asserting once.test_move_after_processingwas racy the same way; it only never failed because it happens to issueSYSTEM FLUSH LOGSand severalsystem.*_logqueries between the row-count wait and the object assertions, which usually hides the window.The polling helper returns the counts it last observed, so a genuine failure still fails, with the observed counts in the assertion message rather than a bare
0 == 1.Not fixed here, but worth noting:
test_tag_after_processinghas the same latent race —after_processing = 'tag'goes through the samepostProcess— but it has 0 failures in ~12000masterruns, and its per-object tag assertions do not fit the count-based helper.Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/117066]
Version info
26.9.1.362(included in26.9and later)