Skip to content

Revert "Reduce Number of FsNode Clones in Plain-Rewritable Disks" - #112557

Merged
alexey-milovidov merged 1 commit into
masterfrom
revert-111883-reduce_fs_node_clones_plain_rewritable
Jul 30, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
revert-111883-reduce_fs_node_clones_plain_rewritable

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

Reverts #111883

Version info

  • Merged into: 26.8.1.407 (included in 26.8 and later)

@alexey-milovidov alexey-milovidov self-assigned this Jul 30, 2026
@alexey-milovidov
alexey-milovidov merged commit 50dc814 into master Jul 30, 2026
1 check failed
@alexey-milovidov
alexey-milovidov deleted the revert-111883-reduce_fs_node_clones_plain_rewritable branch July 30, 2026 09:07
@clickhouse-gh

clickhouse-gh Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [38c201c]

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jul 30, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

What broke it: PR #111883 (#111883) "Reduce Number of FsNode Clones in Plain-Rewritable Disks", merged 2026-07-28 08:31 UTC. Its one substantive change added
cloneFsNodeIfNotExclusive to FsSnapshot.cpp, letting clonePath mutate an FsNode in place when use_count() == 1 instead of always copying it.

Why that races: use_count() isn't a proof of exclusive ownership here. An FsNode is reachable via its parent's subdirectories map, and a thread reading the node takes no reference of its own —
cloneFsNodeIfNotExclusive receives const FsNodePtr & aliasing the parent's map slot. So while one thread is inside std::make_shared(*node) copying the node's map, the count can drop to 1, and a second
thread then modifies that same node in place. Nodes are shared across independent FsSnapshot objects, each with its own mutex, and roots handed out by getRoot are traversed outside the writing snapshot's mutex —
which is why the TSan report shows disjoint mutex sets (M0,M1 vs M2,M3,M4) for the write in clonePath:109 against the read in FsNode's copy constructor (FsSnapshot.h:33).

How it surfaces: the TSan report aborts the server, so the test fails on the next query with Code: 210 ... Connection refused (172.16.4.10:9000) — not a test-logic failure.

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

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog 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