Re: pg_rewind WAL segments deletion pitfall

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: cyberdemn(at)gmail(dot)com
Cc: bungina(at)gmail(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pg_rewind WAL segments deletion pitfall
Date: 2022-08-30 08:27:30
Message-ID: 20220830.172730.239599907718280881.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

At Tue, 30 Aug 2022 10:03:07 +0200, Alexander Kukushkin <cyberdemn(at)gmail(dot)com> wrote in
> On Tue, 30 Aug 2022 at 09:51, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
> wrote:
> > And as I said in a mail I sent just before, the patch looks too
> > complex. How about just comparing WAL file name aginst the last
> > common checkpoint's tli and lsn? We can tell filemap.c about the last
> > checkpoint and decide_file_action can compare the file name with it.
> >
> > It is sufficient to preserve WAL files if tli matches and the segment
> > number of the WAL file is equal to or later than the checkpoint
> > location.
> >
>
> What if the last common checkpoint was on a previous timeline?
> I.e., standby was promoted to primary, the timeline changed from 1 to 2,
> and after that the node crashed _before_ the CHECKPOINT after promote has
> finished.
> The next node will advance the timeline from 2 to 3.
> In this case, the last common checkpoint will be on timeline 1, and the
> check becomes more complex because we will have to consider both timelines,
> 1 and 2.

Hmm. Doesn't it work to ignoring tli then? All segments that their
segment number is equal to or larger than the checkpoint locaiton are
preserved regardless of TLI?

> Also, we need to take into account the divergency LSN. Files after it are
> not required.

They are removed at the later checkpoints. But also we can remove
segments that are out of the range between the last common checkpoint
and divergence point ignoring TLI. the divergence point is also
compared?

> if (file_segno >= last_common_checkpoint_seg &&
> file_segno <= divergence_seg)
> <PRESERVE IT>;

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message hubert depesz lubaczewski 2022-08-30 09:01:45 Re: Excessive number of replication slots for 12->14 logical replication
Previous Message Alexander Kukushkin 2022-08-30 08:03:07 Re: pg_rewind WAL segments deletion pitfall

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2022-08-30 08:33:24 Re: Reducing the chunk header sizes on all memory context types
Previous Message Amit Langote 2022-08-30 08:09:44 Re: SQL/JSON features for v15