pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ed L. <pggeneral@bluepolka.net>
To: Laurette Cisneros <laurette@nextbus.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: server won't shutdown
Date: Mon, 17 Feb 2003 22:06:17 -0500
Message-ID: <20307.1045537577@sss.pgh.pa.us> (raw)
In-Reply-To: <17332.1045534368@sss.pgh.pa.us>
References: <Pine.LNX.4.44.0302171414350.20323-100000@visor.corp.nextbus.com>
	<200302171647.42130.pgadmin@bluepolka.net>
	<16389.1045526983@sss.pgh.pa.us>
	<200302171725.11546.pggeneral@bluepolka.net>
	<17332.1045534368@sss.pgh.pa.us>

I said:
> Oh, duh!  You don't need to be using NOTIFY explicitly --- you just have
> to sit idle long enough to make the SI buffer overflow, and the system
> will try to NOTIFY your backend anyway to make it read the SI message
> buffer.  Which is the path I was looking at --- that will leave
> ImmediateInterruptOK false, preventing response to SIGTERM if the client
> still hasn't done anything by the time it comes.

> Patch forthcoming.

Attached is the fix against 7.3 (or CVS tip).  The same bug exists in
7.2 and 7.1, and should be fixable by the same patch (possibly with some
fuzz).

You can demonstrate the problem by doing 'LISTEN foo' in one psql and
then 'NOTIFY foo' in another, then attempting a fast shutdown --- the
first psql's backend will ignore you until the psql session does something.
The same path can be followed without LISTEN if the first psql is simply
left idle while the second one does a bunch of catalog-updating work
(a few cycles of VACUUM ANALYZE usually suffice).

Sigh, another day another bug...

			regards, tom lane

inline patch 1: src/backend/commands/async.c (+17/-0 lines) download inline-1.patch*** src/backend/commands/async.c.orig Sun Sep 15 21:24:41 2002 --- src/backend/commands/async.c Mon Feb 17 21:38:47 2003 *************** *** 599,604 **** --- 599,614 ---- if (notifyInterruptEnabled) { + bool save_ImmediateInterruptOK = ImmediateInterruptOK; + + /* + * We may be called while ImmediateInterruptOK is true; turn it off + * while messing with the NOTIFY state. (We would have to save + * and restore it anyway, because PGSemaphore operations inside + * ProcessIncomingNotify() might reset it.) + */ + ImmediateInterruptOK = false; + /* * I'm not sure whether some flavors of Unix might allow another * SIGUSR2 occurrence to recursively interrupt this routine. To *************** *** 626,631 **** --- 636,648 ---- elog(LOG, "Async_NotifyHandler: done"); } } + + /* + * Restore ImmediateInterruptOK, and check for interrupts if needed. + */ + ImmediateInterruptOK = save_ImmediateInterruptOK; + if (save_ImmediateInterruptOK) + CHECK_FOR_INTERRUPTS(); } else {

view thread (17+ messages)  latest in thread

Message-ID: <20307.1045537577@sss.pgh.pa.us>
Permalink:  ../20307.1045537577@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20307.1045537577@sss.pgh.pa.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pggeneral@bluepolka.net, laurette@nextbus.com
  Subject: Re: server won't shutdown
  In-Reply-To: <20307.1045537577@sss.pgh.pa.us>
  References: <Pine.LNX.4.44.0302171414350.20323-100000@visor.corp.nextbus.com> <200302171647.42130.pgadmin@bluepolka.net> <16389.1045526983@sss.pgh.pa.us> <200302171725.11546.pggeneral@bluepolka.net> <17332.1045534368@sss.pgh.pa.us> <20307.1045537577@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox