On 13.07.21 09:07, Luca Ferrari wrote:
I'd like to see if I get it right about pg_wal: it grows up to pretty much max_wal_size, at which point a checkpoint is triggered. If the server triggers a timed checkpoint before the pg_wal is at max_wal_size, the system recycles the wals thus keeping the pg_wal size lower than max_wal_size. Is this correct? In particular, what is in simple words, the discrimination between recycling a segment and creating a new one?
Recycling in this context just means that instead of creating a new WAL file for new WAL traffic, it reuses an old file. So if you have WAL files 5, 6, 7, 8, 9, and you know that you don't need 5 and 6 anymore, when you need to start WAL file 10, instead of creating a new file "10", the system just renames "5" to "10" and starts overwriting what was in there. This is just an optimization to use the file system better; it doesn't affect the logical principles of what is going on.