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 1urGkI-003Kuv-7V for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Aug 2025 14:03:27 +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 1urGkG-00FTe6-Ju for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Aug 2025 14:03:25 +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 1urGkG-00FTdx-96 for pgsql-hackers@lists.postgresql.org; Wed, 27 Aug 2025 14:03:24 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1urGkD-0029Wm-2k for pgsql-hackers@postgresql.org; Wed, 27 Aug 2025 14:03:23 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-afcb731ca8eso1089150166b.0 for ; Wed, 27 Aug 2025 07:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756303400; x=1756908200; 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=OzG3fj0aO1xfZtLNEXhyWIY3Qbw13BiHixrZIPaJOIc=; b=ZOqfrXMVGV87AwGC4OUZzhOUMdP8qV8NQgfv922hCOJe0yGWmuYL78TCD8iDjSLNi/ nQl/2bFUiHKLYm3tqzPL2zXdMsyYxkkqPtoNSnYyDosrX7glWkfzZ5JZ9u7/zx0TjJp8 fb9nxkDMySTNUtBvex0ftjVmgX+u6mi9vYpt0+symvBjFw4uaQCZVRJMncEzSQgq6mLI qn3mkmzVwaD7ZcGlnpRI4VXn/1UoFA2g9KR4N/pdDbiP/DD+aioG8Dg+HlLD+qgrhoC0 6V2Qu0rhIGBfagtzr62Nm1tlA+qb/xIdMCTxFn9W63yzc8sx9BfEhxaVH5getx0WR/PI a+VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756303400; x=1756908200; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OzG3fj0aO1xfZtLNEXhyWIY3Qbw13BiHixrZIPaJOIc=; b=QZ/eM2TrOt4QmbMXU0S/2lLQo5ytSmEq9NB+Gkn34mjJsV1Pb3E1FumsLXlgZ5RWQ0 RnxXY9nmlvQdHnu9DvC7g+Sbwv3ex9BlEc7WmHd3xBNscShWQUxHKWdANbcEjeBVZbh3 H097+bdKyjyCbfn0Ze8tWf83riD0sNiSdSnFnLW7a/rixyZBhlmUW2Lvdu+/hXKfbquf r0sHCFql9BGsfPajRI7IstO5AIidhbA5QesrkZYcESroZaPdkeMxOWHxDOUcoXsWWJ6/ qqcgg6oMxNC7eQ4uiOoGCSgeLCrqF+gzx0FZmWaG8phS9ve/KInBXtLe5XMSRb8gHKPW yleQ== X-Forwarded-Encrypted: i=1; AJvYcCUFKvtbU7gij9dOsbROYsOBycOTvVtP/hWQ5aTZPbm0xnLJU3FQ41j3tiw9lMY/2b74RfVy6slPKmGUN0uC@postgresql.org X-Gm-Message-State: AOJu0YxCM2PdHg8+WSkcTfYj4uQqeIPo6iVb1PaHhrpMwE3Gt/3TikWw IKmmkywtUhcIzl0rytJ3tS2+ExFCeKy+RErRS95AW5AfU75kO/0Bv/Ok5wZNokIA1sm28vRCEX9 8XWzAd12rQeZwnEoSlbYuzVZodGTvy54= X-Gm-Gg: ASbGncs7ERQ7vsWAGtuUprttesdnUesIs7B6lw/Ufw8NFfURcCdwdKy0lB/5HJF9jXU CTdXtGgYp7URVc7UNZ6iAcKqQO+fpwC5fknkGBI1ibwdLbLxHqEI9sdF2YVIC0h8Z5GCj+bpsdb /EZ78TAQ9LrDhpeL5qv3aI5xoKBTz3VxK3/z3aweRogCs5mo39RLk+A4hJkPG7L7rKBcdD3alST BU2tI4F0sX9W3wU3nn5Fldpbp6o8TEfZWXyWhKLlpjF9byNiA== X-Google-Smtp-Source: AGHT+IEst42y9Be8wMew+5uqmC9oo87uXQQteBUtH05oCOwjAVtQ60w6UVY9DUVaJ8xYMbFDZP0wxm94NBY5sCtWxlY= X-Received: by 2002:a17:906:794a:b0:afe:9084:f34d with SMTP id a640c23a62f3a-afe9084fb94mr830226566b.21.1756303400264; Wed, 27 Aug 2025 07:03:20 -0700 (PDT) MIME-Version: 1.0 References: <20250827001449.fb.nmisch@google.com> In-Reply-To: <20250827001449.fb.nmisch@google.com> From: Robert Haas Date: Wed, 27 Aug 2025 10:03:08 -0400 X-Gm-Features: Ac12FXzu7t48pzF1fIuR7qerinF_PTYEbnPh9sEK3NyJFhyN15BL819GNfyhKXc Message-ID: Subject: Re: Buffer locking is special (hints, checksums, AIO writes) To: Noah Misch Cc: Andres Freund , pgsql-hackers@postgresql.org, Melanie Plageman , Thomas Munro , Heikki Linnakangas 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, Aug 26, 2025 at 8:14=E2=80=AFPM Noah Misch wrot= e: > > > AFAIK "share exclusive" or "SX" is standard terminology. > > Can you say more about that? Looks like I was misremembering. I was thinking of Gray & Reuter, Transaction Processing: Concepts and Techniques, 1993. However, opening it up, I find that his vocabulary is slightly different. He offers the following six lock modes: IS, IX, S, SIX, Update, X. "I" means "intent" and acts as a modifier to the letter that follows. Hence, SIX means "a course-granularity shared lock with intent to set finer-granularity exclusive locks" (p. 408). His lock manager is hierarchical, so taking a SIX lock on a table means that you are allowed to read all the rows in the table and you are allowed to exclusive-lock individual rows as desired and nobody is allowed to exclusive-lock any rows in the table. It is compatible only with IS; that is, it does not preclude other people from share-locking individual rows (which might delay your exclusive locks on those rows). Since we don't have intent-locking in PostgreSQL, I think my brain mentally flattened this hierarchy down to S, X, SX, but that's not what he actually wrote. His "Update" locks are also somewhat interesting: an update lock is exactly like an exclusive lock except that it permits PAST share-locks. You take an update lock when you currently need a share-lock but anticipate the possibility of needing an exclusive-lock. This is a deadlock avoidance strategy: updaters will take turns, and some of them will ultimately want exclusive locks and others won't, but they can't deadlock against each other as long as they all take "Update" locks initially and don't try to upgrade to that level later. An updater's attempt to upgrade to an exclusive lock can still be delayed by, or deadlock against, share lockers, but those typically won't try to higher lock levels later. If we were to use the existing PostgreSQL naming convention, I think I'd probably argue that the nearest parallel to this level is ShareUpdateExclusive: a self-exclusive lock level that permits ordinary table access to continue while blocking exclusive locks, used for an in-flight maintenance operation. But that's arguable, of course. --=20 Robert Haas EDB: http://www.enterprisedb.com