0003-oauth-Skip-call-count-test-for-libcurl-8.20.0.patch

application/octet-stream

Filename: 0003-oauth-Skip-call-count-test-for-libcurl-8.20.0.patch
Type: application/octet-stream
Part: 2
Message: Re: [oauth] Increased CPU usage during device flow with libcurl 8.20.0

Patch

Format: format-patch
Series: patch 0003
Subject: oauth: Skip call-count test for libcurl 8.20.0
File+
src/test/modules/oauth_validator/t/001_server.pl 19 9
From ac8642cf9985fb23f5ed165cea2648a82f9285f6 Mon Sep 17 00:00:00 2001
From: Jacob Champion <jacob.champion@enterprisedb.com>
Date: Mon, 15 Jun 2026 14:48:17 -0700
Subject: [PATCH 3/3] oauth: Skip call-count test for libcurl 8.20.0

The call-count test in 001_server.pl runs into a recent upstream
regression in Curl:

    https://github.com/curl/curl/issues/21547

The symptom is high CPU usage on some platforms during OAuth HTTP
requests. But it looks like the fix is on track for a June 2026 release,
as part of Curl 8.21.0, so just skip the test if we happen to be using
the broken version.

Reported-by: Andrew Dunstan <andrew@dunslane.net>
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAOYmi%2B%3DyrwMSsHuNJ1V14isA4iSix5Xb3P3VEp1X0BS61MdV4A%40mail.gmail.com
---
 .../modules/oauth_validator/t/001_server.pl   | 28 +++++++++++++------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/test/modules/oauth_validator/t/001_server.pl b/src/test/modules/oauth_validator/t/001_server.pl
index 0d7618a5ef1..8941a355423 100644
--- a/src/test/modules/oauth_validator/t/001_server.pl
+++ b/src/test/modules/oauth_validator/t/001_server.pl
@@ -510,17 +510,27 @@ like(
 	qr@Visit https://example\.com/ and enter the code: postgresuser@,
 	"call count: stderr matches");
 
-my $count_pattern = qr/\[libpq\] total number of polls: (\d+)/;
-if (like($stderr, $count_pattern, "call count: count is printed"))
+SKIP:
 {
-	# For reference, a typical flow with two retries might take between 5-15
-	# calls to the client implementation. And while this will probably continue
-	# to change across OSes and Curl updates, we're likely in trouble if we see
-	# hundreds or thousands of calls.
-	$stderr =~ $count_pattern;
-	unless (cmp_ok($1, '<', 100, "call count is reasonably small"))
+	# Curl 8.20.0 regressed this test case:
+	#
+	#     https://github.com/curl/curl/issues/21547
+	#
+	skip 'call-count test is known to fail with libcurl 8.20.0', 2
+	  if $stderr =~ m/\Qinitialized libcurl 8.20.0\E/;
+
+	my $count_pattern = qr/\[libpq\] total number of polls: (\d+)/;
+	if (like($stderr, $count_pattern, "call count: count is printed"))
 	{
-		diag "full stderr:\n$stderr";
+		# For reference, a typical flow with two retries might take between 5-15
+		# calls to the client implementation. And while this will probably
+		# continue to change across OSes and Curl updates, we're likely in
+		# trouble if we see hundreds or thousands of calls.
+		$stderr =~ $count_pattern;
+		unless (cmp_ok($1, '<', 100, "call count is reasonably small"))
+		{
+			diag "full stderr:\n$stderr";
+		}
 	}
 }
 
-- 
2.34.1