Re: prevent immature WAL streaming

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, masao(dot)fujii(at)oss(dot)nttdata(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org, bossartn(at)amazon(dot)com, mengjuan(dot)cmj(at)alibaba-inc(dot)com, Jakub(dot)Wartak(at)tomtom(dot)com
Subject: Re: prevent immature WAL streaming
Date: 2021-09-04 16:22:05
Message-ID: 202109041622.kq27alud7pir@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-Sep-03, Andres Freund wrote:

> Hi,
>
> On 2021-09-03 20:01:50 -0400, Alvaro Herrera wrote:
> > From 6abc5026f92b99d704bff527d1306eb8588635e9 Mon Sep 17 00:00:00 2001
> > From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
> > Date: Tue, 31 Aug 2021 20:55:10 -0400
> > Subject: [PATCH v3 1/5] Revert "Avoid creating archive status ".ready" files
> > too early"
>
> > This reverts commit 515e3d84a0b58b58eb30194209d2bc47ed349f5b.
>
> I'd prefer to see this pushed soon. I've a bunch of patches to xlog.c that
> conflict with the prior changes, and rebasing back and forth isn't that much
> fun...

Done.

> > + /*
> > + * If we were expecting a continuation record and got an "aborted
> > + * partial" flag, that means the continuation record was lost.
> > + * Ignore the record we were reading, since we now know it's broken
> > + * and lost forever, and restart the read by assuming the address
> > + * to read is the location where we found this flag.
> > + */
> > + if (pageHeader->xlp_info & XLP_FIRST_IS_ABORTED_PARTIAL)
> > + {
> > + ResetDecoder(state);
> > + RecPtr = targetPagePtr;
> > + goto restart;
> > + }
>
> I think we need to add more validation to this path. What I was proposing
> earlier is that we add a new special type of record at the start of an
> XLP_FIRST_IS_ABORTED_PARTIAL page, which contains a) lsn of the record we're
> aborting, b) checksum of the data up to this point.

Hmm, a new record type? Yeah, we can do that, and sounds like it would
make things simpler too -- I wasn't too happy about adding clutter to
AdvanceXLInsertBuffer either, but the alternative I had in mind was that
we'd pass the flag to the checkpointer, which seemed quite annoying API
wise. But if we add a new record, seems we can write it directly in
StartupXLOG and avoid most nastiness. I'm not too sure about the
checksum up to this point, though, but I'll spend some time with the
idea to see how bad it is.

--
Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/
Voy a acabar con todos los humanos / con los humanos yo acabaré
voy a acabar con todos (bis) / con todos los humanos acabaré ¡acabaré! (Bender)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-09-04 16:42:08 Re: [PATCH] Add tab-complete for backslash commands
Previous Message Noah Misch 2021-09-04 16:18:17 Re: public schema default ACL