Skip to content

Backport #107028 to 26.5: Fix data race on FileCacheQueryLimit::query_map causing LOGICAL_ERROR - #114585

Merged
alexey-milovidov merged 3 commits into
26.5from
backport/26.5/107028
Aug 14, 2026
Merged

alexey-milovidov merged 3 commits into
26.5from
backport/26.5/107028

Conversation

@robot-ch-test-poll2

@robot-ch-test-poll2 robot-ch-test-poll2 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #107028

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.5.7.53

@robot-ch-test-poll2 robot-ch-test-poll2 added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default labels Aug 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [26b9bd4]

Summary: ✅

@groeneai

Copy link
Copy Markdown
Collaborator

This is my PR being backported, so here is what breaks and the exact change needed.

The three amd builds fail only on src/Interpreters/tests/gtest_filecache.cpp (8 errors generated, one failing object in each build). The ported fix itself, QueryLimit.h and QueryLimit.cpp, compiles clean on 26.5. Only my regression test is broken.

Cause: I wrote the test against master, where 9de468d826bc1c4 ("make ReadPipeline the single path for read buffer construction") renamed the settings type. 26.5 still takes const ReadSettings &, and FilesystemCacheSettings does not exist there, so clang typo-corrects to the unrelated FileCacheSettings. The cherry-pick had no textual conflict because the test is an append at the end of the file.

The fix is 4 lines, at 2664-2665 and 2736-2737:

-    FilesystemCacheSettings cache_settings;
-    cache_settings.max_download_size_per_query = 1024;
+    ReadSettings cache_settings;
+    cache_settings.filesystem_cache_max_download_size = 1024;

Semantics are preserved: on 26.5 getOrSetQueryContext reads settings.filesystem_cache_max_download_size, which is the pre-rename spelling of the same value, and the defaults of both fields are identical, so the assertions are unchanged. I have not run the adapted test, so treat the green build as the check.

I am not proposing to backport 9de468d826bc1c4: it is a 46-file read-path refactor, not something that belongs on a stable branch to make a test compile. The alternative, if you prefer no churn, is dropping the two tests from this backport, but that ships the fix to 26.5 with no coverage for the race it fixes.

One caveat on the other two: #114584 (26.3) and #114583 (25.8) also have this header at src/Interpreters/Cache/QueryLimit.h, and both are still at the unresolved cherry-pick stage, so they need more than this. #114586 (26.6) already has the new signature and compiles.

alexey-milovidov and others added 2 commits August 14, 2026 05:39
The two regression tests added by the backport were written against
`master`, where `9de468d826bc1c4` renamed the settings type passed to
`FileCacheQueryLimit::getOrSetQueryContext`. On 26.5 that method still
takes `const ReadSettings &` and `FilesystemCacheSettings` does not
exist, so clang typo-corrected it to the unrelated `FileCacheSettings`
and the `amd_debug`, `amd_asan_ubsan` and `amd_tsan` builds failed on
`src/Interpreters/tests/gtest_filecache.cpp`. The cherry-pick produced
no textual conflict because both tests are appended at the end of the
file.

Use `ReadSettings` with `filesystem_cache_max_download_size`, which is
the pre-rename spelling of the same value read by
`getOrSetQueryContext` on this branch, so the assertions are unchanged.
`ReadSettings` is only forward-declared in `QueryLimit.h`, so include
`IO/ReadSettings.h` explicitly.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114585&sha=46540245a0d34a4f50e96e6dabb0aa5b58a83b35&name_0=BackportPR
Related: #114585
Related: #107028

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

Copy link
Copy Markdown
Member

🕵 Applied your fix, thanks for the precise diagnosis. src/Interpreters/tests/gtest_filecache.cpp now uses ReadSettings with filesystem_cache_max_download_size in both QueryLimitContextRevivedDuringRelease and QueryLimitConcurrentReleaseNoLeak, plus an explicit #include <IO/ReadSettings.h> (on this branch QueryLimit.h only forward-declares ReadSettings).

Verified locally that the translation unit compiles against the 26.5 tree — the typo-correction errors are gone. I also merged 26.5 into the branch. Waiting for CI.

@alexey-milovidov
alexey-milovidov merged commit 9b34819 into 26.5 Aug 14, 2026
35 checks passed
@alexey-milovidov
alexey-milovidov deleted the backport/26.5/107028 branch August 14, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants