From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix race conditions in replication slot operations |
Date: | 2017-07-25 17:38:09 |
Message-ID: | E1da3mb-00089M-Dv@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix race conditions in replication slot operations
It is relatively easy to get a replication slot to look as still active
while one process is in the process of getting rid of it; when some
other process tries to "acquire" the slot, it would fail with an error
message of "replication slot XYZ is active for PID N".
The error message in itself is fine, except that when the intention is
to drop the slot, it is unhelpful: the useful behavior would be to wait
until the slot is no longer acquired, so that the drop can proceed. To
implement this, we use a condition variable so that slot acquisition can
be told to wait on that condition variable if the slot is already
acquired, and we make any change in active_pid broadcast a signal on the
condition variable. Thus, as soon as the slot is released, the drop
will proceed properly.
Reported by: Tom Lane
Discussion: https://postgr.es/m/11904.1499039688@sss.pgh.pa.us
Authors: Petr Jelínek, Álvaro Herrera
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/9915de6c1cb2c9b87f5f504c97832cdf3a809753
Modified Files
--------------
src/backend/replication/logical/logicalfuncs.c | 2 +-
src/backend/replication/slot.c | 122 ++++++++++++++++++-------
src/backend/replication/slotfuncs.c | 34 ++++---
src/backend/replication/walsender.c | 6 +-
src/include/replication/slot.h | 10 +-
5 files changed, 118 insertions(+), 56 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2017-07-25 23:08:20 | pgsql: Make PostgresNode easily subclassable |
Previous Message | Robert Haas | 2017-07-24 22:16:00 | pgsql: Fix partitioning crashes during error reporting. |