Re: pg_rewind WAL segments deletion pitfall

From: Polina Bungina <bungina(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: cyberdemn(at)gmail(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pg_rewind WAL segments deletion pitfall
Date: 2022-09-28 08:09:05
Message-ID: CAAtGL4A7zc9u+Gy0_kzcJZDmkrJL-cn1UO3LygXrVB0o6RZKkQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Tue, Sep 27, 2022 at 9:50 AM Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
wrote:

> Regarding the the patch, pg_rewind starts reading segments from the
> divergence point back to the nearest checkpoint, then moves foward
> during rewinding. So, the fact that SimpleXLogPageRead have read a
> segment suggests that the segment is required during the next startup.
> So I don't think we need to move around the keepWalSeg flag. All
> files that are wanted while rewinding should be preserved
> unconditionally.
>

I am probably not getting this right but as far as I see SimpleXLogPageRead
is called at most 3 times during pg_rewind run:
1. From readOneRecord to determine the end-of-WAL on the target by reading
the last shutdown checkpoint record/minRecoveryPoint on it
2. From findLastCheckpoint to find last common checkpoint (here it
indeed reads all the segments that are required during the startup, hence
the keepWalSeg flag set to true)
3. From extractPageMap to extract all the pages modified after the fork
(here we also read all the segments that should be kept but also the ones
further, until the target's end record. Doesn't seem we should
unconditionally preserve them all).
Am I missing something?

> + /*
> + * Some entries (WAL segments) already have an action
> assigned
> + * (see SimpleXLogPageRead()).
> + */
> + if (entry->action == FILE_ACTION_NONE)
> + continue;
> entry->action = decide_file_action(entry);

It might be more reasonable to call decide_file_action() when action
> is UNDECIDED.
>

Agree, will change this part.

Regards,
Polina Bungina

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kyotaro Horiguchi 2022-09-28 09:17:39 Re: pg_rewind WAL segments deletion pitfall
Previous Message Masahiko Sawada 2022-09-28 02:23:16 Re: BUG #17385: "RESET transaction_isolation" inside serializable transaction causes Assert at the transaction end

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-09-28 08:17:25 Re: A doubt about a newly added errdetail
Previous Message John Naylor 2022-09-28 07:49:43 Re: [PoC] Improve dead tuple storage for lazy vacuum