If there is no max limit on how many files can be on FS at some point it will fill up disk space right? so you are saying if we dont have correct archive_command , postgres will do nothing? in my case i did not set archive_command. But from postgres documentation "The number of WAL segment files in pg_xlog directory depends on min_wal_size, max_wal_size and the amount of WAL generated in previous checkpoint cycles. When old log segment files are no longer needed, they are removed or recycled (that is, renamed to become future segments in the numbered sequence)." This statement is little confusing me with what you have said: "If that’s not correct, nothing will remove the WAL files.".
Remember that keep_wal_segments is a minimum setting, not a maximum one. It’s telling the database to maintain at least that many segments. Plus, check how you’ve set the archive_command. If that’s not correct, nothing will remove the WAL files.
I have changed the wal_keep_segments=100 and restarted the postgresql processes but i still see 500+ files under pg_xlog, i had to run checkpoint manually to clean.
On Wed, Jan 30, 2019 at 5:00 PM Alvaro Herrera <alvherre@2ndquadrant.com> wrote: > Hmm ... I would recommend to keep the xlog files in a subdir, not the > root of the filesystem.
They are in a subdir (under /opt/pgdata), and the OP seems likely to have omitted the self/parent hidden directories during his check as well. Plus per the docs we actually expect 501 so there isn't a need to account for 6 extra, just 5.