Skip to content

Make test_select_racing_drop deterministic with a failpoint instead of a sleep - #131652

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-test-select-racing-drop
Nov 15, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-test-select-racing-drop

Conversation

@groeneai

@groeneai groeneai commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #112928
Related: #113695

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

...

Description

test_storage_s3_queue/test_5.py::test_select_racing_drop failed in Integration tests (amd_msan, targeted) on #112928 with iteration 3: assert 'TABLE_IS_DROPPED' in ''.

The test ordered a DROP TABLE ... SYNC against a direct SELECT by wall clock: a 3 s scalar subquery and a 1.2 s sleep, so the DROP had to reach the server within ~1.8 s. In that job the DROP's client needed 2.23 s to connect (0.25 s in the other iterations), so the SELECT read the live metadata first and returned 0 without an error. The server behaved correctly.

Change: a one-shot pause failpoint object_storage_queue_pause_in_direct_select in StorageObjectStorageQueue::read(), after the table is opened and before the read path takes the metadata handle. It parks the query thread during planning, not a pipeline worker. The test enables it, starts the SELECT, waits for the pause, runs DROP TABLE (not SYNC, which would wait for the paused SELECT), disables the failpoint and asserts TABLE_IS_DROPPED. One deterministic pass replaces the 10 sleep-based iterations. Same pattern as nats_pause_before_checking_direct_select_connection from #125494.

Validation: with a 2.5 s delay injected before the DROP, the old test fails on master with the CI message. The new test passes 50/50, still passes with 5 s delays around the DROP, fails when the DROP is removed, and fails when the LOGICAL_ERROR that #113695 fixed is restored. test_5.py passes 36/36.


Workflow [PR]
Sync PR [sync-upstream/pr/131652]

Version info

  • Merged into: 26.11.1.2371-master (included in 26.11 and later)

The test raced `DROP TABLE ... SYNC` against a direct `SELECT` by wall
clock: the `SELECT` kept its plan open for ~3 s in a scalar subquery and
pytest sent the `DROP` 1.2 s later, so the `DROP` had to reach the server
within ~1.8 s. In `Integration tests (amd_msan, targeted)` on ClickHouse#112928 the
`DROP`'s client needed 2.23 s to connect, the `SELECT` read the live
metadata first and returned 0 without an error, and the assertion
`'TABLE_IS_DROPPED' in ''` failed.

Add a one-shot pause failpoint `object_storage_queue_pause_in_direct_select`
in `StorageObjectStorageQueue::read()`, after the table is opened and
before the read path takes the metadata handle. It parks the query thread
during planning, never a pipeline worker inside `IProcessor::work()`.
The test now enables it, starts the `SELECT`, waits for the pause, runs
`DROP TABLE` (not `SYNC`: that waits for the paused `SELECT` to release
the table), disables the failpoint and asserts `TABLE_IS_DROPPED`. One
deterministic pass replaces the 10 sleep-based iterations. Same pattern as
`nats_pause_before_checking_direct_select_connection` (ClickHouse#125494).

Related: ClickHouse#112928
Related: ClickHouse#113695

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 SYSTEM WAIT FAILPOINT ... PAUSE has no client timeout, so a SELECT that never reaches read() blocks until the 900 s pytest timeout instead of failing fast AGREE, noted-not-blocking Bounded and loud (the finally releases the failpoint); same shape as the merged NATS test

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-9:20261114-153300

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The old test with a 2.5 s delay before the DROP (the 2.23 s client latency measured in the failing job) fails on master on demand: iteration 0: assert 'TABLE_IS_DROPPED' in ''.
b Root cause explained? The test ordered the DROP against the SELECT with a 1.2 s sleep inside a 3 s subquery window. When the DROP's client takes more than ~1.8 s to connect, the SELECT reads the live metadata first and returns 0 with no error.
c Fix matches root cause? Yes. The wall-clock ordering is replaced by a pause at the exact point where the DROP must land; no longer sleep, no weaker assertion.
d Test intent preserved / new tests added? Yes. It still asserts that a DROP between table open and metadata access yields TABLE_IS_DROPPED; it fails when the #113695 LOGICAL_ERROR is restored and when the DROP is removed.
e Both directions demonstrated? Yes. Old test: fails with the injected delay. New test: passes 50/50, and 3/3 with 5 s delays after the pause and after the DROP.
f Fix is general across code paths? Both TABLE_IS_DROPPED sites (createFileIterator, initializePipeline) are behind the pause; AzureQueue shares StorageObjectStorageQueue::read(); streaming never calls read().
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only change plus a test hook).
h Backward compatible? (maintainer-approved exception only) Yes. No setting, format or error-code change; the failpoint is a no-op unless enabled.
i Invariants and contracts preserved? The pause is on the query thread during planning, after the storage mutex is released and before any metadata handle is taken; the DROP completed while the SELECT was paused. The failpoint is one-shot and disabled in finally.

Session id: cron:clickhouse-impl-slot-6:20261114-145100

@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [846c86a]

Summary: ✅


AI Review

Summary

PR #131652 replaces the sleep-based ordering in test_select_racing_drop with a one-shot failpoint in StorageObjectStorageQueue::read. It deterministically places DROP TABLE before queue metadata access and preserves the TABLE_IS_DROPPED assertion. No actionable findings.

Missing context / blind spots
  • ⚠️ The integration test was not rerun locally because this checkout has no server binary or build directory. The author reports 50 successful repetitions and negative controls. Fast tests and style checks passed, but targeted integration jobs are still pending in the current CI report; their completion would provide independent execution evidence.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 846c86acc with master 4ba5be0b3 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.62, programs/clickhouse-keeper ×0.66 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 5.8 s 13.9 s +10.2 s (+284%)
Compile time of recompiled translation units

8 translation units recompiled, 20 s compile time in total, 8 of them have a recent master baseline.

Job report

@alexey-milovidov alexey-milovidov self-assigned this Nov 15, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 15, 2026
Merged via the queue into ClickHouse:master with commit 4ba983e Nov 15, 2026
408 of 409 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 15, 2026
@clickhouse-gh clickhouse-gh Bot added comp-s3queue S3Queue/AzureQueue engines (queue-based ingestion from object storage). and removed comp-testing Test content only (no production code). labels Nov 22, 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 comp-s3queue S3Queue/AzureQueue engines (queue-based ingestion from object storage). 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