Fix segfault in dictionary internal query#100839
Conversation
|
Workflow [PR], commit [a765f3b] Summary: ❌
AI ReviewSummaryThis PR fixes a shutdown-time null dereference by making ClickHouse Rules
Final Verdict
|
|
Confirmed against core dump: |
| if (!server_settings[ServerSetting::shutdown_wait_unfinished_queries]) | ||
| process_list.killAllQueries(); |
There was a problem hiding this comment.
I don't think we need this, we have safeExit in case there are alive connections
And it looks like a hack
There was a problem hiding this comment.
I don't think we need this, we have safeExit in case there are alive connections
This is needed for dictionary queries.
We need to (1) disable future updates, (2) kill all the currently running queries, and (3) join the threads.
If we skip (2), (3) can take a long time to finish.
There was a problem hiding this comment.
I see, then let's add a comment and also I guess we need to do this unconditionally, since between previous KillAllQueries and this one dictionary can start reloading?
By the way, is it hard to make proper query termination from joinLoadingThreads?
There was a problem hiding this comment.
By the way, is it hard to make proper query termination from joinLoadingThreads?
It is quite hard. There are arguably too many layers of abstraction between ExternalDictionariesLoader and the code that runs the selects.
I guess we need to do this unconditionally, since between previous KillAllQueries and this one dictionary can start reloading?
Yes, there can be new queries. My initial idea was to still diligently respect the shutdown_wait_unfinished_queries setting, but it probably doesn't matter, so I removed the check.
LLVM Coverage Report
Changed lines: 92.59% (25/27) · Uncovered code |
Backport #100839 to 26.2: Fix segfault in dictionary internal query
Backport #100839 to 26.1: Fix segfault in dictionary internal query
Backport #100839 to 26.3: Fix segfault in dictionary internal query
Linked issues
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix null pointer dereference segfault when loading dictionaries during server shutdown.
Context::getUserDefinedSQLObjectsStorage(dereferencesuser_defined_sql_objects_storage) is called by dictionary threads concurrently with the main thread callingContext::shutdown(setsuser_defined_sql_objects_storageto null). We need to make sure we disable future updates in the dictionaries loader, kill the currently running dictionary queries and join the dictionary loading threads - all before runningContext::shutdown. Similar to what we do with normal queries.Documentation entry for user-facing changes