This question is a follow up on a previous question I posted about efficient ways to max up Postgres pg_wal
directory (for training purposes) : How to bloat pg_wal?.
I'm now wondering what are the possible solutions for getting a Postgres server up and running once the partition is full because pg_wal
has filled up.
I'm interesting in solutions that do not involve adding extra disk space to the partition.
Here are a the 2 other solutions I've come accross while discussing with colleagues :
- Move the entire
pg_wal
directory to another partition with sufficient available disk space and point to this new location from$PGDATA
(ok this is kind of an additional disk space solution) - Regain disk space by removing all WALs that have already been archived (a file with the same name and suffixed by
.done
should be present inpg_wal/archive_status
)
Using pgBackRest
I ran the archive-push
command manually and then removed the WALs from pg_wal
directory but I got the following error when starting Postgres :
2022-06-01 13:54:47 UTC [9334]: user=,db=,app=,client=LOG: invalid primary checkpoint record
2022-06-01 13:54:47 UTC [9334]: user=,db=,app=,client=PANIC: could not locate a valid checkpoint record
Obviously I've removed too many files, but I'm wondering if a clean solution based on the same idea could be used.
Question
Is there a way to clean up pg_wal
without having to restart Postgres once it has shutdown because pg_wal
has filled up ?