On Fri, May 6, 2022 at 10:20 PM Tom Lane <t...@sss.pgh.pa.us> wrote: > > Bharath Rupireddy <bharath.rupireddyforpostg...@gmail.com> writes: > > Can postgres delete the recycled future WAL files once max_wal_size is > > reduced and/or wal_recycle is set to off? > > A checkpoint should do that, see RemoveOldXlogFiles. > > Maybe you have a broken WAL archiving setup, or something else preventing > removal of old WAL files?
Thanks Tom. My test case is simple [1], no archiving, no replication slots - just plain initdb-ed cluster. My expectation is that whenever max_wal_size/wal_recycle is changed from the last checkpoint value, postgres must be able to delete "optionally" "all or some of" the future WAL files to free-up some disk space (which is about to get full) so that I can avoid server crashes and I will have some time to go scale the disk. [1] show min_wal_size; show max_wal_size; show wal_recycle; drop table foo; create table foo(col int); -- run below pg_switch_wal and insert statements 9 times. select pg_switch_wal(); insert into foo select * from generate_series(1, 1000); select redo_wal_file from pg_control_checkpoint(); checkpoint; --there will be around 10 recycled WAL future WAL files. alter system set max_wal_size to '240MB'; select pg_reload_conf(); show max_wal_size; checkpoint; --future WAL files will not be deleted. alter system set min_wal_size to '24MB'; select pg_reload_conf(); show min_wal_size; checkpoint; --future WAL files will not be deleted. alter system set wal_recycle to off; select pg_reload_conf(); show wal_recycle; checkpoint; --future WAL files will not be deleted. Regards, Bharath Rupireddy.