Merge pull request #69186 from ClickHouse/vdimir/client-context-race2

Fix possible timeouts in `sh` tests with tsan, att. 2
This commit is contained in:
vdimir 2024-09-06 11:09:24 +00:00 committed by GitHub
commit 1b71ad26ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
});