Skip to content

Fix data race in LRUFileCachePriority::LRUIterator::invalidate - #95064

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-lru-file-cache-priority-data-race
Jan 25, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-lru-file-cache-priority-data-race

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jan 25, 2026 •

Copy link
Copy Markdown
Member

Linked issues

The invalidate method was taking a reference to the EntryPtr stored in the list node. When another thread called removeEntries which erases the list node, the reference became dangling, causing use-after-free when accessing entry members.

The fix copies the EntryPtr instead of taking a reference, ensuring the Entry object remains valid even if the list node is deleted.

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC) or LOGICAL_ERROR

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix data race in the filesystem cache.

See https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=95057&sha=855aaba0e6750a51d95794122c0dca211f5c4e69&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20sequential%2C%202%2F2%29
#95057

Version info

  • Merged into: 26.1.1.846

The `invalidate` method was taking a reference to the `EntryPtr`
stored in the list node. When another thread called `removeEntries`
which erases the list node, the reference became dangling, causing
use-after-free when accessing entry members.

The fix copies the `EntryPtr` instead of taking a reference, ensuring
the `Entry` object remains valid even if the list node is deleted.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jan 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1a4b0b5]

Summary: ❌

job_name test_name status info comment
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: (STID: 1941-1bfa) FAIL cidb, issue
BuzzHouse (arm_asan) failure
Logical error: Cannot find transaction A that has started mutation B that is going to be applied to part C (STID: 3968-4fab) FAIL cidb, issue
Finish Workflow failure
python3 ./ci/jobs/scripts/workflow_hooks/new_tests_check.py failure

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Jan 25, 2026
@kssenii

kssenii commented Jan 26, 2026

Copy link
Copy Markdown
Member

@alexey-milovidov this is not a correct fix and does not fix the problem, and I have a proper fix here #95042. Please do not merge PRs without review.

@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jan 26, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@kssenii, let's add a revert inside the branch with your fix: #95042

At least, my PR is green, and yours has a segmentation fault, which currently makes it impossible to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

5 participants