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 1m3Ih5-0007Ko-NY for pgsql-general@arkaria.postgresql.org; Tue, 13 Jul 2021 13:43:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3Ih4-0005L6-Mh for pgsql-general@arkaria.postgresql.org; Tue, 13 Jul 2021 13:43:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3Ih4-0005Ky-DG for pgsql-general@lists.postgresql.org; Tue, 13 Jul 2021 13:43:26 +0000 Received: from wforward2-smtp.messagingengine.com ([64.147.123.31]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3Ih0-0007Af-8t for pgsql-general@lists.postgresql.org; Tue, 13 Jul 2021 13:43:25 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailforward.west.internal (Postfix) with ESMTP id DE3D41AC0E0A; Tue, 13 Jul 2021 09:43:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 13 Jul 2021 09:43:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=GRzZVstm5emllxTaX8W6dNi+sC5Kt13wmTTdtVYyN eI=; b=eAGzaT6qCs2WLbtAuLHEvo2+Ix9JkZZhjwe7ZVSuBq9pwHYMXhjuE8SmS RkVSq1ugBDASbXVCtGan9ASRXWLChq7TeaEOcFZ406b0fsUbftqz+UoEsCgxR2xO oZnxB4pNfoB9Khra4wQkNvj2kwP0shuoqghyXmTrAzFkWEmewCpTNeAk2rhG+3q4 ROFtHxjg9/nh4CdeBAgvgZLfMBsZSTOcC1UmqCppuHIcJEzvA3GxGhgdZZl+pXUx mt11WsO4/jsxEdarcgL9EyFRN+RRvzwCQrmbEKT/xQUWw4O+ZV+LG9StDp3bGnfK xZsnB7kEOeSEQSYvMp+7xz/u75Arw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehgdehkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrh hprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeelveehheeuieduieetiedt keeuteelfeetjeffieffudegvdffvdfftdeivdeukeenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghuthes vghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 13 Jul 2021 09:43:13 -0400 (EDT) Subject: Re: pg_wal lifecycle To: Luca Ferrari , pgsql-general References: From: Peter Eisentraut Message-ID: <5cd3241a-f1d3-9881-e3a2-823075d6d6c3@enterprisedb.com> Date: Tue, 13 Jul 2021 15:43:12 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 13.07.21 09:07, Luca Ferrari wrote: > I'd like to see if I get it right about pg_wal: it grows up to pretty > much max_wal_size, at which point a checkpoint is triggered. > If the server triggers a timed checkpoint before the pg_wal is at > max_wal_size, the system recycles the wals thus keeping the pg_wal > size lower than max_wal_size. > Is this correct? In particular, what is in simple words, the > discrimination between recycling a segment and creating a new one? Recycling in this context just means that instead of creating a new WAL file for new WAL traffic, it reuses an old file. So if you have WAL files 5, 6, 7, 8, 9, and you know that you don't need 5 and 6 anymore, when you need to start WAL file 10, instead of creating a new file "10", the system just renames "5" to "10" and starts overwriting what was in there. This is just an optimization to use the file system better; it doesn't affect the logical principles of what is going on.