Re: Force the old transactions logs cleanup even if checkpoint is skipped

From: "Zakhlystov, Daniil (Nebius)" <usernamedt(at)nebius(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: "amborodin(at)acm(dot)org" <amborodin(at)acm(dot)org>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Mokrushin, Mikhail (Nebius)" <rodrijjke(at)nebius(dot)com>
Subject: Re: Force the old transactions logs cleanup even if checkpoint is skipped
Date: 2023-11-08 12:44:09
Message-ID: AM9P190MB1234B376A0DF31F8003A2330B5A8A@AM9P190MB1234.EURP190.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

Thanks for your review.

> I am not sure to understand your last sentence here. Once the
> archiver is back up, you mean that the WAL segments that were not
> previously archived still are still not archived? Or do you mean that
> because of a succession of checkpoint skipped we are just enable to
> remove them from pg_wal.

Yes, the latter is correct - we are unable to clean up the already archived WALs
due to the checkpoint being skipped.

> I am not convinced that this is worth the addition in the skipped
> path. If your system is idle and a set of checkpoints is skipped, the
> data folder is not going to be under extra space pressure because of
> database activity (okay, unlogged tables even if these would generate
> some WAL for init pages), because there is nothing happening in it
> with no "important" WAL generated. Note that the backend is very
> unlikely going to generate WAL only marked with XLOG_MARK_UNIMPORTANT.

> More to the point: what's the origin of the disk space issues? System
> logs, unlogged tables or something else? It is usually a good
> practice to move logs to a different partition. At the end, it sounds
> to me that removing segments more aggressively is just kicking the can
> elsewhere, without taking care of the origin of the disk issues.

This problem arises when disk space issues are caused by temporary failed archiving.
As a result, the pg_wal becomes filled with WALs. This situation
leads to Postgres being unable to perform any write operations since there is no more
free disk space left. Usually, cloud providers switch the cluster to a Read-Only mode
if there is less than 3-4% of the available disk space left, but this also does not resolve
this problem.

The actual problem is that after archiving starts working normally again, Postgres is
unable to free the accumulated WAL and switch to Read-Write mode due to the
checkpoint being skipped, leading to a vicious circle. However, nothing prevents
Postgres from exiting such situations on its own. This patch addresses this specific
behavior, enabling Postgres to resolve such situations autonomously.

Thank you,

Daniil Zakhlystov

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Euler Taveira 2023-11-08 12:50:47 Re: speed up a logical replica setup
Previous Message Alvaro Herrera 2023-11-08 12:32:41 Re: pgsql: Clean up role created in new subscription test.