From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
Cc: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: ReplicationSlotRelease() crashes when the instance is in the single user mode |
Date: | 2025-02-18 06:49:45 |
Message-ID: | CAKFQuwaUgYHhZiFkMrPMraiXu2NTCY2SUC_CdYNQZoqhxdw1hw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Monday, February 17, 2025, Hayato Kuroda (Fujitsu) <
kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> backend> SELECT pg_create_physical_replication_slot(slot_name :=
> 'physical_slot', immediately_reserve := true);
Since this function releases the slot when it returns, re-acquisition, even
by the same backend, must always re-associate MyProcPid to the named slot.
>
> [1]:
> ```
> --- a/src/backend/replication/slot.c
> +++ b/src/backend/replication/slot.c
> @@ -599,7 +599,7 @@ retry:
> SpinLockRelease(&s->mutex);
> }
> else
> - active_pid = MyProcPid;
> + s->active_pid = active_pid = MyProcPid;
> LWLockRelease(ReplicationSlotControlLock);
>
> /*
> ```
>
This, but you cannot modify the slot without holding the spinlock.
I’d probably add an assert that the existing state of s->active_pid is
either 0 or MyProcPid already. In single-user mode it mustn’t, really
cannot, be anything else. But the failure here is because the SQL function
does a slot release; there are probably other reasonable paths where the
assignment of MyProcPid during slot creation is retained and encountered
during a subsequent slot acquire.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Sergey Belyashov | 2025-02-18 06:56:56 | Re: BUG #18815: Logical replication worker Segmentation fault |
Previous Message | John Naylor | 2025-02-18 06:40:13 | Re: Improve CRC32C performance on SSE4.2 |