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

Commit33c5099

Browse files
committed
Fix logic bug in1632ea4
I overlooked that one condition was logically inverted. The fix is alittle bit more involved than simply negating the condition, to makethe code easier to read.Fix some outdated comments left by the same commit, while at it.Author: Masahiko Sawada <sawada.mshk@gmail.com>Author: Álvaro Herrera <alvherre@alvh.no-ip.org>Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>Discussion:https://postgr.es/m/YMRlmB3/lZw8YBH+@paquier.xyz
1 parent86b222b commit33c5099

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

‎src/backend/replication/slot.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,9 @@ ReplicationSlotAcquire(const char *name, bool nowait)
410410
if (IsUnderPostmaster)
411411
{
412412
/*
413-
* Get ready to sleep on the slot in case it is active if SAB_Block.
414-
*(We may endup not sleeping, but we don't want to do this while
415-
*holding thespinlock.)
413+
* Get ready to sleep on the slot in case it is active. (We may end
414+
* up not sleeping, but we don't want to do this while holding the
415+
* spinlock.)
416416
*/
417417
if (!nowait)
418418
ConditionVariablePrepareToSleep(&s->active_cv);
@@ -429,22 +429,24 @@ ReplicationSlotAcquire(const char *name, bool nowait)
429429

430430
/*
431431
* If we found the slot but it's already active in another process, we
432-
*either error out, return the PID of the owning process, or retry after
433-
*a short wait, as caller specified.
432+
*wait until the owning process signals us that it's been released, or
433+
*error out.
434434
*/
435435
if (active_pid!=MyProcPid)
436436
{
437437
if (!nowait)
438-
ereport(ERROR,
439-
(errcode(ERRCODE_OBJECT_IN_USE),
440-
errmsg("replication slot \"%s\" is active for PID %d",
441-
NameStr(s->data.name),active_pid)));
438+
{
439+
/* Wait here until we get signaled, and then restart */
440+
ConditionVariableSleep(&s->active_cv,
441+
WAIT_EVENT_REPLICATION_SLOT_DROP);
442+
ConditionVariableCancelSleep();
443+
gotoretry;
444+
}
442445

443-
/* Wait here until we get signaled, and then restart */
444-
ConditionVariableSleep(&s->active_cv,
445-
WAIT_EVENT_REPLICATION_SLOT_DROP);
446-
ConditionVariableCancelSleep();
447-
gotoretry;
446+
ereport(ERROR,
447+
(errcode(ERRCODE_OBJECT_IN_USE),
448+
errmsg("replication slot \"%s\" is active for PID %d",
449+
NameStr(s->data.name),active_pid)));
448450
}
449451
elseif (!nowait)
450452
ConditionVariableCancelSleep();/* no sleep needed after all */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp