Skip to content

Fix flaky test 04043_system_asynchronous_inserts_user_filter - #105759

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-04043-flaky
May 25, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-04043-flaky

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 25, 2026 •

Copy link
Copy Markdown
Member

The test ensures system.asynchronous_inserts does not leak insert
metadata across users. To exercise the visibility filter it needs a
pending async insert to actually be in the queue while the user-filtered
SELECT queries run, and it has been flaking with both secret_user sees: and admin sees: returning 0 - i.e. the entry was no longer in
the queue when the SELECT queries ran.

PR #103032
dropped the no-parallel tag added in
#100233 on the
basis that every test that called SYSTEM FLUSH ASYNC INSERT QUEUE had
been migrated to the table-scoped variant. That is correct for the
tests that call flush, but this test does the opposite - it depends
on a pending entry remaining in the queue between the INSERT and the
three subsequent SELECT queries. Any concurrent unscoped flush drains
it, and even isolated reruns on sanitizer builds can race the entry's
visibility through system.asynchronous_inserts.

The fix:

  • Re-add no-parallel with a comment that captures the real reason
    (the test consumes pending state, it does not produce it).
  • Disable async_insert_use_adaptive_busy_timeout so the per-query
    10-minute deadline is honored exactly and max_busy_timeout_exceeded
    cannot force an early flush when the shard has been idle for a long
    time.
  • Poll system.asynchronous_inserts for up to 30 seconds before
    running the user-filter checks so the test fails clean on a real
    visibility regression instead of racing the queue.

CI history of the failure:
https://play.clickhouse.com/play?user=play#V0lUSAogICAgOTAgQVMgaW50ZXJ2YWxfZGF5cwpTRUxFQ1QKICAgIHRvU3RhcnRPZkRheShjaGVja19zdGFydF90aW1lKSBBUyBkYXksCiAgICBjb3VudCgpIEFTIGZhaWx1cmVzLAogICAgZ3JvdXBVbmlxQXJyYXkocHVsbF9yZXF1ZXN0X251bWJlcikgQVMgcHJzLAogICAgYW55KHJlcG9ydF91cmwpIEFTIHJlcG9ydF91cmwKRlJPTSBjaGVja3MKV0hFUkUgKG5vdygpIC0gdG9JbnRlcnZhbERheShpbnRlcnZhbF9kYXlzKSkgPD0gY2hlY2tfc3RhcnRfdGltZQogICAgQU5EIHRlc3RfbmFtZSA9ICcwNDA0M19zeXN0ZW1fYXN5bmNocm9ub3VzX2luc2VydHNfdXNlcl9maWx0ZXInCiAgICBBTkQgdGVzdF9zdGF0dXMgSU4gKCdGQUlMJywgJ0VSUk9SJykKICAgIEFORCAocHVsbF9yZXF1ZXN0X251bWJlciA9IDAgT1IgYmFzZV9yZWYgSU4gKCdtYXN0ZXInKSkKICAgIEFORCB0ZXN0X2NvbnRleHRfcmF3IExJS0UgJyVyZXN1bHQgZGlmZmVycyB3aXRoIHJlZmVyZW5jZSUnCkdST1VQIEJZIGRheQpPUkRFUiBCWSBkYXkgREVTQwo=

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix flaky test 04043_system_asynchronous_inserts_user_filter.

Documentation entry for user-facing changes

  • Documentation is unchanged.

Version info

  • Merged into: 26.6.1.124

The test was failing on master (and many open PRs) under sanitizer and S3
builds with both `secret_user sees:` and `admin sees:` returning 0 — i.e.
the queued async insert was no longer in `system.asynchronous_inserts` by
the time the user-filter `SELECT` queries ran.

PR #103032 dropped the `no-parallel` tag added in #100233 on the premise
that all unscoped `SYSTEM FLUSH ASYNC INSERT QUEUE` callers were migrated
to the table-scoped variant. The premise holds for the tests that *call*
flush, but this test does not call flush at all — it relies on the
opposite: a pending entry must remain in the queue between `INSERT` and
the three subsequent `SELECT` queries. Any concurrent unscoped flush
drains it, and even without that there is a residual race in slow CI
environments where the entry's visibility through
`system.asynchronous_inserts` can lag the client return.

Re-add `no-parallel` with a comment that captures the real reason (the
test consumes pending state, it does not produce it), disable
`async_insert_use_adaptive_busy_timeout` so the per-query 10-minute
deadline is honored exactly and `max_busy_timeout_exceeded` cannot force
an early flush when the shard has been idle, and poll
`system.asynchronous_inserts` for up to 30 seconds before running the
user-filter checks so the test fails clean on a real visibility bug
instead of racing the queue.

CI history:
https://play.clickhouse.com/play?user=play#V0lUSAogICAgOTAgQVMgaW50ZXJ2YWxfZGF5cwpTRUxFQ1QKICAgIHRvU3RhcnRPZkRheShjaGVja19zdGFydF90aW1lKSBBUyBkYXksCiAgICBjb3VudCgpIEFTIGZhaWx1cmVzLAogICAgZ3JvdXBVbmlxQXJyYXkocHVsbF9yZXF1ZXN0X251bWJlcikgQVMgcHJzLAogICAgYW55KHJlcG9ydF91cmwpIEFTIHJlcG9ydF91cmwKRlJPTSBjaGVja3MKV0hFUkUgKG5vdygpIC0gdG9JbnRlcnZhbERheShpbnRlcnZhbF9kYXlzKSkgPD0gY2hlY2tfc3RhcnRfdGltZQogICAgQU5EIHRlc3RfbmFtZSA9ICcwNDA0M19zeXN0ZW1fYXN5bmNocm9ub3VzX2luc2VydHNfdXNlcl9maWx0ZXInCiAgICBBTkQgdGVzdF9zdGF0dXMgSU4gKCdGQUlMJywgJ0VSUk9SJykKICAgIEFORCAocHVsbF9yZXF1ZXN0X251bWJlciA9IDAgT1IgYmFzZV9yZWYgSU4gKCdtYXN0ZXInKSkKICAgIEFORCB0ZXN0X2NvbnRleHRfcmF3IExJS0UgJyVyZXN1bHQgZGlmZmVycyB3aXRoIHJlZmVyZW5jZSUnCkdST1VQIEJZIGRheQpPUkRFUiBCWSBkYXkgREVTQwo=
@clickhouse-gh

clickhouse-gh Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c9fe327]

Summary: ✅


AI Review

Summary

The PR stabilizes 04043_system_asynchronous_inserts_user_filter by re-adding no-parallel, disabling adaptive async-insert timeout behavior for this test case, and waiting for queue visibility before asserting per-user filtering. I did not find unresolved contract violations or high-impact risks in the current diff.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.40% 91.40% +0.00%
Branches 76.60% 76.60% +0.00%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 396 line(s), 14 function(s) across 110 file(s) · Details

Top files
  • src/Functions/FunctionShowCertificate.cpp: 38 line(s), 4 function(s)
  • src/Common/QueryFuzzer.cpp: 29 line(s)
  • src/Interpreters/InterpreterCreateQuery.cpp: 19 line(s)
  • src/AggregateFunctions/AggregateFunctionQuantileGK.cpp: 15 line(s)
  • src/Storages/ObjectStorageQueue/ObjectStorageQueueIFileMetadata.cpp: 11 line(s), 1 function(s)

Full report

@alexey-milovidov
alexey-milovidov merged commit df96146 into master May 25, 2026
165 of 167 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-04043-flaky branch May 25, 2026 05:49
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 25, 2026
${CLICKHOUSE_CLIENT} \
--user "secret_user_${CLICKHOUSE_DATABASE}" \
--async_insert 1 \
--async_insert_use_adaptive_busy_timeout 0 \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the only change that was necessary. All the rest is noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants