pgsql: Fix race condition at backend exit when deleting element in sync

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема pgsql: Fix race condition at backend exit when deleting element in sync
Дата
Msg-id E1iQX9Z-0008J9-Dm@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix race condition at backend exit when deleting element in syncrep queue

When a backend exits, it gets deleted from the syncrep queue if present.
The queue was checked without SyncRepLock taken in exclusive mode, so it
would have been possible for a backend to remove itself after a WAL
sender already did the job.  Fix this issue based on a suggestion from
Fujii Masao, by first checking the queue without the lock.  Then, if the
backend is present in the queue, take the lock and perform an additional
lookup check before doing the element deletion.

Author: Dongming Liu
Reviewed-by: Kyotaro Horiguchi, Fujii Masao, Michael Paquier
Discussion: https://postgr.es/m/a0806273-8bbb-43b3-bbe1-c45a58f6ae21.lingce.ldm@alibaba-inc.com
Backpatch-through: 9.4

Branch
------
REL9_4_STABLE

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

Modified Files
--------------
src/backend/replication/syncrep.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Add some assertions to view reloption macros
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Add some assertions in syncrep.c