Skip to content

Clear only the Protobuf cache in 03326_protobuf_schemas_race - #118391

Merged
alexey-milovidov merged 3 commits into
masterfrom
fix/03326-clear-format-schema-cache-for-protobuf
Sep 11, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
fix/03326-clear-format-schema-cache-for-protobuf

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

Related: #107736

03326_protobuf_schemas_race ran a bare SYSTEM CLEAR FORMAT SCHEMA CACHE a hundred times in a loop. Besides the in-memory Protobuf cache, this also deletes every file of the on-disk __cache__ directory under format_schema_path, which is shared by all tests of a parallel run. Any test relying on the cached schema of format_schema_source = 'string' or 'query' that happened to run at the same time then failed with CANNOT_PARSE_PROTOBUF_SCHEMA: File not found.

This is what happened to 05055_format_schema_source_query_background_access in Stateless tests (arm_binary, parallel) of #107736, and on master the same day: the server log shows the schema of 05055 stored at 08:31:14.867 and its SELECT failing at 08:31:15, while 03326 was clearing the cache every 0.27 s from 08:31:03 to 08:31:30.

The schema of 03326 is a plain file in its own directory, not an entry of __cache__, so the race the test exercises is the one with the in-memory ProtobufSchemas cache only. The loop now runs SYSTEM CLEAR FORMAT SCHEMA CACHE FOR Protobuf, which keeps the race and stops interfering with parallel tests. No open issue tracks this flake.

The test is also slow on its own: it averages 170 s and peaks at 271 s in Stateless tests (amd_asan_ubsan, distributed plan, parallel) on master, and the flaky check of this PR failed all eight runs with Test runs too long (> 180s). The slow part is not the cache clearing but the hundred separate clickhouse-client processes - locally the loop of 100 client invocations takes 5 s while the same 100 statements sent through a single connection take 0.075 s. The clearing queries now go through a single connection, repeated for as long as the INSERT is running, so the race is exercised over the whole lifetime of the INSERT. The test takes 1.6 s instead of 6 s locally.

Changelog category (leave one):

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

🤖 Generated with Claude Code


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

The test ran a bare `SYSTEM CLEAR FORMAT SCHEMA CACHE` a hundred times in a loop. Besides the in-memory Protobuf cache it also deletes every file of the on-disk `__cache__` directory under `format_schema_path`, which is shared by all tests of a parallel run. Any test relying on the cached schema of `format_schema_source = 'string'` or `'query'` that happened to run at the same time then failed with `CANNOT_PARSE_PROTOBUF_SCHEMA: File not found`, as `05055_format_schema_source_query_background_access` did in https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=107736&sha=c4de425e719ad1057d0da677efffe2fbd84a71b8&name_0=PR&name_1=Stateless%20tests%20(arm_binary,%20parallel) (#107736): the server log shows the schema stored at 08:31:14.867 and the `SELECT` failing at 08:31:15 while `03326` was clearing the cache every 0.27 s.

The schema of `03326` is a plain file in its own directory, not an entry of `__cache__`, so the race it exercises is the one with the in-memory `ProtobufSchemas` cache only. Use `SYSTEM CLEAR FORMAT SCHEMA CACHE FOR Protobuf`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8634599]

Summary: ✅


AI Review

Summary

This PR narrows 03326_protobuf_schemas_race from the global SYSTEM CLEAR FORMAT SCHEMA CACHE to SYSTEM CLEAR FORMAT SCHEMA CACHE FOR Protobuf, and batches the clear statements over a single client connection while waiting for the background INSERT to finish. I did not find a remaining test-isolation issue or a correctness regression in the current script: FOR Protobuf only drops the in-memory descriptor cache, which is the race this test is meant to cover, and the added wait avoids deleting the schema directory before the background client exits.

Final Verdict

✅ No actionable findings in the current diff.

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Sep 6, 2026
alexey-milovidov and others added 2 commits September 11, 2026 05:58
The flaky check of #118391
failed all eight runs of the test with `Test runs too long (> 180s)`
(https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118391&sha=f9342e71cc9b1da430eb26a87373be051f357202&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29).
The test is slow on master as well - it averages 170 s and peaks at
271 s in `Stateless tests (amd_asan_ubsan, distributed plan, parallel)`
- so the flaky check only made the existing slowness visible.

The slow part is not the cache clearing but the hundred separate
`clickhouse-client` processes it was started from: locally the loop of
100 client invocations takes 5 s while the same 100 statements sent
through a single connection take 0.075 s, and in a sanitizer build a
client start costs over a second.

Send a batch of the clearing queries through one connection instead, and
keep repeating the batch for as long as the `INSERT` is running, so the
race is exercised over the whole lifetime of the `INSERT` rather than a
fixed number of times. The test now takes 1.6 s instead of 6 s locally,
and its duration no longer depends on the client start time.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Sep 11, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 11, 2026
Merged via the queue into master with commit 953dfa3 Sep 11, 2026
175 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix/03326-clear-format-schema-cache-for-protobuf branch September 11, 2026 11:53
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 11, 2026
@clickhouse-gh clickhouse-gh Bot added comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). 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

comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). 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.

2 participants