Re: PANIC :Call AbortTransaction when transaction id is no normal

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PANIC :Call AbortTransaction when transaction id is no normal
Дата
Msg-id 5787.1557771310@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: PANIC :Call AbortTransaction when transaction id is no normal  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
I wrote:
> If we do anything at all about this, my thought would just be to change
> bootstrap_signals() so that it points all the signal handlers at
> quickdie(), or maybe something equivalent to quickdie() but printing
> a more apropos message, or even just set them all to SIGDFL since that
> means process termination for all of these.  die() isn't really the right
> thing, precisely because it thinks it can trigger transaction abort,
> which makes no sense in bootstrap mode.

After further thought I like the SIG_DFL answer, as per attached proposed
patch.  With this, you get SIGINT behavior like this if you manage to
catch it in bootstrap mode (which is not that easy these days):

selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... America/New_York
creating configuration files ... ok
running bootstrap script ... ^Cchild process was terminated by signal 2: Interrupt
initdb: removing data directory "/home/postgres/testversion/data"

That seems perfectly fine from here.

> But ... that code's been like that for decades and nobody's complained
> before.  Why are we worried about bootstrap's response to signals at all?

I'm still wondering why the OP cares.  Still, the PANIC message that you
get right now is potentially confusing.

            regards, tom lane

diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index d8776e1..825433d 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -558,11 +558,16 @@ bootstrap_signals(void)
 {
     Assert(!IsUnderPostmaster);

-    /* Set up appropriately for interactive use */
-    pqsignal(SIGHUP, die);
-    pqsignal(SIGINT, die);
-    pqsignal(SIGTERM, die);
-    pqsignal(SIGQUIT, die);
+    /*
+     * We don't actually need any non-default signal handling in bootstrap
+     * mode; "curl up and die" is a sufficient response for all these cases.
+     * But let's just make sure the signals are set that way, since our parent
+     * process initdb has them set differently.
+     */
+    pqsignal(SIGHUP, SIG_DFL);
+    pqsignal(SIGINT, SIG_DFL);
+    pqsignal(SIGTERM, SIG_DFL);
+    pqsignal(SIGQUIT, SIG_DFL);
 }

 /*

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: POC: Cleaning up orphaned files using undo logs
Следующее
От: Andrew Gierth
Дата:
Сообщение: Re: SQL-spec incompatibilities in similar_escape() and related stuff