Re: prevent immature WAL streaming

Alvaro Herrera <alvherre@alvh.no-ip.org>

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: masao.fujii@oss.nttdata.com, andres@anarazel.de, pgsql-hackers@lists.postgresql.org, bossartn@amazon.com, mengjuan.cmj@alibaba-inc.com, Jakub.Wartak@tomtom.com
Date: 2021-09-03T17:35:32Z
Lists: pgsql-hackers
On 2021-Sep-03, Kyotaro Horiguchi wrote:

> At Thu, 2 Sep 2021 18:43:33 -0400, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote in 

> The name sounds like the start LSN. doesn't contrecordAbort(ed)Ptr work?
> 
> >  			if (!(pageHeader->xlp_info & XLP_FIRST_IS_CONTRECORD))
> >  			{
> >  				report_invalid_record(state,
> >  									  "there is no contrecord flag at %X/%X",
> >  									  LSN_FORMAT_ARGS(RecPtr));
> > +				goto aborted_contrecord;
> 
> This loses the exclusion check between XLP_FIRST_IS_CONTRECORD and
> _IS_ABROTED_PARTIAL.  Is it okay?  (I don't object to remove the check.).

On second thought, I'm not sure that we should make xlogreader report an
invalid record here.  If we do, how is the user going to recover?
Recovery will stop there and lose whatever was written afterwards.
Maybe you could claim that if both bits are set then WAL is corrupted,
so it's okay to stop recovery.  But if WAL is really corrupted, then the
CRC check will fail.  All in all, I think I'd rather ignore the flag if
we see it set.

At most, we could have an

#ifndef FRONTEND
	ereport(WARNING, "found unexpected flag xyz");
#endif

or something like that.  However, xlogreader does not currently have
anything like that, so I'm not completely sure.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/



Commits

  1. Fix determination of broken LSN in OVERWRITTEN_CONTRECORD

  2. Fix instability in 026_overwrite_contrecord.pl test.

  3. Fix typo

  4. Change recently added test code for stability

  5. Remove unstable, unnecessary test; fix typo

  6. Repair two portability oversights of new test

  7. Fix WAL replay in presence of an incomplete record

  8. Document XLOG_INCLUDE_XID a little better

  9. Revert "Avoid creating archive status ".ready" files too early"

  10. Avoid creating archive status ".ready" files too early

  11. Fix scenario where streaming standby gets stuck at a continuation record.

  12. Teach xlogreader to follow timeline switches

  13. Forbid using pg_xlogfile_name() and pg_xlogfile_name_offset() during