On Wed, Jun 10, 2015 at 8:07 AM, Andres Freund <[email protected]> wrote:
> On 2015-06-10 08:00:28 -0700, Gurjeet Singh wrote:
>
> > 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.
>
> There's no need to change anything for logical slots? Or do you just
> mean that you moved the existing code?
>
Yes, I turned the code from logical replication into a function and used it
from logical and physical replication.
> >
> > /*
> > + * Grab and save an LSN value to prevent WAL recycling past that point.
> > + */
> > +void
> > +ReplicationSlotRegisterRestartLSN()
> > +{
...
> > + /*
> > + * Let's start with enough information if we can, so log a
> standby
> > + * snapshot and start decoding at exactly that position.
> > + */
> > + if (!RecoveryInProgress())
> > + {
> > + XLogRecPtr flushptr;
> > +
> > + /* start at current insert position */
> > + slot->data.restart_lsn = GetXLogInsertRecPtr();
> > +
> > + /* make sure we have enough information to start */
> > + flushptr = LogStandbySnapshot();
> > +
> > + /* and make sure it's fsynced to disk */
> > + XLogFlush(flushptr);
> > + }
> > + else
> > + slot->data.restart_lsn = GetRedoRecPtr();
> > +
>
> That doesn't look right to me. Why is this code logging a standby
> snapshot for physical slots?
>
This is the new function I referred to above. The logging of the snapshot
is in 'not RecoveryInProgress()' case, meaning it's running in primary and
not in a standby.
Best regards,
--
Gurjeet Singh http://gurjeet.singh.im/