Re: Race conditions with checkpointer and shutdown
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>,
Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-04-18T14:53:00Z
Lists: pgsql-hackers
Attachments
- assert-there-is-only-one.patch (text/x-diff) patch
Thomas Munro <thomas.munro@gmail.com> writes: > On Wed, Apr 17, 2019 at 10:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: >> I think what we need to look for is reasons why (1) the postmaster >> never sends SIGUSR2 to the checkpointer, or (2) the checkpointer's >> main loop doesn't get to noticing shutdown_requested. >> >> A rather scary point for (2) is that said main loop seems to be >> assuming that MyLatch a/k/a MyProc->procLatch is not used for any >> other purposes in the checkpointer process. If there were something, >> like say a condition variable wait, that would reset MyLatch at any >> time during a checkpoint, then we could very easily go to sleep at the >> bottom of the loop and not notice that there's a pending shutdown request. > Agreed on the non-composability of that coding, but if there actually > is anything in that loop that can reach ResetLatch(), it's well > hidden... Well, it's easy to see that there's no other ResetLatch call in checkpointer.c. It's much less obvious that there's no such call anywhere in the code reachable from e.g. CreateCheckPoint(). To try to investigate that, I hacked things up to force an assertion failure if ResetLatch was called from any other place in the checkpointer process (dirty patch attached for amusement's sake). This gets through check-world without any assertions. That does not really prove that there aren't corner timing cases where a latch wait and reset could happen, but it does put a big dent in my theory. Question is, what other theory has anybody got? regards, tom lane
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