Postgres WAL files clean up

Is there any way how I can clean up postgres WAL files ON MASTER SERVER - SLAVE is OK, but master has wal keep segment set to 2000 and this is causing disk space usage to grow. I'm looking for a way how to clean up that disk space on MASTER without breaking anything. I know that setting keep segments to 2000 is madness but that was not set by me.


Solution 1:

Address the underlying cause and the problem will go away (your underlying problem being someone who didn't know what they were doing and didn't read the Postgres manual set wal_keep_segments to an insane value):

  1. Reduce wal_keep_segments to a sane value.
    (10 is usually sane. 100 is not unreasonable).
  2. Restart the Postgres server.