break_repl_slot_management.patch
text/x-diff
Filename: break_repl_slot_management.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/replication/slot.c | 0 | 0 |
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index dc7de20..78cd416 100644
*** a/src/backend/replication/slot.c
--- b/src/backend/replication/slot.c
*************** ReplicationSlotAcquire(const char *name)
*** 358,364 ****
if (active_pid != MyProcPid)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_IN_USE),
! errmsg("replication slot \"%s\" is active for PID %d",
name, active_pid)));
/* We made this slot active, so it's ours now. */
--- 358,364 ----
if (active_pid != MyProcPid)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_IN_USE),
! errmsg("replication slot \"%s\" is active for PID %d (acq)",
name, active_pid)));
/* We made this slot active, so it's ours now. */
*************** ReplicationSlotRelease(void)
*** 391,396 ****
--- 391,398 ----
* Mark persistent slot inactive. We're not freeing it, just
* disconnecting.
*/
+ pg_usleep(100000);
+ elog(LOG, "ReplicationSlotRelease: unmarking persistent slot");
SpinLockAcquire(&slot->mutex);
slot->active_pid = 0;
SpinLockRelease(&slot->mutex);
*************** ReplicationSlotDropPtr(ReplicationSlot *
*** 523,528 ****
--- 525,532 ----
{
bool fail_softly = slot->data.persistency != RS_PERSISTENT;
+ pg_usleep(100000);
+ elog(LOG, "ReplicationSlotDropPtr: unmarking slot after rename fail");
SpinLockAcquire(&slot->mutex);
slot->active_pid = 0;
SpinLockRelease(&slot->mutex);
*************** ReplicationSlotDropPtr(ReplicationSlot *
*** 540,545 ****
--- 544,551 ----
* and nobody can be attached to this slot and thus access it without
* scanning the array.
*/
+ pg_usleep(100000);
+ elog(LOG, "ReplicationSlotDropPtr: unmarking slot");
LWLockAcquire(ReplicationSlotControlLock, LW_EXCLUSIVE);
slot->active_pid = 0;
slot->in_use = false;
*************** restart:
*** 876,882 ****
if (active_pid)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_IN_USE),
! errmsg("replication slot \"%s\" is active for PID %d",
slotname, active_pid)));
/*
--- 882,888 ----
if (active_pid)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_IN_USE),
! errmsg("replication slot \"%s\" is active for PID %d (drop)",
slotname, active_pid)));
/*