Subject: recovery.conf and archive_cleanup_command

From: Rita <[email-masked]>
Date: Sat, 8 Oct 2022 08:51:08 -0400

I have primary and standby replication setup.

On my primary the archive directory is rather large (30GB) and growing. On
my standby I have recovery.conf which has
archive_cleanup_command = 'pg_archivecleanup -d
/var/lib/pgsql/11/data/archive %r'

I was under the impression this line would remove data from my primary AND
standby. Is that not the case?

-- 
--- Get your facts first, then you can distort them as you please.--

---

From: Laurenz Albe <[email-masked]>
Date: Sun, 09 Oct 2022 19:32:51 +0200

On Sat, 2022-10-08 at 08:51 -0400, Rita wrote:
> On my primary the archive directory is rather large (30GB) and growing. On my standby I have recovery.conf which has 
> archive_cleanup_command = 'pg_archivecleanup -d /var/lib/pgsql/11/data/archive %r'
> 
> I was under the impression this line would remove data from my primary AND standby. Is that not the case?

That depends on your PostgreSQL version, for instance.

Also, it depends on whether the standby server is running and actually recovering.
Finally, it depends on whether the standby can execute the command successfully or not.

Did you look at the standby's logs?

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com

---

From: Yang Steve <[email-masked]>
Date: Fri, 12 May 2023 23:45:53 +1000

I am using PostgreSQL Version 15 now, however, archive_cleanup_command only
triggered on standby box, not on primary. Is that expected as designing?

Laurenz Albe <[email-masked]> 于2022年10月10日周一 04:33写道：

> > On my primary the archive directory is rather large (30GB) and growing.
> On my standby I have recovery.conf which has

---

From: Laurenz Albe <[email-masked]>
Date: Fri, 12 May 2023 16:52:56 +0200

On Fri, 2023-05-12 at 23:45 +1000, Yang Steve wrote:
> I am using PostgreSQL Version 15 now, however, archive_cleanup_command only triggered on standby box, not on primary.
> Is that expected as designing?

Yes.  It is a recovery parameter, and they are only used if PostgreSQL is in recovery.
The parameter makes no sense unless you are recovering.

Yours,
Laurenz Albe