Skip to content

Fix data race in dictionaries - #103277

Merged
mstetsyuk merged 3 commits into
masterfrom
fix-dict-source-invalidate-query-race
May 11, 2026
Merged

mstetsyuk merged 3 commits into
masterfrom
fix-dict-source-invalidate-query-race

Conversation

@mstetsyuk

@mstetsyuk mstetsyuk commented Apr 21, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

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

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

Fix a data race for ClickHouse, MySQL, PostgreSQL and XDBC dictionary sources where clone() const reads from and isModified() const writes to the same invalidate_query_response string.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.529
  • Backported to: 26.4.3.19, 26.3.11.19, 26.2.19.25, 25.8.24.13

@clickhouse-gh

clickhouse-gh Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ab1fc67]

Summary: ❌

job_name test_name status info comment
Unit tests (asan_ubsan, function_prop_fuzzer) FAIL
FunctionsStress FAIL cidb
Unit tests (msan, function_prop_fuzzer) FAIL
FunctionsStress FAIL
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/new_tests_check.py FAIL
python3 ./ci/jobs/scripts/workflow_hooks/check_report_messages.py FAIL

AI Review

Summary

This PR replaces plain std::string state with a synchronized InvalidateQueryResponse holder in dictionary sources to eliminate the clone() const vs isModified() const data race. The locking strategy in updateAndCheckModified and the copy-constructor lock on the source instance are consistent with the intended race fix, and I did not find remaining correctness or safety regressions in the touched paths.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@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 Apr 21, 2026
@mstetsyuk
mstetsyuk requested a review from Algunenano April 23, 2026 20:22
@Algunenano Algunenano self-assigned this May 4, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.10% 91.10% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 88.00% (22/25) · Uncovered code

Full report · Diff report

@mstetsyuk
mstetsyuk added this pull request to the merge queue May 11, 2026
Merged via the queue into master with commit c6779e3 May 11, 2026
161 of 165 checks passed
@mstetsyuk
mstetsyuk deleted the fix-dict-source-invalidate-query-race branch May 11, 2026 16:40
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label May 11, 2026
robot-ch-test-poll added a commit that referenced this pull request May 11, 2026
Cherry pick #103277 to 25.8: Fix data race in dictionaries
robot-ch-test-poll added a commit that referenced this pull request May 11, 2026
Cherry pick #103277 to 26.2: Fix data race in dictionaries
robot-ch-test-poll added a commit that referenced this pull request May 11, 2026
Cherry pick #103277 to 26.3: Fix data race in dictionaries
robot-ch-test-poll added a commit that referenced this pull request May 11, 2026
Cherry pick #103277 to 26.4: Fix data race in dictionaries
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label May 11, 2026
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label May 11, 2026
@fm4v

fm4v commented May 14, 2026

Copy link
Copy Markdown
Member

@mstetsyuk Hi! Please include a link to the CI report or the issue so we can understand the problem

fm4v added a commit that referenced this pull request May 14, 2026
Backport #103277 to 26.4: Fix data race in dictionaries
fm4v added a commit that referenced this pull request May 14, 2026
Backport #103277 to 26.3: Fix data race in dictionaries
fm4v added a commit that referenced this pull request May 14, 2026
Backport #103277 to 26.2: Fix data race in dictionaries
fm4v added a commit that referenced this pull request May 14, 2026
Backport #103277 to 25.8: Fix data race in dictionaries
@mstetsyuk

Copy link
Copy Markdown
Member Author

@fm4v, I found this bug when debugging this crash: https://github.com/ClickHouse/clickhouse-core-incidents/issues/1501 - that said, I don't think it caused the crash.

zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…3277

Backport ClickHouse#103277 to 26.4: Fix data race in dictionaries
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.

6 participants