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 1vfrlm-005c0z-1v for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jan 2026 03:42:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vfrlk-007pcX-1n for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jan 2026 03:42:04 +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 1vfrlk-007pcO-0h for pgsql-hackers@lists.postgresql.org; Wed, 14 Jan 2026 03:42:04 +0000 Received: from mail-dy1-x132e.google.com ([2607:f8b0:4864:20::132e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vfrlg-000LU4-1N for pgsql-hackers@postgresql.org; Wed, 14 Jan 2026 03:42:02 +0000 Received: by mail-dy1-x132e.google.com with SMTP id 5a478bee46e88-2b053ec7d90so7792614eec.0 for ; Tue, 13 Jan 2026 19:41:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768362118; x=1768966918; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=//8eiFfxQGkvpU/ALhA1hw4Cq1qn4oyN5jMIejMqwls=; b=AnFJh0YX6JLp8+8Mp8vcCbL6KCkgwEEidSjJHCbwZyvlMTACodnr9ynmjpeXRiu32y QV9eEDEtkFC2kyqss+cr4ZiZpfKEcKUgUFJ+Jap69a3k6OY02JjZT7xeG59AXCndPN0m tZd5S50nKHsjkNRgHq1JCaxkmU2J5/xLl3DpZkH3HqtX7x5iI+eiHTc8PKSEeg4O+FpX JFBo/VvXE6ZLlHobCSqzUOO5bJwL3gTpPWcsxVZ9ak2avaXvRLieIz0sZBFIgAL7Lha6 q/1DOGrWgcR6k0GkzMPtkY6kJM6Ghz7OHS1HLXyl0mqVqrgKgZfYtI23yDpZgw+5FXpZ tzbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768362118; x=1768966918; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=//8eiFfxQGkvpU/ALhA1hw4Cq1qn4oyN5jMIejMqwls=; b=WLgQSQj4D1+CCENve6pbbwoWPV4vFn1OgIMN/HRdI/XjTyi+syO5vWnNFYnPspmEE3 tU1HcCdLKWRvT/rtRmKt51fqHL3S44rGvwDEgmaPrwcsq7pLBqIgCJbucf+B3LWD3Vw6 QfJpo3TqfFq1A7I7BDFrFP1isO4XjxxIXB0cIIic4NPB9LcJc+MH8KEuLEYKdrgrZ6xq D7F9bwICo6+hTmOvmv5T3YHWug89XiPHSmkicOKqd8MXl9IM7GJD2k8w3V7Chz0YxsgP ChL6AuurdEFiymYnxEuLBWDo+JdJhZXxhJgBI7+LobT9Wbtn/cxe0fQECQXz6yu6u2fg ZtPw== X-Forwarded-Encrypted: i=1; AJvYcCWsupR2MW1bX9luofxmwpo2i4fPVwOk5NKgr9jxx3Yb6o0xSx2wX3yAOrwJ/RX69YIWLYV9Bw1uiAYQUsd5@postgresql.org X-Gm-Message-State: AOJu0YzJgMgd1aNH9AnoqiTS/6T2vu5Sa3eyJl2XhBiPHLSRcGS3sHv9 A6DEzBMBmBIZooucG4rvfmLn7F18bWUsHy90XbICFPE/SHb2scJgxj+C X-Gm-Gg: AY/fxX5FkLDn2ni1GK4nkyT5w5hnIccJU9Fep73QsvqdnGugxhGHKX6bRbqnDSlDJ3w niibO1sR6nmOhO2Ydi4+qCtJhSJ/FAajA6qROZNygTZBed4kBhsrvTLoQPIkVoJ2eXWlInahUhV UxTdBr/j41+THesF8iL4OetDUtA5EZRae3DrX6hUIwQZZe5lErTiJhycrFqLPcVLunt2NWU0LzS dGOLFYuonwMN4w5RLd3hK2c29rMFbN+YcrjqTso9fz+XEZ7nL2LT8CP6cNJLT+CYD0n6sqLarVj r4ylVSUE3eAk8FtTq+fRBBEuGLHMeAiJiyTWYYGxq1gATc+l4ekDbN2sl77DhCGVYddOAGeHVxA QV7ILAZQyUlLCYCxYGhO7Hx1PsSC6bzlyzfdnALbmmZnUCFoaYcdE0BqZR3+icaTKoSuZIU8kl/ GeD+BCszTA9znjjUpH8aZd X-Received: by 2002:a05:7300:7fa5:b0:2ae:5e93:b69 with SMTP id 5a478bee46e88-2b4870c0be8mr1378143eec.29.1768362118010; Tue, 13 Jan 2026 19:41:58 -0800 (PST) Received: from smtpclient.apple ([142.171.105.12]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b1707b0b2bsm18588085eec.23.2026.01.13.19.41.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jan 2026 19:41:57 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81.1.4\)) Subject: Re: Buffer locking is special (hints, checksums, AIO writes) From: Chao Li In-Reply-To: Date: Wed, 14 Jan 2026 11:41:19 +0800 Cc: Kirill Reshke , Heikki Linnakangas , Melanie Plageman , Matthias van de Meent , pgsql-hackers@postgresql.org, Thomas Munro , Noah Misch , Robert Haas , Michael Paquier Content-Transfer-Encoding: quoted-printable Message-Id: <9C2494E1-F446-42DF-B070-7E231B8E6221@gmail.com> References: <1108f18d-cf7c-4f17-b29c-a119fe42f7e5@iki.fi> <5dwlfu2jyzkyf3nrlzxxblxctb6xio5es73ptgsahjnmfu5miu@772rc764hfhi> <4csodkvvfbfloxxjlkgsnl2lgfv2mtzdl7phqzd4jxjadxm4o5@usw7feyb5bzf> To: Andres Freund X-Mailer: Apple Mail (2.3826.700.81.1.4) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Jan 13, 2026, at 08:33, Andres Freund wrote: >=20 > Hi, >=20 > On 2026-01-12 12:45:03 -0500, Andres Freund wrote: >> I'm doing another pass through 0003 and will push that if I don't = find >> anything significant. >=20 > Done, after adjust two comments in minor ways. >=20 >=20 >> Also working on doing comment polishing of the later patches, found a = few >> things, but not quite enough to be worth reposting yet. >=20 > Here are the remaining commits, with a bit of polish: >=20 > - fixed references to old names in some places (lwlocks, release_ok) >=20 > - Aded an assert that we don't already hold a lock in = BufferLockConditional() >=20 > - typo and grammar fixes >=20 > - updated the commit message of the LW_FLAG_RELEASE_OK, as "requested" = by > Melanie. I hope this explains the situation better. >=20 > - added a commit that renames ResOwnerReleaseBufferPin to > ResOwnerReleaseBuffer (et al), as it now also releases content locks = if held >=20 > I kept this separate as I'm not yet sure about the new name, = partially due > to there also being a "buffer io" resowner. I tried "buffer = ownership" for > the resowner that tracks pins and locks, but that was long and not = clearly > better. >=20 > Greetings, >=20 > Andres Freund > = A couple of comments on v10-0003, I just noticed 0001 and 0002 have been = pushed. Basically, code changes in 0003 is straightforward, just a couple of = small comments: 1 ``` - * refcounts in buf_internals.h. This limitation could be lifted by = using a - * 64bit state; but it's unlikely to be worthwhile as 2^18-1 backends = exceed - * currently realistic configurations. Even if that limitation were = removed, - * we still could not a) exceed 2^23-1 because inval.c stores the = ProcNumber - * as a 3-byte signed integer, b) INT_MAX/4 because some places compute - * 4*MaxBackends without any overflow check. We check that the = configured - * number of backends does not exceed MAX_BACKENDS in = InitializeMaxBackends(). + * refcounts in buf_internals.h. This limitation could be lifted, but = it's ``` Before this patch, there was room for lifting the limitation. With this = patch, state is 64bit already, but the significant 32bit will be used = for buffer locking as stated in buf_internals.h, in other words, there = is no room for lifting the limitation now. If that=E2=80=99s true, then = I think we can remove the statements about lifting limitation. 2. By searching for =E2=80=9CLockBufHdr=E2=80=9D, I found one place = missed to update in contrib/pg_prewarm/autoprewarm.c at line 706: ``` for (num_blocks =3D 0, i =3D 0; i < NBuffers; i++) { uint32 buf_state; <=3D=3D=3D line 706, should = change to uint64 CHECK_FOR_INTERRUPTS(); bufHdr =3D GetBufferDescriptor(i); /* Lock each buffer header before inspecting. */ buf_state =3D LockBufHdr(bufHdr); ``` I will continue reviewing 0004 tomorrow. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/