From: | Gurjeet Singh <gurjeet(at)singh(dot)im> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | "Duran, Danilo" <danilod(at)amazon(dot)com>, "robertmhaas(at)gmail(dot)com" <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: replication slot restart_lsn initialization |
Date: | 2015-06-10 15:24:23 |
Message-ID: | CABwTF4VGZu5Gyw0+Ts3hd-rDcRpjKe0TmwD9JJTQSN8H-zq9fQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Jun 10, 2015 at 8:07 AM, Andres Freund <andres(at)anarazel(dot)de> 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/
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2015-06-10 15:29:38 | Re: skipping pg_log in basebackup (was Re: pg_basebackup and pg_stat_tmp directory) |
Previous Message | Andres Freund | 2015-06-10 15:17:15 | Re: s_lock() seems too aggressive for machines with many sockets |