Re: [sqlsmith] stuck spinlock in pg_stat_get_wal_receiver after OOM
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Andres Freund <andres@anarazel.de>,
Andreas Seltenreich <seltenreich@gmx.de>,
pgsql-hackers@postgresql.org,
Michael Paquier <michael.paquier@gmail.com>
Date: 2017-10-03T16:58:23Z
Lists: pgsql-hackers
Attachments
- fix-unsafe-accesses-to-WalRcv-latch.patch (text/x-diff) patch
I wrote: > So that's trouble waiting to happen, for sure. At the very least we > need to do a single fetch of WalRcv->latch, not two. I wonder whether > even that is sufficient, though: this coding requires an atomic fetch of > a pointer, which is something we generally don't assume to be safe. > > I'm inclined to think that it'd be a good idea to move the set and > clear of the latch field into the nearby spinlock critical sections, > and then change WalRcvForceReply to look like ... Concretely, as per the attached. I reordered the WalRcvData fields to show that the "latch" field is now treated as protected by the spinlock. In the back branches, we shouldn't do that, just in case some external code is touching the mutex field. regards, tom lane
Commits
-
Fix race condition with unprotected use of a latch pointer variable.
- 2451de7e9e72 10.1 landed
- 45f9d08684d9 11.0 landed
-
Fix coding rules violations in walreceiver.c
- c9c37e335e3a 9.2.24 landed
- b24f15f86de4 9.3.20 landed
- ad40d5f74585 10.1 landed
- 89e434b59caf 11.0 landed
- 86076395ef81 9.6.6 landed
- 6b2daef96d43 9.4.15 landed
- 182abe31387c 9.5.10 landed
-
Use latch instead of select() in walreceiver
- 597a87ccc9a6 10.0 cited