{{ message }}
Update system.functions table with more details#104479
Merged
Merged
Conversation
Contributor
rschu1ze
reviewed
May 11, 2026
Member
Author
|
@rschu1ze may I merge this once tests pass? |
Member
|
The |
alexey-milovidov
requested changes
May 12, 2026
alexey-milovidov
left a comment
Member
There was a problem hiding this comment.
Overall, very good PR, thank you!
This comment was marked as resolved.
This comment was marked as resolved.
1 task
pull Bot
pushed a commit
to CrazyForks/ClickHouse
that referenced
this pull request
May 14, 2026
…results
`table_function_results` is a `Tables` map protected by `table_function_results_mutex`.
All 5 production accesses (`Context::executeTableFunction`,
`Context::clearTableFunctionResults`) take the mutex before reading or writing
the map. The `ContextData(const ContextData &)` copy constructor, however,
copied the map in its initializer list:
table_function_results(o.table_function_results),
without acquiring `o.table_function_results_mutex`. When another thread was
mutating `o.table_function_results` under the mutex (e.g. inserting a new
table-function cache entry from `Context::executeTableFunction`), TSan
reported a data race against the unsynchronized read inside the copy
constructor.
Reported via STID 1003-358c (issue ClickHouse#104807). The truncated stack from the
AST fuzzer hit on PR ClickHouse#104479 (amd_tsan) showed:
T762 (write, holding M0): Context::executeTableFunction ->
std::map::__insert_node_at
T748 (read, no mutex): ContextData::ContextData(const ContextData&) ->
std::map __copy_construct_tree
The fix follows the established pattern used elsewhere in this file
(`QueryAccessInfo::QueryAccessInfo`, `QueryFactoriesInfo::QueryFactoriesInfo`,
`QueryPrivilegesInfo::QueryPrivilegesInfo`): take the source object's
mutex and copy the protected field in the constructor body.
PR ClickHouse#94171 originally added `table_function_results_mutex` and locked the
production readers/writers, but did not update the `ContextData` copy
constructor. This fix closes that gap.
Also adds a regression test in `gtest_context_race.cpp` that races a
writer thread (`executeTableFunction`) against a copier thread
(`Context::createCopy`). Without this fix, the TSan build reports the
race; with the fix, the test passes.
CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104479&sha=42334bfbb7d48857ed6741a30fd2a876590b1dff&name_0=PR&name_1=AST%20fuzzer%20%28amd_tsan%29
Closes ClickHouse#104807
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 task
# Conflicts: # src/Functions/IFunctionAdaptors.h # src/Functions/array/arrayFold.cpp
alexey-milovidov
approved these changes
May 16, 2026
rschu1ze
requested changes
May 17, 2026
1 task
rschu1ze
approved these changes
May 18, 2026
Member
Author
|
@alexey-milovidov, why did you remove the no-parallel tag? A SQL function is being re-created. This is going to be flaky if the test runs in parallel. |
Contributor
LLVM Coverage ReportChanged lines: 98.53% (67/68) · Uncovered code |
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.

Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add
deterministicandhigher_ordercolumns tosystem.functionstable.Documentation entry for user-facing changes
The
system.functionstable got new columns:deterministic, andhigher_order. This helps with automated testing. For each of these columns, if the value is unknown, it outputs NULL.Version info
26.5.1.750