public inbox for [email protected]  
help / color / mirror / Atom feed
From: Alpha Shuro <[email protected]>
To: [email protected]
Subject: (docs): add missing info about ShareLocks
Date: Sat, 22 Nov 2025 09:07:01 +0100
Message-ID: <[email protected]> (raw)

Hello

I had a production incident a few weeks ago while using deferred indexes, where the Postgres docs lead me down the wrong path of investigation due to missing details. Specifically, the docs implied that a `ShareLock` was only acquired when creating indexes, but only after looking at the code did I learn that this lock is also acquired when transactions are waiting for other transactions to complete. I think this would be helpful to someone who might find themselves on the same path in the future, and as I understand it this mailing list is the way to submit patches to the docs?



Attachments:

  [application/octet-stream] 0001-document-ShareLock-behaviour-when-using-a-deferred-u.patch (1.2K, 2-0001-document-ShareLock-behaviour-when-using-a-deferred-u.patch)
  download | inline diff:
From 80741b41d6ff09fdd395775f87b99098b589c16e Mon Sep 17 00:00:00 2001
From: Alpha Shuro <[email protected]>
Date: Wed, 15 Oct 2025 17:55:05 +0200
Subject: [PATCH] document ShareLock behaviour when using a deferred unique
 index

The logs that were printed by Postgres
when enforcing deferred unique indexes were misleading.

This change should make it easier to understand or investigate
when users see the `waits for ShareLock` log entry
---
 doc/src/sgml/mvcc.sgml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/doc/src/sgml/mvcc.sgml b/doc/src/sgml/mvcc.sgml
index 049ee75a4ba..4e36c59776a 100644
--- a/doc/src/sgml/mvcc.sgml
+++ b/doc/src/sgml/mvcc.sgml
@@ -1016,6 +1016,11 @@ ERROR:  could not serialize access due to read/write dependencies among transact
         <para>
          Acquired by <command>CREATE INDEX</command>
          (without <option>CONCURRENTLY</option>).
+
+         It is also acquired when enforcing a DEFERRED UNIQUE INDEX:
+         If a transaction detects another transaction that might cause
+         a potential conflict, it waits for the other transaction to complete,
+         by acquiring a ShareLock on the other transaction's transaction id.
         </para>
        </listitem>
       </varlistentry>
-- 
2.51.0



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: (docs): add missing info about ShareLocks
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox