Skip to content

Fix flaky test 02015_async_inserts_4 - #102019

Merged
pufit merged 1 commit into
ClickHouse:masterfrom
groeneai:fix/02015-async-inserts-4-flaky
Apr 8, 2026
Merged

pufit merged 1 commit into
ClickHouse:masterfrom
groeneai:fix/02015-async-inserts-4-flaky

Conversation

@groeneai

@groeneai groeneai commented Apr 8, 2026 •

Copy link
Copy Markdown
Collaborator

The test creates users and roles with hardcoded global names (u_02015_allowed,
u_02015_denied, role_02015). When the flaky check runs this test multiple
times with parallel workers, one instance's DROP USER IF EXISTS races with
another instance's REVOKE ALL / CREATE USER, causing UNKNOWN_ROLE errors.

The fix suffixes all user and role names with $CLICKHOUSE_DATABASE (unique per
test invocation), so parallel instances operate on independent global objects.

Reproduction: --test-runs 10 -j 4 — fails 6/10 without fix, passes 50/50
with fix at --test-runs 50 -j 8.

Ref: #101447

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):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.669

The test creates users and roles with hardcoded global names
(u_02015_allowed, u_02015_denied, role_02015). When the flaky check
runs this test multiple times with parallel workers, one instance's
DROP USER races with another instance's REVOKE/CREATE, causing
UNKNOWN_ROLE errors.

Fix: suffix user and role names with $CLICKHOUSE_DATABASE (unique per
test invocation) so parallel instances operate on independent global
objects.

Reproduction: --test-runs 10 -j 4 fails 6/10 without fix, 50/50
passes with fix at -j 8.

Ref: ClickHouse#101447
@groeneai

groeneai commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

Pre-PR Validation Gate (session: cron:clickhouse-ci-task-worker:20260408-034500)

a) Deterministic repro? Yes — --test-runs 10 -j 4 with the original code fails 6/10 times. The race is between parallel instances: one run's DROP USER IF EXISTS u_02015_allowed executes between another run's CREATE USER and REVOKE ALL, causing UNKNOWN_ROLE (Error 511).

b) Root cause explained? The test creates users (u_02015_allowed, u_02015_denied) and role (role_02015) with hardcoded global names. The flaky check runs the test N times with parallel workers (-j N). Instance B's DROP USER IF EXISTS at line 10 races with Instance A's REVOKE ALL ON *.* FROM at line 18 — the user created by A at line 15 is destroyed by B before A can revoke privileges from it.

c) Fix matches root cause? Yes — suffixing names with $CLICKHOUSE_DATABASE (unique per test invocation) eliminates the collision between parallel instances entirely.

d) Test intent preserved? Yes — the test still verifies async insert privilege checking: denied user gets "Not enough privileges", allowed user (via role grant) successfully inserts, data is correct. Only the naming changed.

e) Both directions demonstrated?

  • Without fix: 6/10 FAIL (--test-runs 10 -j 4)
  • With fix: 50/50 PASS (--test-runs 50 -j 8)

@groeneai

groeneai commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov — could you review this? Per your request on #101447, this makes the test repeatable by suffixing user/role names with $CLICKHOUSE_DATABASE to avoid races when the flaky check runs parallel instances.

@alesapin alesapin added the can be tested Allows running workflows for external contributors label Apr 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fadab59]

Summary: ✅


AI Review

Summary

This PR fixes flakiness in tests/queries/0_stateless/02015_async_inserts_4.sh by deriving user/role names from CLICKHOUSE_DATABASE, isolating concurrently running flaky-check instances that operate on global RBAC objects. I reviewed the diff for correctness, race-risk mitigation, and ClickHouse rule compliance; the change is targeted and appropriate, with no additional blockers or major concerns identified.

Missing context
  • ⚠️ CI is still in progress; no final functional/integration outcomes were available at review time.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
Final Verdict
  • Status: ✅ Approve

@alesapin alesapin self-assigned this Apr 8, 2026
@clickhouse-gh clickhouse-gh Bot added the pr-ci label Apr 8, 2026
@pufit
pufit added this pull request to the merge queue Apr 8, 2026
Merged via the queue into ClickHouse:master with commit d043209 Apr 8, 2026
163 of 164 checks passed
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors 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.

4 participants