Postgres pg_wals full whats best practice for removal of old WALs that were not removed automatically



  • We had an outage on our postgresql-12 server at the weekend, we have pg_wals that reside on a partition that had become full. This then crashed the server due to the space running out.

    We then moved the pg_wals to a different partition and started the server up.

    I can see new pg_wals are generating but have some dating from a day or so ago which have not cleared.

    DB PG Setting:

    archive_command = on
    archive_command = '/home/postgres/bin/walarchiving.bsh %p %f'
    wal_keep_segments = 500
    

    Can I remove the old WALs that pre-date the new start time of postgres? What is the best practice on old WALs after a PG crash.



  • Don't manually delete WAL segments. They get removed automatically if they are no longer needed. If that doesn't happen, something is blocking progress:

    • perhaps the archiver is failing

    • perhaps you have a stale replication slot

    Remove the problem, and PostgreSQL will delete the old files after the next checkpoint.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2