Re: [HACKERS] Bug in Physical Replication Slots (at least 9.5)?

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: michael(dot)paquier(at)gmail(dot)com
Cc: jdnelson(at)dyn(dot)com, pgsql-hackers(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: Re: [HACKERS] Bug in Physical Replication Slots (at least 9.5)?
Date: 2017-02-01 07:41:38
Message-ID: 20170201.164138.24166847.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hello, I'll add the rebased version to the next CF.

At Fri, 20 Jan 2017 11:07:29 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote in <20170120(dot)110729(dot)107284864(dot)horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
> > > > - Delaying recycling a segment until the last partial record on it
> > > > completes. This seems doable in page-wise (coarse resolution)
> > > > but would cost additional reading of past xlog files (page
> > > > header of past pages is required).
> > >
> > > Hm, yes. That looks like the least invasive way to go. At least that
> > > looks more correct than the others.
> >
> > The attached patch does that. Usually it reads page headers only
> > on segment boundaries, but once continuation record found (or
> > failed to read the next page header, that is, the first record on
> > the first page in the next segment has not been replicated), it
> > becomes to happen on every page boundary until non-continuation
> > page comes.
> >
> > I leave a debug info (at LOG level) in the attached file shown on
> > every state change of keep pointer. At least for pgbench, the
> > cost seems ignorable.
>
> I revised it. It became neater and less invasive.
>
> - Removed added keep from struct WalSnd. It is never referrenced
> from other processes. It is static variable now.
>
> - Restore keepPtr from replication slot on starting.

keepPtr is renamed to a more meaningful name restartLSN.

> - Moved the main part to more appropriate position.

- Removed the debug print code.

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
0001-Fix-a-bug-of-physical-replication-slot.patch text/x-patch 7.3 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message krzysztof.heim 2017-02-01 10:23:03 BUG #14521: pg_attribute.attndims = 0 for array column
Previous Message Stephen Frost 2017-01-30 04:30:48 Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2017-02-01 07:46:43 Re: Parallel tuplesort (for parallel B-Tree index creation)
Previous Message Rahila Syed 2017-02-01 07:40:06 Re: Parallel Index Scans