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 1w5UJV-003IZk-38 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2026 19:54:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5UJU-00GDqS-1C for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2026 19:54:48 +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 1w5UJT-00GDqH-2q for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2026 19:54:48 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w5UJS-000000011Ty-06t5 for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2026 19:54:47 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-486fe655187so2767725e9.2 for ; Wed, 25 Mar 2026 12:54:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774468485; x=1775073285; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=jw/+H23NnqivN43eOSjyaMQMuTo9vRCxcu56Z3IxmDY=; b=Nrz64DAPhe298TMGf9327hGO0eTJ/LWqM71gbeKYV4gWGc4+Y2UO35Z3xzKCBylkSM Qrc379CTDAS464Cm70RmoTRGm9MEIPwyu1Yai9P3oPxTOQpDycH+5gjU/PC/dH5quDkv 2OefijKQA1QZ9lf4XXeZcrhx5r9ePP80kAYqdWT3BtAtQUDMoJoTW6GX5pH7Ymx4/bAL qsOQ/XlrsQ7NeNskyjx5GZUKj7FYQvGs49dXIkp1ptjINkbkT7cVZICa+CGP46+N/nIG YeJ9rvJxktBmQObgf12f6jSWpPtbZ8X3FUKVbFarlHdjFxmb2uUq3038owHPrRXgyYsx iHNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774468485; x=1775073285; h=in-reply-to:content-disposition: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; bh=jw/+H23NnqivN43eOSjyaMQMuTo9vRCxcu56Z3IxmDY=; b=NW9rQuGfIhUxNQ+6sLnFhbzO+O3Wrzlhkjyg1U2pIwOIbMqk/jlinfTrr63nEYunDI Kx5KauKkJrurwopo5qwk/SLBHcdfY1SN3GFozYiZplrQ8FIkkDqKWS93luMKjO4Av0bb uj8Pf50d+xx5YB60t63RGTOnhi7dDddRc2Qln4RfzpxWTjHJo0XgXLMuKT57BJm17/lE gqnDnYVhxA7T0olFUxftKu4NbQkUGBO1O90Gt2G1cQwfCj8/FBhG6U5BXHsKqmQVG3Aa RCH6YcJzYHgCkp974LIIL6BQF0nWVJVC15QCPKUY+/PC/SXqCZHz6Yjm66lqSH607pxw cs6g== X-Forwarded-Encrypted: i=1; AJvYcCV4t9wXITnUsFEGxMUTdmpH6B3FhAGoqpCZaq9174suhXhb2K18GbI+2w8BhQXuay5L+FPV6/3Fh6gVuko/@lists.postgresql.org X-Gm-Message-State: AOJu0YwyrQsvJcZP6xw+M5DCdKmnaIoglDnu2TKVS1u6omDwNhkCxebE FDI4EcChUHY9yw8Hek3GF222Fl4ifkw9VC9sUf0+I/RMyZAHsXMkTQS7 X-Gm-Gg: ATEYQzxkN7+tl6HlU7HRu9xik8hH420+YiFz5Dk1NJCs4lciwJz6D+Vwu6pTORrwwqy V8prKdCEZPvkEZdbRYJWv7D8XsUI9C1IWdcuh43d4X3Y+CJiQkjQHbEPyxjgf2XbEn8KhAStf3e /zkHITCBB+BpdPN0mh9jO/shkUzsVAiYe9yRFjXIquT4lUS3CM2Sv0gFvWeJaTfKuoY1F4Uv1+G p5HtKfqA/BI+E5d/N0LqX5QZqwwmDyByF9o4WKJqFUIz8RssE48CRuSmFDjjGSHuLtcMnOKlbE8 FegOaw9+ob02yDBdHx6vNHqLq8+NBAKo7QkcdAWMVqzA88NknjKTZvqGhOEnNUuxBgUPg/Z/Jxq u/t/zH2G8ySarBoS08KDBmfutiqWKrpRqGEyovQ5c6h1q1Fc1ZWY30ZZTcP++QrthHrnRsNYbhP jh/79B50x+StOmSvvOL92lL6iB7duXZgLH5myDCsiI39kB4ZRPWjbEgAoLX613aBUIapHT9urzi 3bp9CpesxIJeRxo2fbfv4Cc4det1ym5DR/g0fkgUkgivtNY0WXOfpnCfA== X-Received: by 2002:a05:600c:1f8e:b0:485:4006:960c with SMTP id 5b1f17b1804b1-4871605aa53mr73847045e9.16.1774468484546; Wed, 25 Mar 2026 12:54:44 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-487116f1905sm157780515e9.3.2026.03.25.12.54.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2026 12:54:43 -0700 (PDT) Date: Wed, 25 Mar 2026 19:54:42 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: Andres Freund , Jeff Davis , Greg Sabino Mullane , pgsql-hackers@lists.postgresql.org Subject: Re: Adding locks statistics Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="AUNYTZhlO/wpj51V" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --AUNYTZhlO/wpj51V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Wed, Mar 25, 2026 at 02:25:01PM +0900, Michael Paquier wrote: > On Wed, Mar 25, 2026 at 03:15:19AM +0000, Bertrand Drouvot wrote: > > Thanks for the test removal. I created an open item for v19 so that we > > don't forget to re-add a new version of the tests. I'll work on it. > > > > [1]: https://wiki.postgresql.org/wiki/PostgreSQL_19_Open_Items > > Thanks for adding that. We are most likely going to need the help of > the CI here. The buildfarm has been fortunately (unfortunately?) > stable on this one, and that would make for less noise overall. PFA a new version of the tests using an injection point. This new injection point is created in ProcSleep() when we know that the deadlock timeout fired. The patch adds a new query_until_stderr() subroutine in BackgroundPsql.pm: It does the same as query_until() except that it is waiting for a desired stderr (and not stdout). Thanks to it the session can wait until it gets the injection point notice. I think that looks clearer that way than using the logfile to look for the notice (should log_min_messages be set to an appropriate value). If you like the idea, maybe we could introduce query_until_stderr() in a separate commit. If you don't, then we could switch to looking in the server logfile instead of the session stderr. Then the new tests follow this workflow: - session 1 holds a lock - session 2 attaches to the new injection point with the notice action - session 2 is blocked by session 1 and waits until the injection point notice is received - session 1 releases its lock, session 2 commits - pg_stat_lock is polled until we get the counters for the lock type or die with a timeout That way there is no sleep at all. Once we know that session 2 has waited longer than the deadlock timeout (thanks to the new injection point notice) then we can release the locks and poll pg_stat_lock to get the updated stats. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --AUNYTZhlO/wpj51V Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-Add-new-tests-for-lock-stats.patch"