Skip to content

Commit

Permalink
Merge pull request #69186 from ClickHouse/vdimir/client-context-race2
Browse files Browse the repository at this point in the history
Fix possible timeouts in `sh` tests with tsan, att. 2
  • Loading branch information
vdimir authored Sep 6, 2024
2 parents 8c9cf37 + d38551a commit 1b71ad2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Client/ClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,21 @@ void ClientBase::processParsedSingleQuery(const String & full_query, const Strin
/// Temporarily apply query settings to context.
std::optional<Settings> old_settings;
SCOPE_EXIT_SAFE({
try
{
/// We need to park ParallelFormating threads,
/// because they can use settings from global context
/// and it can lead to data race with `setSettings`
resetOutput();
}
catch (...)
{
if (!have_error)
{
client_exception = std::make_unique<Exception>(getCurrentExceptionMessageAndPattern(print_stack_trace), getCurrentExceptionCode());
have_error = true;
}
}
if (old_settings)
client_context->setSettings(*old_settings);
});
Expand Down

0 comments on commit 1b71ad2

Please sign in to comment.