Fix data race on shutdown_called in DatabaseMaterializedPostgreSQL#97554
Merged
alexey-milovidov merged 3 commits intomasterfrom Feb 23, 2026
Merged
Fix data race on shutdown_called in DatabaseMaterializedPostgreSQL#97554alexey-milovidov merged 3 commits intomasterfrom
alexey-milovidov merged 3 commits intomasterfrom
Conversation
`shutdown_called` was a plain `bool` written by TCPHandler thread during `DROP DATABASE` (in `shutdown`) and read concurrently by BackgroundSchedulePool thread (in `tryStartSynchronization`). TSan detected this race and aborted the server, causing all subsequent `test_postgresql_replica_database_engine/test_3.py` tests to fail with "Connection refused". Changed to `std::atomic<bool>`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97541&sha=9c54f0ea0a9a17ee5cf1bd5077ef581f6419b5c2&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Workflow [PR], commit [b231049] Summary: ❌
|
alexey-milovidov
added a commit
that referenced
this pull request
Feb 21, 2026
… link The "Finish workflow" check requires Bug Fix PRs to include new or changed tests. This is too strict for PRs that fix CI failures, where the existing CI already serves as the test. Allow the check to pass if the PR description contains a link to a CI report (`s3.amazonaws.com/clickhouse-test-reports`), e.g. as in #97554 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 task
… link The "Finish workflow" check requires Bug Fix PRs to include new or changed tests. This is too strict for PRs that fix CI failures, where the existing CI already serves as the test. Allow the check to pass if the PR description contains a link to a CI report (`s3.amazonaws.com/clickhouse-test-reports`), e.g. as in #97554 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
alexey-milovidov
added a commit
that referenced
this pull request
Feb 21, 2026
… link The "Finish workflow" check requires Bug Fix PRs to include new or changed tests. This is too strict for PRs that fix CI failures, where the existing CI already serves as the test. Allow the check to pass if the PR description contains a link to a CI report (`s3.amazonaws.com/clickhouse-test-reports`), e.g. as in #97554 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
alexey-milovidov
added a commit
that referenced
this pull request
Feb 21, 2026
… link The "Finish workflow" check requires Bug Fix PRs to include new or changed tests. This is too strict for PRs that fix CI failures, where the existing CI already serves as the test. Allow the check to pass if the PR description contains a link to a CI report (`s3.amazonaws.com/clickhouse-test-reports`), e.g. as in #97554 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Algunenano
approved these changes
Feb 21, 2026
Member
Algunenano
left a comment
There was a problem hiding this comment.
Confirmed the TSan report — data race between TCPHandler thread writing shutdown_called in shutdown() and BgSchPool thread reading it in tryStartSynchronization(). The std::atomic<bool> fix is correct and minimal.
3f86a61 to
f982a7b
Compare
kssenii
approved these changes
Feb 23, 2026
Algunenano
pushed a commit
to Algunenano/ClickHouse
that referenced
this pull request
Feb 24, 2026
… link The "Finish workflow" check requires Bug Fix PRs to include new or changed tests. This is too strict for PRs that fix CI failures, where the existing CI already serves as the test. Allow the check to pass if the PR description contains a link to a CI report (`s3.amazonaws.com/clickhouse-test-reports`), e.g. as in ClickHouse#97554 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Algunenano
pushed a commit
to Algunenano/ClickHouse
that referenced
this pull request
Feb 24, 2026
… link The "Finish workflow" check requires Bug Fix PRs to include new or changed tests. This is too strict for PRs that fix CI failures, where the existing CI already serves as the test. Allow the check to pass if the PR description contains a link to a CI report (`s3.amazonaws.com/clickhouse-test-reports`), e.g. as in ClickHouse#97554 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Algunenano
pushed a commit
to Algunenano/ClickHouse
that referenced
this pull request
Feb 24, 2026
… link The "Finish workflow" check requires Bug Fix PRs to include new or changed tests. This is too strict for PRs that fix CI failures, where the existing CI already serves as the test. Allow the check to pass if the PR description contains a link to a CI report (`s3.amazonaws.com/clickhouse-test-reports`), e.g. as in ClickHouse#97554 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Algunenano
pushed a commit
to Algunenano/ClickHouse
that referenced
this pull request
Feb 24, 2026
…postgresql-shutdown-race Fix data race on shutdown_called in DatabaseMaterializedPostgreSQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shutdown_calledinDatabaseMaterializedPostgreSQL— was a plainboolwritten by TCPHandler thread duringDROP DATABASE(inshutdown) and read concurrently by BackgroundSchedulePool thread (intryStartSynchronization)test_postgresql_replica_database_engine/test_3.pytests to fail with "Connection refused"std::atomic<bool>CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97541&sha=9c54f0ea0a9a17ee5cf1bd5077ef581f6419b5c2&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix data race on
shutdown_calledinDatabaseMaterializedPostgreSQL.Documentation entry for user-facing changes
🤖 Generated with Claude Code