You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The quickdie function is called as a signal handler. As a result this function should call async-signal-safe functions only.
The YBOnPostgresBackendShutdown function is too complex to be called from signal handler as this function destroys the pggate::PgApiImpl object and the destructor of this object locks mutexes.
Also it is not safe to destroy the pggate::PgApiImpl object because YSQL is a multi-threaded process. As a result quickdie can be called from any of the thread. As a result pggate::PgApiImpl object can be destroyed while it is still in use by the YSQL main thread.
Example:
YSQL's main thread calls YBCInsertSequenceTuple function
...
if (IsYugaByteEnabled())
{
HandleYBStatus(YBCInsertSequenceTuple(...)); // This function uses the `pggate::PgApiImpl` object
}
...
at same time another thread handles SIGQUIT signal by calling quickdie.
As a result it is possible that quickdie will delete the pggate::PgApiImpl object while it is still in use.
The text was updated successfully, but these errors were encountered:
Summary:
quickdie() is the signal handler invoked to handle SIGQUIT. This is the
immediate shutdown mode, expected to be invoked when something is really
wrong, such as corrupted shared memory.
This being the case, it is not safe to invoke
YBOnPostgresBackendShutdown, which internally invokes PgApi destructor
from quickdie. This also causes TSAN failures because there could be
other concurrent threads in process of accessing the PgApi object.
Secondly as noted in the comment in quickdie(), it is not safe to call
ereport() from quickdie as it is not async-signal-safe. It has been
added by PG authors anyway as a best effort to provide some information before shutting
down. Although acceptable, this again causes TSAN failures. Therefore
this patch silences the TSAN failures by not invoking the ereport() in
TSAN build.
Test Plan: Manually tested by running tests enabled with TSAN.
Reviewers: dmitry
Reviewed By: dmitry
Subscribers: yql
Differential Revision: https://phabricator.dev.yugabyte.com/D23045
Jira Link: DB-2635
Description
The
quickdie
function is called as a signal handler. As a result this function should callasync-signal-safe
functions only.The
YBOnPostgresBackendShutdown
function is too complex to be called from signal handler as this function destroys thepggate::PgApiImpl
object and the destructor of this object locks mutexes.Also it is not safe to destroy the
pggate::PgApiImpl
object because YSQL is a multi-threaded process. As a resultquickdie
can be called from any of the thread. As a resultpggate::PgApiImpl
object can be destroyed while it is still in use by the YSQL main thread.Example:
YSQL's main thread calls
YBCInsertSequenceTuple
functionat same time another thread handles SIGQUIT signal by calling
quickdie
.As a result it is possible that
quickdie
will delete thepggate::PgApiImpl
object while it is still in use.The text was updated successfully, but these errors were encountered: