Re: how to terminate a process when kill fails - Mailing list pgsql-general

From Bruce Momjian
Subject Re: how to terminate a process when kill fails
Date
Msg-id 200211020115.gA21Fav22771@candle.pha.pa.us
Whole thread Raw
In response to Re: how to terminate a process when kill fails  (Mike Mascari <mascarm@mascari.com>)
List pgsql-general
Woh, the prohibition to using kill -9 is still valid.  I can think of no
reason to use -9 unless something is broken in our code or in the OS.

pg_ctl code has:

    case "$shutdown_mode" in
        s|smart)
            sig="-TERM"
            ;;
        f|fast)
            sig="-INT"
            ;;
        i|immediate)
            sig="-QUIT"
            ;;
and the 7.3 postgres manual page has:

   To stop a running query use the SIGINT signal. To
   tell postgres to reread the config file,
   use a SIGHUP signal. The postmaster uses SIGTERM
   to tell a postgres process to quit normally and
   SIGQUIT to terminate without the normal cleanup.
   These should not be used by users.


---------------------------------------------------------------------------

Mike Mascari wrote:
> Johnson, Shaunn wrote:
>  >
> > Running PostgreSQL 7.2.1 on RedHat Linux 7.2.
> >
> > I think I may have asked before, but I never got an answer
> > that told me one way or another -
> >
> > How can I kill processes without kill -9 <pid> and
> > ruining the database?
> >
> > I've tried restarting postgreSQL hoping that it cleans up
> > a few things.  I've tried to simply kill the processes that
> > were running.  Nothing happens; nothing dies.  I don't see
> > much of anything in the messages / log files.
> >
> > Any suggestions?
>
> Use kill -9. Do a:
>
> killall -9 postgres
> killall -9 postmaster
>
> The tip message
>
> 'Don't kill -9 the postmaster'
>
> is old and was added when havoc could be caused by an old
> postgres backend process. Consider the scenrio:
>
> 1. postmaster started
> 2. postgres started  (Session #1)
> 3. postmaster killed (-9)
> 4. postmaster restarted
> 5. postgres started (Session #2)
>
> Now there isn't any synchronization between Sesison #1 and
> Session #2 at all, which would lead to data corruption. This
> scenario was fixed a long time ago (7.1?). The whole 'Don't kill
> -9 the postmaster' comment was actually a tongue-in-cheek remark
> by me regarding a parallel discussion of RedHat init scripts.
> The corruption possibility has long-since been fixed. Since I've
> seen FUD claiming PostgreSQL doesn't have sufficient
> crash-recovery because of the tip, I suggest the tip be changed to:
>
> 'Feel free to kill -9 the postmaster'
>
> Mike Mascari
> mascarm@mascari.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: problems with building recent cvs snaphots
Next
From: Bruce Momjian
Date:
Subject: Re: [SQL] unnecessary updates