pgsql: Fix a recently-introduced race condition in LISTEN/NOTIFY handli

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix a recently-introduced race condition in LISTEN/NOTIFY handli
Дата
Msg-id E1kj5Vr-0003Is-56@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cbc7a7a10c2d91cfa0401e9f68b17f19b7d5e7d2

Modified Files
--------------
src/backend/commands/async.c | 52 +++++++++++++++++++++++++++++++++-----------
1 file changed, 39 insertions(+), 13 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Fujii Masao
Дата:
Сообщение: pgsql: Fix CLUSTER progress reporting of number of blocks scanned.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Clean up after tests in src/test/locale/.