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.98.2) (envelope-from ) id 1xDFdA-00000000P5Z-0Cdf for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Oct 2026 06:23:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xDFd8-00000004ChT-3xbS for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Oct 2026 06:23:26 +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.98.2) (envelope-from ) id 1xDFd8-00000004ChL-2FEd for pgsql-hackers@lists.postgresql.org; Sun, 04 Oct 2026 06:23:26 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xDFd6-00000000Gre-1ELg for pgsql-hackers@lists.postgresql.org; Sun, 04 Oct 2026 06:23:25 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-49d05d51553so5501075e9.2 for ; Sat, 03 Oct 2026 23:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791095003; x=1791699803; darn=lists.postgresql.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=3/mFkTr7TAyktkKRx+8E0hb9miGo7c+7mNo1Ye/7lxE=; b=pLe2qzkFWtPIql6HYcNfwd8ac+sr+zrSyNUrXWB0c5fUjpjESc3Z1wKaTHpV08+L2V pXzMDeSZIM6+U7KbqyE/PjLmrWpElb5WHgg+dlZH4iIOFEc7dYi5i+3ot5pOwrcMh+Oa LbI+CKU+S7RjB/o6kKpQ4uWQUHRDKskQfug7QN+VTy/KlPR5Z930g66nvbhXNl0kd2ev KSBH+LYQ/CVWUwT6iDuRK575t4yE9P+FLgyskmQQi5T+0TTHeMPithaC7fvWBYCCk89z FE+3LEZwRD+AP5oShD5fBhpn4GnJVK9/N5TXMkkm37Y+BOWbLIMj3+1NgFt7eHm3dEZ3 O0EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791095003; x=1791699803; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3/mFkTr7TAyktkKRx+8E0hb9miGo7c+7mNo1Ye/7lxE=; b=BdnrmJFTdHWXs7TRIfyyFeVIsyaixbEwKZmqnymCwVWvtNO7eYGZ9hT2XJIYLX8UkP XIUX38Bt57EoREv9FVHK3BgdWFKV/68fY5fxMOoid0MSI37hyUZjRGwYNahLAmuNCb0p oYU7BGU08crL+t23O+FpC8hCv15wRKllTg6IDrkk9yVLl2iqKpmu11KTpFnxhDCqBK/g Nxoe5fisoMHTTUwOov6bNX2HTrcUka5oG4gq39mud6MS48JOtG3UA+tC2eVcyzDGskeh b85vUYEcHqE3gCMAJBK2bNBzCRRX26UpfiQ6sEYkDRH6ZbToAnRlfm6Ta5LKRk4Z5Pkw Ga0w== X-Forwarded-Encrypted: i=1; AKwUvBzUoTGYMfC66O8jbRmWnp8ZFiVJaKY3tpUQFdady/itcrOC+9iorn1ATf3tzWaqRMOzVBMhtdCsPxLnQJ2F@lists.postgresql.org X-Gm-Message-State: AFuF++lLtEXhrODisU9umD1o8WLqQ6jBtCKqiueC7EkX/qeYG4qm6Ro/ W3UQ/aKf0SJ6dX4Sb20kWsMBh/6XlVVZPJOYVGCFuKSLBUdmwzx3vAPl X-Gm-Gg: AYBFou3933naaxvuExZkzB6a6q2x5uf2NXTb1SZQ/NbCXqAB8UV9xf4oUtScgUwIEYK mb044123N6B1xBjIUkoCnYl34iYjHP0hvR5gfT8b8JnlS/gY9F2vNcesX5xgECq8R6TNyxaR3A4 Y5VBJr9KD6oH1OO6Us86LLKn7D+vy9TaDgToHkdr3F7fs2hPISGpeT370nUQvKJUVqYc4MV4il/ mYu1Z4WDREiHhUao2J4369JMreJ7v88+Lum58Yl/TNKqo+5K6mxN4vutwwQ81hRxYmBCwjKXm/C zez3jpQsbrbNzNXBPjO1uFYKE/dxFArqZSgh3WoXRoyP6W+HCRWfaqiqbTMtzXyN6lN0tyrAo6Z Tn4vSVg8umvJfY04Z35w6czTkhm70wXqhA8++VhcmFox0n/DFHbdvQwX9NKgtdd0+2n55l4RPxu Bbzbixs8pKCEjMMoyzswZCPKSQCW8bh15/b+ClYL9YQ8lNx+8Ps9zCmmqoqWx1p/z2J/7c7RLmS X06bEc9MMbkHEeToDvLPrIV2cuRhWIPWAVI12d5p3SEb2DNgjWcztC/wg== X-Received: by 2002:a05:600c:c106:b0:49f:fefa:cfcd with SMTP id 5b1f17b1804b1-4a1680e95femr43091655e9.5.1791095002608; Sat, 03 Oct 2026 23:23:22 -0700 (PDT) Received: from bdtpg (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a0e1afbc44sm225313375e9.4.2026.10.03.23.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Oct 2026 23:23:22 -0700 (PDT) Date: Sun, 4 Oct 2026 06:23:20 +0000 From: Bertrand Drouvot To: shihao zhong Cc: Nathan Bossart , Kirill Reshke , pgsql-hackers@lists.postgresql.org, Amit Kapila Subject: Re: Report relation extension blockers within parallel lock groups Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="5NILkxRGLFFv2V7J" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --5NILkxRGLFFv2V7J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Shihao, On Fri, Oct 02, 2026 at 10:47:03PM -0600, shihao zhong wrote: > Hi Bertrand, > > > The description in the documentation is getting quite dense. This could > be > > a good opportunity to restructure it for readability. > > The attached 0002 goes on top of v1. > > It moves the prepared transaction sentence up and > gives parallel query its own paragraph. Thanks for the proposal! Moving the prepared transaction sentence up and giving parallel query its own paragraph make sense to me. That said, I think that the parallel query paragraph could be made a bit shorter like in v2 attached. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --5NILkxRGLFFv2V7J Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-Report-relation-extension-blockers-within-paralle.patch" From b09ceeab9d6f217f39d3cb6cb64b3e0c398aabcd Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Sat, 29 Aug 2026 04:24:42 +0000 Subject: [PATCH v2] Report relation extension blockers within parallel lock groups in pg_blocking_pids() Commit 85f6b49c2c53 made relation extension locks conflict between members of the same parallel lock group, but did not update the same group filtering in pg_blocking_pids(). So, pg_blocking_pids() can omit the process that is actually blocking a relation extension request. Add the relation extension exception in pg_blocking_pids(). pg_blocking_pids() reports parallel workers using their lock group leader PID. Therefore, when one member of a parallel lock group blocks another, the PID supplied to pg_blocking_pids() can appear in the result. This does not mean that a process blocks itself. Rather, a lock held by one member of its parallel lock group blocks a lock request made by another member of that group. The commit also documents this behavior. Author: Bertrand Drouvot Reviewed-by: shihao zhong Reviewed-by: Kirill Reshke Reviewed-by: Chao Li Discussion: https://postgr.es/m/apTpV8h%2BCYHf%2B1PJ%40bdtpg --- doc/src/sgml/func/func-info.sgml | 20 +++++++++++++------- src/backend/utils/adt/lockfuncs.c | 10 ++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) 75.1% doc/src/sgml/func/ 24.8% src/backend/utils/adt/ diff --git a/doc/src/sgml/func/func-info.sgml b/doc/src/sgml/func/func-info.sgml index e56c9a22c42..8f55a1cb755 100644 --- a/doc/src/sgml/func/func-info.sgml +++ b/doc/src/sgml/func/func-info.sgml @@ -243,13 +243,19 @@ One server process blocks another if it either holds a lock that conflicts with the blocked process's lock request (hard block), or is waiting for a lock that would conflict with the blocked process's lock - request and is ahead of it in the wait queue (soft block). When using - parallel queries the result always lists client-visible process IDs - (that is, pg_backend_pid results) even if the - actual lock is held or awaited by a child worker process. As a result - of that, there may be duplicated PIDs in the result. Also note that - when a prepared transaction holds a conflicting lock, it will be - represented by a zero process ID. + request and is ahead of it in the wait queue (soft block). A prepared + transaction that holds a conflicting lock is represented by a zero + process ID. + + + When using parallel queries the result always lists client-visible + process IDs (that is, pg_backend_pid results), + even if the actual lock is held or awaited by a child worker process. + Thus, the result can contain duplicate PIDs or, for relation extension + locks (lock type extend in pg_locks), the + PID of the blocked session itself when one process participating in + the parallel query blocks another. Frequent calls to this function could have some impact on database diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c index 3eb9a5b4215..1f0cc2b9bcb 100644 --- a/src/backend/utils/adt/lockfuncs.c +++ b/src/backend/utils/adt/lockfuncs.c @@ -518,8 +518,14 @@ pg_blocking_pids(PG_FUNCTION_ARGS) /* A proc never blocks itself, so ignore that entry */ if (instance == blocked_instance) continue; - /* Members of same lock group never block each other, either */ - if (instance->leaderPid == blocked_instance->leaderPid) + + /* + * Members of the same lock group do not block each other, except + * when extending a relation. + */ + if (instance->leaderPid == blocked_instance->leaderPid && + blocked_instance->locktag.locktag_type != + LOCKTAG_RELATION_EXTEND) continue; if (conflictMask & instance->holdMask) -- 2.34.1 --5NILkxRGLFFv2V7J--