Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u2rjR-0071gX-5R for pgsql-general@arkaria.postgresql.org; Thu, 10 Apr 2025 13:14:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u2riR-00Bef1-4p for pgsql-general@arkaria.postgresql.org; Thu, 10 Apr 2025 13:13:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u2riQ-00Beer-Pi for pgsql-general@lists.postgresql.org; Thu, 10 Apr 2025 13:13:11 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u2riO-004Wm0-20 for pgsql-general@lists.postgresql.org; Thu, 10 Apr 2025 13:13:10 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-736ee709c11so565080b3a.1 for ; Thu, 10 Apr 2025 06:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744290786; x=1744895586; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=4Xn3tra/W1CdRJE1XOapzL6X1XAXN9An3Gj5ojobyms=; b=iFTx+h1G/vki/UJiGJx2evLLqOAYK9q/9SMvnluzUTN/RcYY+e0Po//BgLTzO97clP olBwEZ7pX4zsbPahfB1RvqZLgR4dDuYg/G6SLkYUUJVdDLZyAhR8ANJdV18IBZIFCB47 G0NfNo8vG46kGySVpj/AN6gnLA9bPQKbQ4VeDbRdJhABB/gImSb7iNZ9qJw1wDT0j0kv J1zB6EagqJSgRLR9Nf/rKr0eycHJ/PlYgElIOCPW19xOpDjuWDFMqHWhGoOF5TibwC7W HE10+WVCstnQS7jS1CSMPXcjb0RqqnBdh2OgurR2sd/waVKApk2VhxhgObZBfWlH0VJr r+xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744290786; x=1744895586; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4Xn3tra/W1CdRJE1XOapzL6X1XAXN9An3Gj5ojobyms=; b=nlXPqysmsU++jbsOnc8tVsacy5hw91KdLKg1tCBCqDGEK7OGPMCniMPOWlcM5IuoSZ o/8LhtTJ1sYheV9vYxOZHi1zktYSU4S9fiFj/2oOSbYMK+xM9CWLSlYO7stA75VmoX5z D/0j3Aqmtw7cYyyoB5m30FlBjIKVyppziZb1zlEmkdNGbYZDyGyv/84vACLXRy+FVc6z tL9tCgXHonLjX0Q/kZtHP815lj/5sfPqypejSMfCbNX1u+7kUmue0/1jjprm9jKGSjzr JUhHSrT7im4bCMmc/iIce7ceUWlVatyR9APrIHBSU8Sf6He5s1IdjPkvN7bPRWGdKC1G RHMw== X-Gm-Message-State: AOJu0YwdV/TQkdSLVBfsPrX3rxuPhndK2A1CcyD1f5CjKrNfpvJ70CDg LbxIYgA0HuSs5Qi5OM51Ybk0sYBnsf+TDu4seniyhQkghhBYFGQau2kctSdRnzUsUwaAfSTHHe6 dwa+xp4U5yPY/7HHB7o6j1X0OhGPrMA== X-Gm-Gg: ASbGnctJHDUz7WSBcsyN74+NUUlaa71JAwYfAKbg0iRz6izvLg2JpthY95/0dNxacD2 i0gdoSG1ZYUBL+vTRTGrNexJeZnkpTjC+23xFQchoEKa6IlD03UU2+GP9S72VMWAhpZgqTQNJF1 G+EYoewvEvHA8fV24w8F/yJkar X-Google-Smtp-Source: AGHT+IFMhgwgQET19cqhKzihM23dKOLR+1QZmhzxmxyXIpaxbv1yeRKx95MMWsZLr+lhQoAPorpI7cx6FpTtnGYSgmw= X-Received: by 2002:a05:6a00:170b:b0:736:4110:5579 with SMTP id d2e1a72fcca58-73bc0a074eamr3461174b3a.2.1744290785935; Thu, 10 Apr 2025 06:13:05 -0700 (PDT) MIME-Version: 1.0 References: <399f53cd1274345d0301dd7ecf016ae749e87abe.camel@cybertec.at> In-Reply-To: <399f53cd1274345d0301dd7ecf016ae749e87abe.camel@cybertec.at> From: Justin Swanhart Date: Thu, 10 Apr 2025 09:12:52 -0400 X-Gm-Features: ATxdqUF9qbCa1ewBO_Jwa6F26chLGI-d6e-EyYhF4do5v4kwTUcvPKJXl-y9QlE Message-ID: Subject: Re: Archive logging not cleaning up pg_wal directory To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000ae49f306326c5801" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ae49f306326c5801 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you very much. I had a stale replication slot. I removed it and the logs were cleaned up immediately. --Justin On Thu, Apr 10, 2025 at 8:48=E2=80=AFAM Laurenz Albe wrote: > On Thu, 2025-04-10 at 08:28 -0400, Justin Swanhart wrote: > > I have the following in my postgresql.conf for archive logging: > > archive_command=3D'test ! -f /var/lib/postgresql/prod_archive_logs/%f &= & > cp %p /var/lib/postgresql/prod_archive_logs/%f' > > > > This command is properly copying the log files to my archive directory > but they remain in the `pg_wal` > > directory after they are copied, consuming hundreds of gigs of space. > Am I supposed to create a cron > > job to clean out the `pg_wal` directory periodically (keep only 1 day o= f > logs I guess?) > > > > I tried to use mv: > > archive_command=3D'test ! -f /var/lib/postgresql/prod_archive_logs/%f &= & > mv %p /var/lib/postgresql/prod_archive_logs/%f' > > > > When I did this the archives were moved away to the archive directory > but when I tried to set up > > replication the server could not find the archived log to replicate fro= m > so I changed it to "cp" and now have this problem. > > > > What am I missing? > > Something else is blocking WAL removal: > https://www.cybertec-postgresql.com/en/why-does-my-pg_wal-keep-growing/ > > Since you mention replication, my money is on a stale replication slot. > > Yours, > Laurenz Albe > --000000000000ae49f306326c5801 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you very much.=C2=A0 I had a stale replication = slot.=C2=A0 I removed it and the logs were cleaned up immediately.

--Justin

On Thu, Apr 10, 2025 at 8:48= =E2=80=AFAM Laurenz Albe <la= urenz.albe@cybertec.at> wrote:
On Thu, 2025-04-10 at 08:28 -0400, Justin Swanhart wr= ote:
> I have the following in my postgresql.conf for archive logging:
> archive_command=3D'test ! -f /var/lib/postgresql/prod_archive_logs= /%f && cp %p /var/lib/postgresql/prod_archive_logs/%f'
>
> This command is properly copying the log files to my archive directory= but they remain in the `pg_wal`
> directory after they are copied, consuming hundreds of gigs of space.= =C2=A0 Am I supposed to create a cron
> job to clean out the `pg_wal` directory periodically (keep only 1 day = of logs I guess?)
>
> I tried to use mv:
> archive_command=3D'test ! -f /var/lib/postgresql/prod_archive_logs= /%f && mv %p /var/lib/postgresql/prod_archive_logs/%f'
>
> When I did this the archives were moved away to the archive directory = but when I tried to set up
> replication the server could not find the=C2=A0archived log to replica= te from so I changed it to "cp" and now have this problem.
>
> What am I missing?

Something else is blocking WAL removal:
https://www.cybertec-postgres= ql.com/en/why-does-my-pg_wal-keep-growing/

Since you mention replication, my money is on a stale replication slot.

Yours,
Laurenz Albe
--000000000000ae49f306326c5801--