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 1u2rKA-006wB4-A5 for pgsql-general@arkaria.postgresql.org; Thu, 10 Apr 2025 12:48:06 +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 1u2rK8-00BVe8-NZ for pgsql-general@arkaria.postgresql.org; Thu, 10 Apr 2025 12:48:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u2rK8-00BVdz-CT for pgsql-general@lists.postgresql.org; Thu, 10 Apr 2025 12:48:04 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u2rK6-0043sy-2c for pgsql-general@lists.postgresql.org; Thu, 10 Apr 2025 12:48:03 +0000 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5e60cfef9cfso1335332a12.2 for ; Thu, 10 Apr 2025 05:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1744289281; x=1744894081; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=dq7+lChNbR+0IZs4s0HMbN8tURQ1sdlzpuB8Fm83DKY=; b=L9UxSeeZWmarc3BuUWMdBFv2cXS+s2DNqbHCi7biWmk067t4kQFXnLCH8r/UdvGteO ynhe43ogRUZWm07gPddtEVjmoyApOB0PsvrScDpyp80OFqhLBSAItxFtlXJW6gaSKxcx Gz/jjKAVj3AjaqaM+qF+sDPcE1NENVruVk9XVU86hMSkyEQpsFBPYZEcHp90lYYElliH +9xG9UIaEpZdQPv1LpSj7s0tGOnC/K8ZpBVQ97tsimOIXItArQ+xulZpDOpHUS4wP5wX 6YSbMt8L6r7vv7w2LLOvr/JsidSedkdj/ybd5u6aoA9Rd7QSOSqHDRXAnIMHq2aaTYKi JwZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744289281; x=1744894081; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=dq7+lChNbR+0IZs4s0HMbN8tURQ1sdlzpuB8Fm83DKY=; b=Cel8nY1y2+o6MK0vH1b6j8KmUMMoUOhDktOxAyZEk75i2XHwcc5w1bhzMcHXVVyzLV qYKQ9K2dRvnmRuvpgFge32n6QMHrOK7v56iCF3JNiNuwSzAdh4N/obOzKpipJB96O57P lC8+2YR6jbcco+dTgx/MGzgXnyiIVM5xRLpRddMO7yxGY90vo5gU5OQWlGFwZRqbJqv0 9/RTiV+lqL08x8329tqSM2nz6FhrWX+BJx1qgODHLNxJePpkYoChnoIqm59pciJZqqMJ yyM7717nxJAG2Jw906RyM8wkjwMhBzs5MfY1Artmw7JIBDua9cnqerg+PcSyo+qpBQbX pkog== X-Forwarded-Encrypted: i=1; AJvYcCUE2NYrf3RCBm51UGYeIl4xYc/xrGG8bZs/mCTFSRCj9vMy6avypWSMS27WTUgslzH1u8eH63iW//nRPwYr@lists.postgresql.org X-Gm-Message-State: AOJu0YyjK7AMeS3R7yK4Zwu+vKTqiO5w3rQijwk+tIiSZyecGE8o9gDP QYK7QGdh3PddmllWEkZVNhJNBF64Qp8yHOyGzNuuRmbW4oDZvax2h+1zfcb2Ik7/BXM+oGN2Ggv 3 X-Gm-Gg: ASbGncuGTqCJqzFC49heP8GtwXF7x6YlzYC2inM9Zwbnit4lkSmxx9RbTYgALtdwZG2 UwNPqVfEhez/pBjNx1AB3Y0VgSWk9vDSoRFqw1ZvsvNBMMsZSSQryZMcgOLv3ZA3vxHEjZ3whCK Fgj4g9QxyqncPRRwGpCoDz2ltkDRYyXcQh8dCCmKbUR8W75FRk33qYTILzA/5FDWdA2zqnQTnst SsVOfvk2isQc6jFA1cRTJWfveg3nf04hVf9TcdJtFD5PuXxhimRIxO3zHKa5WUTkrLBm3VoRUy4 W85V1MOdYinlWwOsNNWEYXOdpmVCohkS062pqSE212UzhIDnbwyvuUN0jWc= X-Google-Smtp-Source: AGHT+IE3nqUjWIwhixebQt+HCxdtTBEw+J4cjgNR4uj1pwdz4HOeDYMgcbZNJlY90qFztVO3Twu6Vg== X-Received: by 2002:a05:6402:5194:b0:5e5:4807:5441 with SMTP id 4fb4d7f45d1cf-5f329337b8cmr2295424a12.30.1744289281448; Thu, 10 Apr 2025 05:48:01 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:1ab7:3e39:bdc1:195:d94b]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5f2fbc2e8bfsm2254011a12.34.2025.04.10.05.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Apr 2025 05:48:01 -0700 (PDT) Message-ID: <399f53cd1274345d0301dd7ecf016ae749e87abe.camel@cybertec.at> Subject: Re: Archive logging not cleaning up pg_wal directory From: Laurenz Albe To: Justin Swanhart , pgsql-general@lists.postgresql.org Date: Thu, 10 Apr 2025 14:48:00 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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' >=20 > This command is properly copying the log files to my archive directory bu= t 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?) >=20 > 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' >=20 > 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 replicate = from so I changed it to "cp" and now have this problem. >=20 > 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