diff --git a/src/postgres/src/backend/utils/misc/yb_ash.c b/src/postgres/src/backend/utils/misc/yb_ash.c index b3d6b3cd78a..f9d3e1a6563 100644 --- a/src/postgres/src/backend/utils/misc/yb_ash.c +++ b/src/postgres/src/backend/utils/misc/yb_ash.c @@ -37,6 +37,7 @@ #include "parser/scansup.h" #include "pgstat.h" #include "postmaster/bgworker.h" +#include "postmaster/interrupt.h" #include "storage/ipc.h" #include "storage/latch.h" #include "storage/lwlock.h" @@ -81,10 +82,6 @@ static ExecutorFinish_hook_type prev_ExecutorFinish = NULL; static ExecutorEnd_hook_type prev_ExecutorEnd = NULL; static ProcessUtility_hook_type prev_ProcessUtility = NULL; -/* Flags set by interrupt handlers for later service in the main loop. */ -static volatile sig_atomic_t got_sigterm = false; -static volatile sig_atomic_t got_sighup = false; - YbAshTrackNestedQueries yb_ash_track_nested_queries = NULL; typedef struct YbAsh @@ -330,7 +327,7 @@ yb_ash_ExecutorStart(QueryDesc *queryDesc, int eflags) query_id = queryDesc->plannedstmt->queryId != 0 ? queryDesc->plannedstmt->queryId : yb_ash_utility_query_id(queryDesc->sourceText, - queryDesc->plannedstmt->stmt_len, + queryDesc->plannedstmt->stmt_len, queryDesc->plannedstmt->stmt_location); YbAshSetQueryId(query_id); } @@ -676,28 +673,6 @@ YbAshReleaseBufferLock() LWLockRelease(&yb_ash->lock); } -static void -yb_ash_sigterm(SIGNAL_ARGS) -{ - int save_errno = errno; - - got_sigterm = true; - SetLatch(MyLatch); - - errno = save_errno; -} - -static void -yb_ash_sighup(SIGNAL_ARGS) -{ - int save_errno = errno; - - got_sighup = true; - SetLatch(MyLatch); - - errno = save_errno; -} - void YbAshMain(Datum main_arg) { @@ -707,8 +682,10 @@ YbAshMain(Datum main_arg) yb_ash_circular_buffer_size * 1024))); /* Register functions for SIGTERM/SIGHUP management */ - pqsignal(SIGHUP, yb_ash_sighup); - pqsignal(SIGTERM, yb_ash_sigterm); + pqsignal(SIGHUP, SignalHandlerForConfigReload); + pqsignal(SIGTERM, SignalHandlerForShutdownRequest); + pqsignal(SIGINT, SignalHandlerForShutdownRequest); + pqsignal(SIGQUIT, SignalHandlerForCrashExit); /* We're now ready to receive signals */ BackgroundWorkerUnblockSignals(); @@ -717,7 +694,7 @@ YbAshMain(Datum main_arg) pgstat_report_appname("yb_ash collector"); - while (!got_sigterm) + while (true) { TimestampTz sample_time; int rc; @@ -730,15 +707,7 @@ YbAshMain(Datum main_arg) if (rc & WL_POSTMASTER_DEATH) proc_exit(1); - /* Process signals */ - if (got_sighup) - { - /* Process config file */ - got_sighup = false; - ProcessConfigFile(PGC_SIGHUP); - ereport(LOG, - (errmsg("bgworker yb_ash signal: processed SIGHUP"))); - } + HandleMainLoopInterrupts(); if (yb_enable_ash && yb_ash_sample_size > 0) { diff --git a/src/yb/yql/pgwrapper/pg_ash-test.cc b/src/yb/yql/pgwrapper/pg_ash-test.cc index 8d25ff1d31f..040f8651a93 100644 --- a/src/yb/yql/pgwrapper/pg_ash-test.cc +++ b/src/yb/yql/pgwrapper/pg_ash-test.cc @@ -290,7 +290,6 @@ TEST_F(PgAshTest, YB_DISABLE_TEST_IN_TSAN(NoMemoryLeaks)) { } TEST_F_EX(PgWaitEventAuxTest, NewDatabaseRPCs, PgNewDatabaseWaitEventAux) { - GTEST_SKIP() << "Skipping this test until #24582 is done"; ASSERT_OK(conn_->Execute("CREATE DATABASE db1")); ASSERT_OK(conn_->Execute("ALTER DATABASE db1 RENAME TO db2")); ASSERT_OK(conn_->Execute("DROP DATABASE db2"));