Re: replication slot restart_lsn initialization - Mailing list pgsql-hackers

From Gurjeet Singh
Subject Re: replication slot restart_lsn initialization
Date
Msg-id CABwTF4VZR0E-CGCCT=-uuB+=Eau_8h4-BYn7L2DBWDNNduwiVw@mail.gmail.com
Whole thread Raw
In response to Re: replication slot restart_lsn initialization  (Andres Freund <andres@anarazel.de>)
Responses Re: replication slot restart_lsn initialization  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Tue, May 5, 2015 at 5:53 PM, Andres Freund <andres@anarazel.de> wrote:

> Was there any consideration for initializing restart_lsn to the latest
> WAL write pointer when a slot is created? Or for allowing an optional
> parameter in pg_create_(physical|logical)_replication_slot() for
> specifying the restart_lsn at slot creation?

I've been wondering about allowing for the latter alternative. I could
have used it a couple times. The former doesn't make much sense to me,
it could be too far *ahead* in many cases actually.  A patch for this
would be fairly trivial.

Attached is the patch that takes the former approach (initialize restart_lsn when the slot is created). I think it's better than the latter approach (depend on user to specify an LSN) because the LSN user specifies may have already been recycled. pg_create_logical_replication_slot() prevents LSN from being recycled that by looping (worst case 2 times) until there's no conflict with the checkpointer recycling the segment. So I have used the same approach.

The function pg_create_physical_replication_slot() now has an additional boolean parameter 'activate' which user can use to allocate restart_lsn as part of the creation process.

Best regards,
--
Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: s_lock() seems too aggressive for machines with many sockets
Next
From: Andres Freund
Date:
Subject: Re: s_lock() seems too aggressive for machines with many sockets