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 1v0iR2-00HJTH-Kl for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Sep 2025 15:26:36 +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 1v0iR1-0015IP-Au for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Sep 2025 15:26:35 +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 1v0iR0-0015IH-Sr for pgsql-hackers@lists.postgresql.org; Mon, 22 Sep 2025 15:26:35 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v0iQw-002DPD-2B for pgsql-hackers@lists.postgresql.org; Mon, 22 Sep 2025 15:26:34 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-77f1f8a114bso1418791b3a.0 for ; Mon, 22 Sep 2025 08:26:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1758554790; x=1759159590; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=cRuifYZPQq11oE5sCiMDed80+P6ZH1RtZDTwH/IEpqU=; b=CTKG7AFqnF0Zcq42oLLw3K/DeAyr5znZs7BWxfWVWbWNcf6SRANpsEVhrAsoHvyxvT +IX6ohUA+aTTqxZ7B9vfsFr1+SKEegO7gVxqY8JNIaBDAks+JNjdh3bQzeq5p+Bvp9Uw 1ZVMhBvxBt33duB5J7mekldVZkeDLf5ZVCC8zl65APlqdRLBqSUm0u7VvwF5PtX3+3XW n8zd2GtYMQ0ErjxFbcPI+EsRe4zLvqgMPdC81BpRlEsZTVZyUcE4e1eHsazyhKk23PUZ 5Yj70ATUmiDC4Xc4Lu7TcotpslRi6Z1DxfrI+R9Xq1o7pTCgWVct2JuQ16fdbe9HfJKx hAGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758554790; x=1759159590; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cRuifYZPQq11oE5sCiMDed80+P6ZH1RtZDTwH/IEpqU=; b=U0t2EHgGx98aoSPgFlvXXdsV6sJoQTo5nGWMQk9f9yPJEpMg0VzKZyyReSpJZuF/hs mrxAMhGq3BSbksNd0LzRt65yiagqWZs5sTZT1vWLvv4Ozh4zHl3UE6qh28XNDvWcq2Gd SVtdzQ4ZPJ+ag1WcGhih03xj053kgBCSGPnOBqhbBOJMwxeObb/3bPSCNs3q0KLZ1a6c bvv45szMmSwCOqKCS4hY0zPjY3vSPB8okkk7EgC0zPTMPtw+RC5XFzZWB8gyizY4XqT6 hHnrVWSymbzOX0EZwrTvTUhazzK6RE7uoTpaH8aT5f4/8zFGXP9YnD4juCw1ddw2GbPR ZGhA== X-Gm-Message-State: AOJu0Yz/0iFKMK8LYpauQuOzv6GeIddjze+drHeSGYwt6YKI7AGcVMC8 div+M/o/a7P4c3pI6F6tw5qP6ebwNw9vB/ZqJ89f4aqFNw2l24MGbHGHV2ueCo4XPA== X-Gm-Gg: ASbGncsvCBBbhDosAdpL68y/10ELRDkjvMASDVJzgqJXVJtKXWzX/DBZz7OS/zoaBlm kydvZ9rBjuE8PXwupkJJdJXBwPn7ZflQx5/8ssl4M+HHIoOladN1BVE/WrZD+SjLmvaGM7+QQrT bOZDrqOyqQ3+tStLImh8209g/qHY1U97XI+lbYqnlddha4b9hDwEF3ai1AtxrR7ah42GRz74gMl rZsN3KYsCoI/5sVYQ/1egzyGjkXIt0rRZQaHuqOm3NEzGn+xSLlGeHS5clNLrRBQ3n8neUObrli YP0x3jLNK1snFnqwpSok8zckKYzLOgH8bOnFYYh91iemnqJ/7RW3sJNDbqOBX72UL8+h8bzNct5 xYi2kooWiO6+v78D7uRZoSGBCxSR7WJFG2pR3OGPb6Cz8J1UFoxX2pglWVjGvlqdgJS05 X-Google-Smtp-Source: AGHT+IE/PP8fhG/9JHOejbZWPMbIUD7lnjyhx5+rAKog4/ypkmTZ7pR5WNVLZDBIRTrtffj8pkiC0A== X-Received: by 2002:a05:6a21:329b:b0:263:57a:bb46 with SMTP id adf61e73a8af0-2920875282bmr18414181637.13.1758554789858; Mon, 22 Sep 2025 08:26:29 -0700 (PDT) Received: from jeff-ws-bridge.lan (c-76-102-242-158.hsd1.ca.comcast.net. [76.102.242.158]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-77f346ba10asm3922055b3a.69.2025.09.22.08.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 08:26:29 -0700 (PDT) Message-ID: Subject: Re: Use WALReadFromBuffers in more places From: Jeff Davis To: Bharath Rupireddy , Jingtang Zhang Cc: pgsql-hackers@lists.postgresql.org, Nitin Jadhav Date: Mon, 22 Sep 2025 08:26:28 -0700 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.3-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 2025-09-13 at 22:04 -0700, Bharath Rupireddy wrote: > Thanks for looking at this. Yes, the WAL writers can zero out flushed > buffers before WALReadFromBuffers gets to them. However, > WALReadFromBuffers was intentionally designed as an opportunistic > optimization - it's a "try this first, quickly" approach before > falling back to reading from WAL files. IIRC, one motivation (perhaps the primary motivation?) was to make it possible to read buffers before they are flushed. It was always possible to read already-flushed buffers. The benefit of reading unflushed buffers is that we can replicate the WAL sooner (though it can't be replayed until the primary flushes it). Is that right? Regards, Jeff Davis