Skip to content

Fix logical error when enable enable_filesystem_query_cache_limit - #86935

Closed
linkwk7 wants to merge 4 commits into
ClickHouse:masterfrom
linkwk7:fix_fs_cache_query_limit
Closed

linkwk7 wants to merge 4 commits into
ClickHouse:masterfrom
linkwk7:fix_fs_cache_query_limit

Conversation

@linkwk7

@linkwk7 linkwk7 commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a [user-readable short description]

Fix #86855

  1. Treat max_size and max_elements 0 as no limit in IFileCachePriority::check
  2. When filesystem cache is evicting, it may get candidate from query priority and main priority, so it shouldn't assume cache entry always exists in QueryContext(in FileCacheQueryLimit::QueryContext::tryRemove)

@kssenii kssenii self-assigned this Sep 10, 2025
@kssenii kssenii added the can be tested Allows running workflows for external contributors label Sep 10, 2025
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [89f656c]

Summary: ⏳

job_name test_name status info comment
Bugfix validation (integration tests) failure
test_filesystem_cache/test.py::test_parallel_cache_loading_on_startup[node] FAIL cidb
test_filesystem_cache/test.py::test_caches_with_the_same_configuration[node] FAIL cidb
test_filesystem_cache/test.py::test_caches_with_the_same_configuration_2[node_caches_with_same_path] FAIL cidb
test_filesystem_cache/test.py::test_custom_cached_disk FAIL cidb
test_filesystem_cache/test.py::test_force_filesystem_cache_on_merges FAIL cidb
test_filesystem_cache/test.py::test_system_sync_filesystem_cache FAIL cidb
test_filesystem_cache/test.py::test_keep_up_size_ratio FAIL cidb
test_filesystem_cache/test.py::test_dynamic_resize FAIL cidb
test_filesystem_cache/test.py::test_filesystem_cache_log FAIL cidb
test_filesystem_cache/test.py::test_dynamic_resize_disabled FAIL cidb
3 more test cases not shown
Integration tests (amd_asan, flaky) failure
test_filesystem_cache/test.py::test_caches_with_the_same_configuration[node-3-3] FAIL cidb
test_filesystem_cache/test.py::test_caches_with_the_same_configuration[node-1-3] FAIL cidb
Stress test (amd_tsan) failure
Server died FAIL cidb
Hung check failed, possible deadlock found (see hung_check.log) FAIL cidb
Killed by signal (in clickhouse-server.log) FAIL cidb
Fatal message in clickhouse-server.log (see fatal_messages.txt) FAIL cidb
Killed by signal (output files) FAIL cidb
Found signal in gdb.log FAIL cidb

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 10, 2025
@kssenii

kssenii commented Sep 12, 2025

Copy link
Copy Markdown
Member

Hi! There is no need to "merge master branch" unless there are conflicts, some tests failures can be unrelated to changes due to being flaky.

@kssenii

kssenii commented Sep 12, 2025 •

Copy link
Copy Markdown
Member

Could you please add an integration test for the issue? See tests/integration/test_filesystem_cache/test.py. One inconvenience is that it is possible to run integration tests only on linux, so if you can't do this, then I can add a test, though I'd really appreciate if you could do this.

@linkwk7

linkwk7 commented Sep 12, 2025

Copy link
Copy Markdown
Contributor Author

sure, let me add a test for this

@linkwk7
linkwk7 force-pushed the fix_fs_cache_query_limit branch from 0006e43 to d028244 Compare September 14, 2025 09:53
@kssenii

kssenii commented Sep 24, 2025

Copy link
Copy Markdown
Member

The changes LGTM, but for some reason tests failed in test_filesystem_cache with a logical error (https://s3.amazonaws.com/clickhouse-test-reports/PRs/86935/d028244d79f08137001e08d326369e5dd449432d//integration_tests_amd_asan_old_analyzer_6_6/integration_run_parallel_0.log) which I do not see how is it related to this PR, I will check

@clickhouse-gh

clickhouse-gh Bot commented Nov 18, 2025

Copy link
Copy Markdown
Contributor

Dear @kssenii, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@alexey-milovidov

Copy link
Copy Markdown
Member

Continued in #101428.

@alexey-milovidov alexey-milovidov self-assigned this Mar 31, 2026
alexey-milovidov added a commit that referenced this pull request Apr 29, 2026
After rebasing onto current master, two of the original three changes
in #86935 are no longer applicable:

1. The `FileCacheQueryLimit::QueryContext::remove` -> `tryRemove`
   rename was needed because `EvictionCandidates::finalize` called
   `query_context->remove(...)` for every evicted entry. That call
   site was removed from master in 62ffdf7, so `tryRemove` had
   no callers and was effectively dead code. Reverting the
   `QueryLimit.cpp` / `QueryLimit.h` changes to match master.

2. The integration test `test_caches_with_query_limit` was meant to
   reproduce the bug from #86855, but with the current `tryReserve`
   shape `query_priority_iterator->incrementSize` is unreachable on
   the first reservation (the iterator is only assigned inside the
   `!main_priority_iterator` branch and `add` does not return it),
   so the per-query `check` is no longer hit. The "Bugfix validation"
   job confirms this - the test passes against the master binary.
   Removing the test since it does not validate the fix.

What remains is the `IFileCachePriority::check` change: treat
`max_size = 0` and `max_elements = 0` as "no limit" (consistent with
`canFit`, which already does so). This is a defensive guard for the
per-query priority, which is constructed with `max_elements = 0`,
matching the `0 == unlimited` convention used elsewhere.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101428&sha=95a5413b6250fe9b49e79ae60f50d1babb31909b&name_0=PR

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
clickgapai pushed a commit to clickgapai/ClickHouse that referenced this pull request May 1, 2026
…ry_limit

Merging ClickHouse#86935: Fix logical error when enable enable_filesystem_query_cache_limit
PedroTadim added a commit that referenced this pull request Sep 18, 2026
Backport #101428 to 26.3: Merging #86935: Fix logical error when enable enable_filesystem_query_cache_limit
VighneshPath pushed a commit to VighneshPath/ClickHouse that referenced this pull request Sep 18, 2026
…ical error when enable enable_filesystem_query_cache_limit
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-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use s3 with filesystem cache got Logical error: Cache limits violated.

3 participants