Re: Race conditions with checkpointer and shutdown
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-04-29T04:52:37Z
Lists: pgsql-hackers
On Sun, Apr 28, 2019 at 12:56 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > Even if that isn't the proximate cause of the current reports, it's > clearly trouble waiting to happen, and we should get rid of it. > Accordingly, see attached proposed patch. This just flushes the > "immediate interrupt" stuff in favor of making sure that > libpqwalreceiver.c will take care of any signals received while > waiting for input. +1 I see that we removed the code that this was modelled on back in 2015, and in fact your patch even removes a dangling reference in a comment: - * This is very much like what regular backends do with ImmediateInterruptOK, > The existing code does not use PQsetnonblocking, which means that it's > theoretically at risk of blocking while pushing out data to the remote > server. In practice I think that risk is negligible because (IIUC) we > don't send very large amounts of data at one time. So I didn't bother to > change that. Note that for the most part, if that happened, the existing > code was at risk of slow response to SIGTERM anyway since it didn't have > Enable/DisableWalRcvImmediateExit around the places that send data. Right. > My thought is to apply this only to HEAD for now; it's kind of a large > change to shove into the back branches to handle a failure mode that's > not been reported from the field. Maybe we could back-patch after we > have more confidence in it. +1 That reminds me, we should probably also clean up at least the ereport-from-signal-handler hazard identified over in this thread: https://www.postgresql.org/message-id/CAEepm%3D10MtmKeDc1WxBM0PQM9OgtNy%2BRCeWqz40pZRRS3PNo5Q%40mail.gmail.com -- Thomas Munro https://enterprisedb.com
Commits
-
In walreceiver, don't try to do ereport() in a signal handler.
- ac8f2e1ef34f 10.9 landed
- 9346d396fd4a 11.4 landed
- a1a789eb5ac8 12.0 landed