pgsql: Fix handling of synchronous replication for stopping WAL senders

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix handling of synchronous replication for stopping WAL senders
Date: 2018-11-29 00:15:02
Message-ID: E1gS9yw-0005bh-PY@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix handling of synchronous replication for stopping WAL senders

This fixes an oversight from c6c3334 which forgot that if a subset of
WAL senders are stopping and in a sync state, other WAL senders could
still be waiting for a WAL position to be synced while committing a
transaction. However the subset of stopping senders would not release
waiters, potentially breaking synchronous replication guarantees. This
commit makes sure that even WAL senders stopping are able to release
waiters and are tracked properly.

On 9.4, this can also trigger an assertion failure when setting for
example max_wal_senders to 1 where a WAL sender is not able to find
itself as in synchronous state when the instance stops.

Reported-by: Paul Guo
Author: Paul Guo, Michael Paquier
Discussion: https://postgr.es/m/CAEET0ZEv8VFqT3C-cQm6byOB4r4VYWcef1J21dOX-gcVhCSpmA@mail.gmail.com
Backpatch-through: 9.4

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4c703369af3e34cd7289d99c1b6f10e3b3bbbb4d

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

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2018-11-29 00:47:02 pgsql: Add missing NO_INSTALLCHECK in commit_ts and test_rls_hooks
Previous Message Peter Geoghegan 2018-11-28 22:44:24 pgsql: Have BufFileSize() ereport() on FileSize() failure.