postgresql/src/backend
Tom Lane 60d6c71430 Fix a recently-introduced race condition in LISTEN/NOTIFY handling.
Commit 566372b3d fixed some race conditions involving concurrent
SimpleLruTruncate calls, but it introduced new ones in async.c.
A newly-listening backend could attempt to read Notify SLRU pages that
were in process of being truncated, possibly causing an error.  Also,
the QUEUE_TAIL pointer could become set to a value that's not equal to
the queue position of any backend.  While that's fairly harmless in
v13 and up (thanks to commit 51004c717), in older branches it resulted
in near-permanent disabling of the queue truncation logic, so that
continued use of NOTIFY led to queue-fill warnings and eventual
inability to send any more notifies.  (A server restart is enough to
make that go away, but it's still pretty unpleasant.)

The core of the problem is confusion about whether QUEUE_TAIL
represents the "logical" tail of the queue (i.e., the oldest
still-interesting data) or the "physical" tail (the oldest data we've
not yet truncated away).  To fix, split that into two variables.
QUEUE_TAIL regains its definition as the logical tail, and we
introduce a new variable to track the oldest un-truncated page.

Per report from Mikael Gustavsson.  Like the previous patch,
back-patch to all supported branches.

Discussion: https://postgr.es/m/1b8561412e8a4f038d7a491c8b922788@smhi.se
2020-11-28 14:03:40 -05:00
..
access Fix and simplify some usages of TimestampDifference(). 2020-11-10 22:51:58 -05:00
bootstrap Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:15 -07:00
catalog Fix misleading error message about inconsistent moving-aggregate types. 2020-09-06 12:56:10 -04:00
commands Fix a recently-introduced race condition in LISTEN/NOTIFY handling. 2020-11-28 14:03:40 -05:00
executor Properly check index mark/restore in ExecSupportsMarkRestore. 2020-11-24 21:36:09 +00:00
foreign Code review for foreign/custom join pushdown patch. 2015-05-10 14:36:36 -04:00
lib Revert "Permit dump/reload of not-too-large >1GB tuples" 2016-12-06 12:45:49 -03:00
libpq Avoid logging complaints about abandoned connections when using PAM. 2019-11-05 14:27:37 -05:00
main Install Windows crash dump handler before all else. 2017-11-12 14:31:04 -08:00
nodes Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:15 -07:00
optimizer Properly check index mark/restore in ExecSupportsMarkRestore. 2020-11-24 21:36:09 +00:00
parser Further fixes for CREATE TABLE LIKE: cope with self-referential FKs. 2020-11-19 15:03:17 -05:00
po Translation updates 2020-11-09 12:50:59 +01:00
port Fix race condition in our Windows signal emulation. 2019-12-09 15:03:52 -05:00
postmaster Use _exit(2) for SIGQUIT during ProcessStartupPacket, too. 2020-09-10 12:06:26 -04:00
regex Fix misoptimization of "{1,1}" quantifiers in regular expressions. 2019-05-12 18:53:43 -04:00
replication doc: wire protocol data type for history file content is bytea 2020-11-12 14:33:28 -05:00
rewrite Make rewriter prevent auto-updates on views with conditional INSTEAD rules. 2020-01-14 09:48:44 +00:00
snowball Remove no-longer-required function declarations. 2015-05-24 12:20:23 -04:00
storage Don't Insert() a VFD entry until it's fully built. 2020-11-16 20:32:35 -05:00
tcop Further fixes for CREATE TABLE LIKE: cope with self-referential FKs. 2020-11-19 15:03:17 -05:00
tsearch Avoid possible dangling-pointer access in tsearch_readline_callback. 2020-09-23 11:36:13 -04:00
utils Fix and simplify some usages of TimestampDifference(). 2020-11-10 22:51:58 -05:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
Makefile Fix make rules that generate multiple output files. 2018-03-23 13:45:38 -04:00
nls.mk Translation updates 2020-11-09 12:50:59 +01:00