I'm currently confronted with an issue of rapidly incresing used diskspace on a server that hosts a postgres database. When looking deeper into it I found out the space of the WAL directory has doubled in size and thus caused the rapid increase in used diskspace. So it was no gradual increase of the WAL size but a rapid spike happening in under a minute.
The min_wal_size and max_wal_size parameters of postgres are currently set to 4GB and 8GB respectively. The WAL size used to be 4GB for some time and then suddenly increased to 8GB. During this increase (and also for some hours before) I ran a python script. This script acts on a table and copies over all the values that are not NULL from an older column to the respective rows in a newer column which are currently still NULL. This happens for several columns pairs. The scrip uses Afterwards it drops the old column. The script uses sqlalchemy to interact with the postgres database.
As I understand it even though the actual data in the WAL log may not take up the size indicated by min_wal_size the space occupied by the WAL files will not decrease below this value after the checkpoints when the data from the shared buffers gets written do disk.
What I do not understand is: What happens if at some point the data in the WAL files takes up more space than min_wal_size? Will new WAL files get created one by one, or is a batch of new WAL files created at once and then populated with data incrementally afterwards?
I don't understand why this doublind in the WAL size happens at some random point in time when the script was running for a while.