Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIweQ-0004oP-B0 for pgsql-admin@arkaria.postgresql.org; Tue, 02 Aug 2022 18:29:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oIwdR-0000PQ-0z for pgsql-admin@arkaria.postgresql.org; Tue, 02 Aug 2022 18:28:53 +0000 Received: from makus.postgresql.org ([72.32.157.229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIwZV-0001IN-Hd for pgsql-admin@lists.postgresql.org; Tue, 02 Aug 2022 18:24:49 +0000 Received: from mail.thelabyrinth.net ([45.56.70.56]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIwRZ-0003zM-0z for pgsql-admin@postgresql.org; Tue, 02 Aug 2022 18:16:38 +0000 Received: from [10.142.0.6] (unknown [136.144.42.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dsteele) by mail.thelabyrinth.net (Postfix) with ESMTPSA id B75B9546A1; Tue, 2 Aug 2022 18:16:32 +0000 (UTC) Message-ID: Date: Tue, 2 Aug 2022 14:16:31 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: WAL restore/recovery fills pg_wal volume Content-Language: en-US To: Don Seiler , pgsql-admin References: From: David Steele In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/2/22 09:26, Don Seiler wrote: > > I'm on PG 12 on Ubuntu 18.04. > > I have a very large database (~18TB) with which we have a separate > pg_wal volume configured. The pg_wal volume is around 50GB but typical > daily usage rarely sees it over 10GB. We use pgbackrest to archive WALs > as well as performing backups. > > The problem is when we are performing restore and recovery (e.g. to set > up a new physical replica), also via pgbackrest. The DB restore works > fine but when it comes to the WAL restore and recovery, the pg_wal > volume will fill up before PG can clear out the already-recovered WAL > files. This means I have to restart the database and start the recovery > process over again. The last time I ended up writing a cron job to > delete around 100 logs per minute just via an `rm` command based on the > recovery rate I saw. > > My understanding is that the recovered WAL files would be cleared when > the replica hits a recovery start point. My primary is configured with a > 10 minute checkpoint_timeout. The replica pg_wal will fill up before 10 > minutes. The primary and replica have the same size pg_wal volume but > the primary never comes close to filling up, as I said before. > > I believe two options (aside from the ugly rm cron job) would be to > either shorten the checkpoint_timeout on the primary, which would be > hard to do due to the activity level, or make a larger pg_wal volume > (trial and error to determine just how much larger?). > > I'm interested to know if there's anything else I can do to avoid the > toil when we do these restores and also if maybe there is something > wrong and that PG shouldn't be filling up the volume blindly. This appears to be related to [1], which we have been discussing over on that thread. Regards, -David [1] https://www.postgresql.org/message-id/flat/20210202151416.GB3304930%40rfd.leadboat.com