Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ce5cf2

Browse files
committed
Allow replication slots to be dropped in single-user mode
Starting with commit9915de6, replication slot drop uses acondition variable sleep to wait until the current user of the slot goesaway. This is more user friendly than the previous behavior of erroringout if the slot is in use, but it fails with a not-for-user-consumptionerror message in single-user mode; plus, if you're using single-usermode because you don't want to start the server in the regular mode(say, disk is full and WAL won't recycle because of the slot), it'sinconvenient.Fix by skipping the cond variable sleep in single-user mode, sincethere can't be anybody to wait for anyway.Reported-by: tushar <tushar.ahuja@enterprisedb.com>Author: Álvaro Herrera <alvherre@alvh.no-ip.org>Discussion:https://postgr.es/m/3b2f809f-326c-38dd-7a9e-897f957a4eb1@enterprisedb.com
1 parent8fb68aa commit0ce5cf2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

‎src/backend/replication/slot.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,20 +351,28 @@ ReplicationSlotAcquire(const char *name, bool nowait)
351351
if (s->in_use&&strcmp(name,NameStr(s->data.name))==0)
352352
{
353353
/*
354-
* This is the slot we want. We don't know yet if it's active, so
355-
* get ready to sleep on it in case it is. (We may end up not
356-
* sleeping, but we don't want to do this while holding the
357-
* spinlock.)
354+
* This is the slot we want; check if it's active under some other
355+
* process. In single user mode, we don't need this check.
358356
*/
359-
ConditionVariablePrepareToSleep(&s->active_cv);
357+
if (IsUnderPostmaster)
358+
{
359+
/*
360+
* Get ready to sleep on it in case it is active. (We may end
361+
* up not sleeping, but we don't want to do this while holding
362+
* the spinlock.)
363+
*/
364+
ConditionVariablePrepareToSleep(&s->active_cv);
360365

361-
SpinLockAcquire(&s->mutex);
366+
SpinLockAcquire(&s->mutex);
362367

363-
active_pid=s->active_pid;
364-
if (active_pid==0)
365-
active_pid=s->active_pid=MyProcPid;
368+
active_pid=s->active_pid;
369+
if (active_pid==0)
370+
active_pid=s->active_pid=MyProcPid;
366371

367-
SpinLockRelease(&s->mutex);
372+
SpinLockRelease(&s->mutex);
373+
}
374+
else
375+
active_pid=MyProcPid;
368376
slot=s;
369377

370378
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp