How WAL segments should be written?

From: Mohab Yaser <mohabyaserofficial2003(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: How WAL segments should be written?
Date: 2025-08-02 06:39:18
Message-ID: CAEnf3iByRW40sEwx6HF2nT0JFaTDxO9bRHTp6DHvJRd66szE+A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello guys,

I was working on pgmoneta, specifically on a new project where we can
filter some actions that happened after a certain backup was taken. You can
take a look at it here
<https://github.com/pgmoneta/pgmoneta/discussions/630> to get some context.
Currently, I am in the phase where I have read some WAL files, removed the
records I don't want from them, and the next step is to write them back to
disk. If I started with these WAL files:
```
file 1: 10 records
file 2: 10 records
file 3: 10 records
file 4: 10 records
```
and after filtering, I ended up with these files:
```
file 1: 8 records
file 2: 5 records
file 3: 10 records
file 4: 3 records
```

Can I just write these files with their current number of records, leaving
gaps where there are fewer records, while maintaining the 16MB/file
constraint (or `--wal-segsize`, whatever the value)? Or do I need to
compact them to fill each file completely? In the first option, I would
write some records and zero-pad the rest of the file.

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2025-08-02 08:00:00 Re: Improving tracking/processing of buildfarm test failures
Previous Message Andrew Dunstan 2025-08-02 00:51:07 Re: Add support for specifying tables in pg_createsubscriber.