public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alpha Shuro <[email protected]>
To: Laurenz Albe <[email protected]>
Cc: [email protected]
Subject: Re: (docs): add missing info about ShareLocks
Date: Thu, 27 Nov 2025 12:33:42 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
Ah thanks for pointing this out, I've moved it to the xact-locking page instead
> Den 22. nov. 2025 kl. 13.07 skrev Laurenz Albe <[email protected]>:
>
> On Sat, 2025-11-22 at 09:07 +0100, Alpha Shuro wrote:
>> 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?
>
> No, that is wrong. This section is about table locks, and a lock on a transaction ID
> should, if anywhere, be documented elsewhere. Actually, there is already something
> about transaction ID locks in https://www.postgresql.org/docs/current/xact-locking.html
>
> Perhaps you could improve that short documentation?
>
> Yours,
> Laurenz Albe
>
> PS: There are also SHARE locks on rows.
Attachments:
[application/octet-stream] document-ShareLock-when-using-deferred-unique.patch (661B, 2-document-ShareLock-when-using-deferred-unique.patch)
download | inline diff:
diff --git a/doc/src/sgml/xact.sgml b/doc/src/sgml/xact.sgml
index 3aa7ee1383e..d753869cc88 100644
--- a/doc/src/sgml/xact.sgml
+++ b/doc/src/sgml/xact.sgml
@@ -102,6 +102,13 @@
of multixact IDs (<literal>mxid</literal>; see <xref
linkend="vacuum-for-multixact-wraparound"/>).
</para>
+
+ <para>
+ If there is a DEFERRED UNIQUE constraint on a row inserted in a transaction,
+ and there are multiple concurrent transactions inserting the same unique key,
+ the earlier transactions will wait for later transactions by
+ acquiring a <structfield>ShareLock</structfield> on the transaction ID.
+ </para>
</sect1>
<sect1 id="subxacts">
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], [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