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 1vs2fI-002KUh-0k for pgsql-general@arkaria.postgresql.org; Mon, 16 Feb 2026 17:45:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vs2fH-004T9H-07 for pgsql-general@arkaria.postgresql.org; Mon, 16 Feb 2026 17:45:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vs2fG-004T97-2A for pgsql-general@lists.postgresql.org; Mon, 16 Feb 2026 17:45:42 +0000 Received: from mout02.posteo.de ([185.67.36.66]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vs2fD-00000000vbO-2Ml1 for pgsql-general@postgresql.org; Mon, 16 Feb 2026 17:45:41 +0000 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id AD061240105 for ; Mon, 16 Feb 2026 18:45:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.de; s=2017; t=1771263936; bh=ZgRaubDV4dW+l1chET3GBm7Y5rzNKL2G3Su1j+I2rtc=; h=Content-Type:Message-ID:Date:MIME-Version:Subject:From:To:From; b=SfxAaiIXmdi0gKLC26KYVsUn6485jjDEs2dWdDEZRleUVQx+EjG6PaAGY9PqQ3tXg W2oIcEfdTY4SXL7hqK5jteh3NK9lRQzWpAt++3phSbtQ2/5meAYt+TA1qgwar0MGkK eMGA1l/2vnkaaWKWdMkD3sQC8/fFgpjHpw5VuXFXJEOoJdB1Ts6g7VOK8mEXa0Iyuu uSmWL0e1mGnl2S/YGnRW1gfZY/BIER1X9UqnODpaPsFSbE2kFj13rjsM1/1bfhVZ8j 1AtvqsfAVmejzaExWjDcl8RFVZKjEDNWqL38Zl+9EoXnG+0xW5IfT/5vJyLgQtoeqN vU90UcGTpV7Mw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4fF9Cs6sMPz9rxh for ; Mon, 16 Feb 2026 18:45:29 +0100 (CET) Content-Type: multipart/alternative; boundary="------------MWXrHp7g3m4DWuXNBdP4NaNI" Message-ID: <87ca8c2c-6826-44d1-8a31-a5f793a2729e@posteo.de> Date: Mon, 16 Feb 2026 17:45:30 +0000 MIME-Version: 1.0 Subject: Re: Guarantee order of batched pg_advisory_xact_lock From: Nico Heller To: pgsql-general@postgresql.org References: <93fb937f-9f4d-4bd7-b7e6-51d5f98859d9@posteo.de> <14506.1770844674@sss.pgh.pa.us> <101916.1770850197@sss.pgh.pa.us> <777cfa1c-fd1f-479f-b9b8-217b0f7a40b7@posteo.de> Content-Language: en-US In-Reply-To: <777cfa1c-fd1f-479f-b9b8-217b0f7a40b7@posteo.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------MWXrHp7g3m4DWuXNBdP4NaNI Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Does anyone have any idea what the root cause of my issue is? I appreciate any insight. As I said, hash collisions can be rules out, sadly. On 2/12/26 12:18, Nico Heller wrote: > > I just checked for hash collisions with the following query today: > > SELECT COUNT(*), hashtextextended(key, 0) FROM > ( >   SELECT key FROM table1 >   UNION >   SELECT key FROM table2 >   UNION >   ... > ) keys (key) > GROUP BY hashtextextended(key, 0) > HAVING COUNT(*) > 1 > > Where table1, table2, ... are all the tables we are acquire keys from > to use for the mentioned query. > > Sadly, no results were returned. Thus, I can rule out hash collisions. > > Any other thoughts? Here is an error log from the JDBC driver: > > > > org.postgresql.util.PSQLException: ERROR: deadlock detected Detail: > Process 60780 waits for ExclusiveLock on advisory lock > [24605,3030106527,494580150,1]; blocked by process 65280. >  Process 65280 waits for ExclusiveLock on advisory lock > [24605,1321834016,1311356115,1]; blocked by process 60780. > > > > On 2/11/26 23:49, Tom Lane wrote: >> Nico Heller writes: >>> So it would probably be better to ORDER BY the hashtextended result >>> instead of :keysToLock, right? >> Yeah, that seems like it'd work, if you have no other dependencies >> on the locking order. >> >> regards, tom lane --------------MWXrHp7g3m4DWuXNBdP4NaNI Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Does anyone have any idea what the root cause of my issue is? I appreciate any insight.
As I said, hash collisions can be rules out, sadly.

On 2/12/26 12:18, Nico Heller wrote:

I just checked for hash collisions with the following query today:

SELECT COUNT(*), hashtextextended(key, 0) FROM
(
  SELECT key FROM table1
  UNION
  SELECT key FROM table2
  UNION
  ...
) keys (key)
GROUP BY hashtextextended(key, 0)
HAVING COUNT(*) > 1

Where table1, table2, ... are all the tables we are acquire keys from to use for the mentioned query.

Sadly, no results were returned. Thus, I can rule out hash collisions.

Any other thoughts? Here is an error log from the JDBC driver:


org.postgresql.util.PSQLException: ERROR: deadlock detected Detail: Process 60780 waits for ExclusiveLock on advisory lock [24605,3030106527,494580150,1]; blocked by process 65280.
                                                                                                                 Process 65280 waits for ExclusiveLock on advisory lock [24605,1321834016,1311356115,1]; blocked by process 60780.



On 2/11/26 23:49, Tom Lane wrote:
Nico Heller <nico.heller@posteo.de> writes:
So it would probably be better to ORDER BY the hashtextended result 
instead of :keysToLock, right?
Yeah, that seems like it'd work, if you have no other dependencies
on the locking order.

			regards, tom lane
--------------MWXrHp7g3m4DWuXNBdP4NaNI--