Re: Copy function for logical replication slots - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Copy function for logical replication slots
Date
Msg-id 20190220032613.GC15532@paquier.xyz
Whole thread Raw
In response to Re: Copy function for logical replication slots  (Masahiko Sawada <sawada.mshk@gmail.com>)
Responses Re: Copy function for logical replication slots
List pgsql-hackers
On Tue, Feb 19, 2019 at 05:09:33PM +0900, Masahiko Sawada wrote:
> On Tue, Feb 19, 2019 at 1:28 AM Andres Freund <andres@anarazel.de> wrote:
>> Well, I'd not thought we'd do it without acquiring the other slot. But
>> that still seems to be easy enough to address, we just need to recheck
>> whether the slot still exists (with the right name) the second time we
>> acquire the spinlock?
>
> Yeah, I think that would work. The attached patch takes this
> direction. Please review it.

+     if (XLogRecPtrIsInvalid(copy_restart_lsn) ||
+              copy_restart_lsn < src_restart_lsn ||
+              src_islogical != copy_islogical ||
+              strcmp(copy_name, NameStr(*src_name)) != 0)
+              ereport(ERROR,
+                              (errmsg("could not copy logical replication slot \"%s\"",
+                               NameStr(*src_name)),
+                               errdetail("The source replication slot has been dropped during copy")));
+
+      /* Install copied values again */
+      SpinLockAcquire(&MyReplicationSlot->mutex);

Worth worrying about this window not reduced to zero?  If the slot is
dropped between both then the same issue would arise.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Delay locking partitions during INSERT and UPDATE
Next
From: Юрий Соколов
Date:
Subject: Re: Compressed TOAST Slicing