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.96) (envelope-from ) id 1vO0VP-005d6G-1l for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Nov 2025 21:23:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vO0VN-00BwyE-18 for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Nov 2025 21:23:21 +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.96) (envelope-from ) id 1vO0VN-00Bwy6-0F for pgsql-hackers@lists.postgresql.org; Tue, 25 Nov 2025 21:23:21 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vO0VL-001UY3-19 for pgsql-hackers@postgresql.org; Tue, 25 Nov 2025 21:23:21 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-63c489f1e6cso352901a12.1 for ; Tue, 25 Nov 2025 13:23:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764105798; x=1764710598; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hYLchNVRSlssegyPHR/sqQDm6WaOQ3AP4pPtcxbar+4=; b=acntQSejzMG/LdGDCP1nLeKTMwbf55W88MOnriCenWxfKjviX8iIK/q1OcTGWj9RDK v3V/Gw7UQ+MUIUM4gT9esre1ZXykUTty1mqGqgezwlOl4WERndiwNEDrhUMDHHYQg+K/ tocpt6sfyZOGow8Km5wvfrVwkvEe5hLGOwhCQfsrVnHf3zJNnZ7K/A1Vkp5Zh21afvNC Q5cCsyFQnMvDln02+wRHNiuATSy5eXVnjIns+wnfv0ZfBjo2oX/htTuxPsaRdJP5c2Uv wv1ZidjBTdmgUzuOT7Zop2HSXX5jycW6y3qAbvifpuLVL1vzyXorxxd+YHauNUllAIgM U/FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764105798; x=1764710598; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hYLchNVRSlssegyPHR/sqQDm6WaOQ3AP4pPtcxbar+4=; b=Ihiyg2EoJ1IS2E8xo7NO+SGIz9zHcL7bAKe/2LxEQRz8Ic6jgLHUqlU84NCo2R+aqi QEcPm2L4GkglhgQDM0EuccTlhVWAUg5jmtSZ3NFl/jegFE4zld1UbYaP4XTGv0ROEIiW IfPiHd3WC7L5R7IkLyGrKscW+0gJAJ7IY5UIqTB20Xt/IhBT2mFrFdpGHMesnG9DIoEj pk6k+lRMAXk5u0yBK2uj4fQ62ehKAzVscNj2wO7yxupVdU442MCqkr/LN1I6dXWROlm7 ypab/fgkN3+dMJm6c6qZIzulFOp65yE+OxO9MnQ8clX3TadWXfc7I23X73p2ik8ShUaT H9rQ== X-Forwarded-Encrypted: i=1; AJvYcCW6+7T8fvHh83fmJqmScOt0P+D6J6/uEGgjDUXDH/YjyQpw7rYMkPdwjXTBx4HHIue/7x7enpcHStoM5q8v@postgresql.org X-Gm-Message-State: AOJu0YyUJuiMih5m/Uod+QEshVN4Uvgg6/ej1CXMW2VbXJalhU+ck/MX cwEfDxPpfV5bxKnsHQWVCLxB7OXQcXkvFBhM+RaAudRA/u171EM/wBz69dtw8iMWeJ4s4bio1mT pAadVrMIhOpaNsdTQsPJeh6mlMyKZDgk= X-Gm-Gg: ASbGncsshnxTsC4XO0LpAVqL5wMAmfZQAH4bx4UClRxP2iuhv9YYR9sqwHZKHpPmyCN Xi0+BJkzysKosQ11HWZXfbTcYXZrhgAbXwrtPMZb/CMmxT0b6T02VJFLcZa3Eaf+JmFcHBwSdZy A64wineKMPOmNAiaS03Rbi6wxWSTlOucODPUHO0Dj3dCIOziv5FjCc0e0iF7WXbq1fUGiXaSdJC WWs2aD/njlUl6VIqklvq+z0w/TIyCj8bIIeVy2T/u38Iuc4udyZioWY5+SBPhPYd5Uu5vWNhvS3 c70JWLI= X-Google-Smtp-Source: AGHT+IG0hQdTy5t3ztcFrFB+Y5I8J8mhJERrt6E5/FYZ8rqIG/GkZSlyT5Ygier1d/iwuzTM86/WB1ihBtfWEsLe0p8= X-Received: by 2002:aa7:d387:0:b0:641:1cbe:a5bf with SMTP id 4fb4d7f45d1cf-64539690464mr13560480a12.9.1764105797569; Tue, 25 Nov 2025 13:23:17 -0800 (PST) MIME-Version: 1.0 References: <6kmid26do57ykqfpvq6iieniy4djsymhrypkjccazq5g4bbe6a@2y6owwv7qpex> <3je3ahgf7rrmmurxo6hnlhg5d3ffwfrtjwjxd6jm5srlv5iebp@vxqk5qtgmowr> <3w7v3w6a57jnssokap4k7thoekig72flnyhd4wp3yftzdd7lm7@f6lpcfen6hr7> <6rgb2nvhyvnszz4ul3wfzlf5rheb2kkwrglthnna7qhe24onwr@vw27225tkyar> <3nce7i72ayzkunai6mkz24ckbxk74jodz4ua2chcdrwppxlxcd@w6x5kfkjrkru> In-Reply-To: From: Melanie Plageman Date: Tue, 25 Nov 2025 16:23:04 -0500 X-Gm-Features: AWmQ_bmSUmR2NS8MzURE7mOB-wzsRK2EQKiFefEqhdq2tqqy4YOk9F5G2TEMfXc Message-ID: Subject: Re: Buffer locking is special (hints, checksums, AIO writes) To: Andres Freund Cc: Matthias van de Meent , pgsql-hackers@postgresql.org, Thomas Munro , Heikki Linnakangas , Noah Misch , Robert Haas , Michael Paquier Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Nov 25, 2025 at 3:46=E2=80=AFPM Andres Freund = wrote: > > > > > > I presume you didn't do this because HeapTupleSatisifiesMVCC() for > > > > SNAPSHOT_MVCC calls the non-batch version (and, of course, > > > > HeapTupleSatisifiesVisibility() is the much more common case). > > > > > > > > if (TransactionIdIsValid(xid)) > > > > { > > > > if (BufferIsPermanent(buffer)) > > > > { > > > > /* NB: xid must be known committed here! */ > > > > XLogRecPtr commitLSN =3D TransactionIdGetCommitL= SN(xid); > > > > > > > > if (XLogNeedsFlush(commitLSN) && > > > > BufferGetLSNAtomic(buffer) < commitLSN) > > > > { > > > > /* not flushed and no LSN interlock, so don= 't > > > > set hint */ > > > > return; false; > > > > } > > > > } > > > > } > > > > > > > > Separately, I was thinking, should we assert here about having the > > > > right lock type? > > > > > > Not sure I get what assert of what locktype where? > > > > In SetHintBitsExt() that we have share-exclusive or above. > > We *don't* necessarily hold that though, it'll just be acquired by > BufferBeginSetHintBits(). Or do you mean in the SHB_ENABLED case? Yea, in the enabled case. Also, can't we skip the whole if (TransactionIdIsValid(xid)) { if (BufferIsPermanent(buffer)) { /* NB: xid must be known committed here! */ XLogRecPtr commitLSN =3D TransactionIdGetCommitLSN(xid); if (XLogNeedsFlush(commitLSN) && BufferGetLSNAtomic(buffer) < commitLSN) { /* not flushed and no LSN interlock, so don't set hint */ return; } } } part if state is SHB_DISABLED? - Melanie