0

I'm using Postgres 9.3 and I have a master database and a hot standby one that is following the master. The operating system is CentOS 7.

I've changed the way of starting Posgres from SysV to systemd. I've used the standard /usr/lib/systemd/system/postgresql-9.3.service, and it's much more simplified than the old SysV script.

After the change, I've observed that it continues to work ok. The only downside is that the archives in the hot standby are never deleted. It is like the archive_cleanup_command in recovery.conf were ignored.

In the .service, Postgres is started in this way:

pg_ctl start -D ${PGDATA} -s -w -t 300

whereas in SysV in this other way:

postmaster -p $PGPORT -D $PGDATA

I think both of them are quite equivalent.

If I change back to SysV, then archives are not accumulated any more.

Why my archives aren't cleaned up with systemd?

  • 1
    Try to add more logging to PotgreSQL and look at systemd logging about PostgreSQL to find anything related. Try to temporarily replace your command in archive_cleanup_commad by a simple shell just creating a file, to see if it is executed or not at all. It may be a permissions problem, depending on what your command does. – Patrick Mevzek Dec 22 '17 at 22:42
  • Good suggestions – david.perez Dec 28 '17 at 14:29
0

The problem is that the PATH environment is different.

I had this line in recovery.conf:

archive_cleanup_command = 'pg_archivecleanup /var/lib/pgsql/9.3/standby/archive %r'

And Postgres doesn't find pg_archivecleanup and silently ignores it.

Solution is to change the line to this:

archive_cleanup_command = '/usr/pgsql-9.3/bin/pg_archivecleanup /var/lib/pgsql/9.3/standby/archive %r'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.