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 1rp7UE-0059EV-Le for pgsql-general@arkaria.postgresql.org; Tue, 26 Mar 2024 14:09:11 +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 1rp7UD-00FQZe-I3 for pgsql-general@arkaria.postgresql.org; Tue, 26 Mar 2024 14:09:09 +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 1rp7UD-00FQZT-6x for pgsql-general@lists.postgresql.org; Tue, 26 Mar 2024 14:09:09 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rp7UA-006atc-Bw for pgsql-general@postgresql.org; Tue, 26 Mar 2024 14:09:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 42QE94ZD2818931; Tue, 26 Mar 2024 10:09:04 -0400 From: Tom Lane To: Don Seiler cc: Postgres General Subject: Re: Use of max_slot_wal_keep_size parameter In-reply-to: References: Comments: In-reply-to Don Seiler message dated "Tue, 26 Mar 2024 08:49:54 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2818929.1711462144.1@sss.pgh.pa.us> Date: Tue, 26 Mar 2024 10:09:04 -0400 Message-ID: <2818930.1711462144@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Don Seiler writes: > With our recent upgrade to PG 15, we've put the max_slot_wal_keep_size into > place, setting it about 3% lower than the size of the volume dedicated to > pg_wal. However last night we had an incident where the volume filled up > while we were performing a massive insert from one table into another. > I don't believe the replica was lagging, and we have pgbackrest configured > for async archiving, which I assume was fine. It seemed to just be a matter > of PG not cleaning up the WAL. Our understanding was that > max_slot_wal_keep_size would prevent this but perhaps it only deals with > situations where the replication slot lag is a factor? My immediate reaction is that 3% is a mighty small margin for error. I don't know exactly how max_slot_wal_keep_size is enforced these days, but in the past restrictions like that were implemented by deciding during a checkpoint whether to unlink a no-longer-needed WAL file (if we had too much WAL) or rename/recycle it to become a future WAL segment (if not). So you could overshoot the specified target by more or less the amount of WAL that could be emitted between two checkpoints. Perhaps it's tighter nowadays, but I really doubt that it's exact-to-the-kilobyte-at-all-times. regards, tom lane