Skip to content

Better handling of fatal errors#46846

Merged
alexey-milovidov merged 1 commit intomasterfrom
better-fatal-handling
Feb 25, 2023
Merged

Better handling of fatal errors#46846
alexey-milovidov merged 1 commit intomasterfrom
better-fatal-handling

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

This closes #37889.

@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-not-for-changelog This PR should not be mentioned in the changelog label Feb 24, 2023
/// It is important to destroy query context here. We do not want it to live arbitrarily longer than the query.
query_context.reset();

CurrentThread::setFatalErrorCallback({});
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We reset the callback before the destruction of TCPHandler.


void ThreadStatus::onFatalError()
{
std::lock_guard lock(thread_group->mutex);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows it to be reset.

if (sig != SIGTSTP) /// This signal is used for debugging.
{
/// The time that is usually enough for separate thread to print info into log.
sleepForSeconds(20); /// FIXME: use some feedback from threads that process stacktrace
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement TODO.
The logs will be sent to the client in more cases.

@alexey-milovidov
Copy link
Copy Markdown
Member Author

I didn't reproduce the case, but it should become better.

@alexey-milovidov alexey-milovidov merged commit 25853da into master Feb 25, 2023
@alexey-milovidov alexey-milovidov deleted the better-fatal-handling branch February 25, 2023 19:55
}


static std::atomic<bool> fatal_error_printed{false};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not quite correct to use std::atomic in a signal handler, it would be better to use std::atomic_flag. However, I doubt someone actually uses ClickHouse on architectures where it matters.

Copy link
Copy Markdown
Member

@tavplubix tavplubix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tavplubix tavplubix self-assigned this Feb 26, 2023

void ThreadStatus::onFatalError()
{
std::lock_guard lock(thread_group->mutex);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yokofly added a commit to timeplus-io/proton that referenced this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use-of-uninitialized-value in DB::TCPHandler

3 participants