Skip to content

Fix flaky test test_azure_glob_scheherazade - #107799

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix/azure-glob-scheherazade-parallel-drop
Jun 18, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix/azure-glob-scheherazade-parallel-drop

Conversation

@groeneai

@groeneai groeneai commented Jun 17, 2026 •

Copy link
Copy Markdown
Collaborator

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

Fixes the flaky integration test test_storage_azure_blob_storage/test.py::test_azure_glob_scheherazade, which times out (>900s pytest-timeout) under sanitizer builds with concurrent xdist workers.

The test creates 1001 AzureBlobStorage tables across ~31 threads to verify glob selection beyond the 1000-blob pagination boundary, then dropped all 1001 tables serially during cleanup. The serial cleanup is 1001 sequential DROP TABLE round-trips, each of which can enter azure_query's retriable-error backoff (time.sleep(i), up to 10 tries). Under ASan plus contention from concurrent workers the cleanup wall-clock crossed the per-test timeout.

The fix parallelizes the cleanup using the same chunked-thread pattern the test already uses for creation. The creation phase runs ~31 concurrent threads doing heavier CREATE + INSERT work without timing out, so the lighter parallel DROP stays well within the concurrency the test already exercises. Test intent is unchanged: still 1001 tables, still asserts the glob count beyond the 1000-blob boundary.

Surfaced on PR #101143 ("Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6)"), whose clickhouse-local SYSTEM LISTEN changes do not touch AzureBlobStorage code. Pre-existing chronic flake, fixed here in a separate PR.

Version info

  • Merged into: 26.6.1.965

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes (mechanism, not rate). Benchmarked serial vs parallel DROP of 1001 tables on a local debug server: serial 60.95s vs parallel 6.60s (9.2x) for trivial Memory tables with zero network cost. Under ASan (~2-3x slower) plus 6 concurrent xdist workers plus azure_query's per-call retriable backoff (time.sleep(i), up to 10 tries), the serial path's wall-clock compounds past the 900s pytest-timeout at the cleanup loop.
b Root cause explained? The test creates 1001 AzureBlobStorage tables across ~31 threads, then dropped them serially: 1001 sequential DROP TABLE round-trips, each able to enter azure_query's retry backoff. Cleanup wall-clock is the sum over 1001 tables, which under sanitizer + concurrent-worker contention crosses the 900s per-test timeout.
c Fix matches root cause? Yes. Parallelize the cleanup with the same chunked-thread pattern (nights_per_job = ~33 per chunk, ~31 threads) the test already uses for creation. Cleanup wall-clock becomes the slowest single chunk, not the sum of all 1001. No timeout bump, no data reduction, no tag silencing.
d Test intent preserved / new tests added? Preserved. Still 1001 tables, still asserts the glob count 1001\t1001\t1001\t1001 beyond the 1000-blob pagination boundary, still drops every created table. Only the cleanup loop's concurrency changed. No new test needed (this is a flaky-test stabilization, not a code bug).
e Both directions demonstrated? The full test PASSES with the fix via the praktika integration runner (1 passed in 29.81s), confirming correctness is unchanged. The timeout direction is demonstrated by the serial-vs-parallel benchmark in (a): the serial cleanup is the documented hang point that the parallel cleanup eliminates.
f Fix is general, not a narrow patch? N/A (flaky integration-test cleanup stabilization, not a C++ code bug). The change is confined to the one test's cleanup loop and mirrors the proven creation pattern directly above it.

Session id: cron:clickhouse-worker-slot-0:20260617-213700

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @SmitaRKulkarni — could you review this? It fixes the flaky timeout in test_azure_glob_scheherazade by parallelizing the cleanup that drops 1001 AzureBlobStorage tables (previously serial, exceeding the 900s timeout under sanitizers), using the same chunked-thread pattern the test already uses for creation.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 17, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3f8a066]

Summary: ✅


AI Review

Summary

This PR changes cleanup in test_azure_glob_scheherazade: it keeps the 1001-table glob coverage but drops the per-table cleanup in chunked SafeThread workers so worker exceptions still propagate through join. I did not find any remaining correctness issue in the current diff; the previously reported raw-thread exception swallowing issue is addressed.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 17, 2026
@alexey-milovidov alexey-milovidov self-assigned this Jun 17, 2026
The test creates 1001 AzureBlobStorage tables across ~31 threads, then dropped
all of them serially during cleanup. Under sanitizer builds with concurrent
xdist workers the serial cleanup (1001 sequential DROP TABLE round-trips, each
able to hit azure_query's retry backoff) exceeded the 900s pytest-timeout.

Parallelize the cleanup using the same chunked-thread pattern already used for
table creation. The creation phase already runs ~31 concurrent threads doing
heavier CREATE plus INSERT work without timing out, so the lighter parallel
DROP is well within the established concurrency the test exercises. Test intent
is unchanged: still 1001 tables, still verifies glob selection beyond the
1000-blob pagination boundary.

Use helpers.utility.SafeThread for the DROP workers so a cleanup exception that
survives azure_query's retries is re-raised on join(), instead of a raw
threading.Thread silently swallowing it and leaving the table behind.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the fix/azure-glob-scheherazade-parallel-drop branch from e516fc2 to 3f8a066 Compare June 17, 2026 23:49
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (fixup 3f8a066, addressing bot CR)

# Question Answer
a Deterministic repro? Yes for the CR concern. A standalone script mirroring this DROP loop deterministically shows a worker exception SWALLOWED by raw threading.Thread (join returns normally) and PROPAGATED by SafeThread on join(). The original timeout repro is the chronic ASan+xdist case captured in CIDB (test exceeded the 900s pytest-timeout doing 1001 serial DROPs).
b Root cause explained? The original flakiness: 1001 serial DROP TABLE round-trips, each able to hit azure_query's retry backoff, exceeded the 900s timeout under sanitizer + concurrent xdist. The CR's separate correctness concern: parallelizing with raw threading.Thread swallows a worker's post-retry DROP exception, so a failed cleanup would silently pass and leak a table.
c Fix matches root cause? Yes. Parallel cleanup (chunked threads, same pattern as the creation phase) removes the serial timeout; SafeThread re-raises a worker exception on join(), restoring the serial version's fail-loud cleanup contract. No band-aids (no timeout bump, no no-parallel, no assertion change).
d Test intent preserved / new tests added? Preserved. Still 1001 tables, still asserts 1001\t1001\t1001\t1001 (glob selection beyond the 1000-blob pagination boundary). Only the cleanup mechanism changed; no new test needed for a test-only flaky/cleanup fix.
e Both directions demonstrated? Yes for the CR fix: raw threading.Thread swallows the simulated failed DROP; SafeThread propagates it. Functional correctness of the parallel DROP itself was confirmed by the prior full integration run (passed in 29.81s).
f Fix is general, not a narrow patch? N/A in the C++ sense (test-only). The fix uses the repo-wide idiom (helpers.utility.SafeThread) rather than a one-off try/collect, so the propagation guarantee matches every other parallel test in the suite.

Session id: cron:clickhouse-worker-slot-4:20260617-234300

@clickhouse-gh

clickhouse-gh Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.20% 85.20% +0.00%
Functions 92.30% 92.30% +0.00%
Branches 77.50% 77.40% -0.10%

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

Newly covered by added/modified tests: 456 line(s), 46 function(s) across 124 file(s) · Details

Top files
  • src/Client/ClientBase.cpp: 144 line(s)
  • src/Storages/StorageReplicatedMergeTree.cpp: 16 line(s)
  • src/Disks/IO/CachedOnDiskWriteBufferFromFile.cpp: 15 line(s)
  • src/AggregateFunctions/TimeSeries/AggregateFunctionTimeseriesChanges.h: 14 line(s), 32 function(s)
  • src/Storages/StorageFilesystem.cpp: 12 line(s)

Full report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 18, 2026
Merged via the queue into ClickHouse:master with commit d428cbb Jun 18, 2026
165 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 18, 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.

3 participants