pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Emptying oauth_validator_libraries doesn't stop OAuth logins
14+ messages / 5 participants
[nested] [flat]

Commits from this thread:
  2026-11-12 79b9722a49 2e0fe6d5ac da36a19a61  oauth: Apply bgconn timeout per query in 001_server
  2026-11-05 dcf112bd4e  Fix oauth validator test on EXEC_BACKEND
  2026-11-05 c38de3ae60 e352ac8c5c 8e54a41457  oauth: Recheck oauth_validator_libraries during authentication
* Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-10-10 09:57  Zsolt Parragi <zsolt.parragi@percona.com>
  0 siblings, 2 replies; 14+ messages in thread

From: Zsolt Parragi @ 2026-10-10 09:57 UTC (permalink / raw)
  To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>; Jacob Champion <jacob.champion@enterprisedb.com>; Daniel Gustafsson <daniel@yesql.se>

Hello

The docs for oauth_validator_libraries say "If set to an empty string
(the default), OAuth connections will be refused", but that's only
true for a freshly started server. On a running one, setting it to ''
and reloading leaves existing oauth HBA lines working.

    LOG:  parameter "oauth_validator_libraries" changed to ""
    LOG:  parameter "oauth_validator_libraries" must be set for
authentication method "oauth"
    CONTEXT:  line 2 of configuration file ".../pg_hba.conf"
    LOG:  pg_hba.conf was not reloaded

SHOW reports '', pg_hba_file_rules shows the error, but logins on the
oauth line still succeed.

The allowlist is only enforced by check_oauth_validator() while
pg_hba.conf is parsed. When the GUC change makes an oauth line
invalid, the whole HBA reload fails, and the postmaster keeps the
previously parsed lines, including the validator name that was
resolved against the old list. load_validator_library() never looks at
the current setting. The same happens if a line has an explicit
validator=foo and foo is removed from the list: the validator that is
"not permitted by oauth_validator_libraries" keeps authenticating
users.

The attached patch calls check_oauth_validator() again in
oauth_init(), before loading the library, and fails the authentication
if the validator isn't permitted anymore. Only logins on affected
oauth lines fail, everything else keeps working with the old HBA lines
as before.

The patch doesn't make the behavior stricter than what we already have
elsewhere:
* After a restart, the same configuration makes the postmaster refuse
to start (load_hba() fails at startup).
* With EXEC_BACKEND, every backend re-parses pg_hba.conf with the
current setting, so all new connections already fail with "could not
load pg_hba.conf", not only the oauth ones.

Attachments:

v1-0001-oauth-Recheck-oauth_validator_libraries-during-au.patch (application/octet-stream, 3.0K) download From d5bc7ea5dbf96ed016bfb1852b8e3857e55a64dc Mon Sep 17 00:00:00 2001 From: Zsolt Parragi <zsolt.parragi@percona.com> Date: Sat, 10 Oct 2026 09:06:55 +0000 Subject: [PATCH v1] oauth: Recheck oauth_validator_libraries during authentication The validator allowlist is only enforced while parsing pg_hba.conf. If a change to oauth_validator_libraries makes an existing oauth line invalid, the HBA reload fails and the old lines stay in use, so a removed validator keeps authenticating users. In particular, setting the list to '' doesn't refuse OAuth connections, as documented. Check the HBA line against the current setting again before loading the validator. Backpatch-through: 18 --- src/backend/libpq/auth-oauth.c | 14 ++++++++++++++ src/test/modules/oauth_validator/t/001_server.pl | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/backend/libpq/auth-oauth.c b/src/backend/libpq/auth-oauth.c index fb830065fba..29a0b00ba1c 100644 --- a/src/backend/libpq/auth-oauth.c +++ b/src/backend/libpq/auth-oauth.c @@ -109,6 +109,7 @@ static void * oauth_init(Port *port, const char *selected_mech, const char *shadow_pass) { struct oauth_ctx *ctx; + char *err_msg; if (strcmp(selected_mech, OAUTHBEARER_NAME) != 0) ereport(ERROR, @@ -127,6 +128,19 @@ oauth_init(Port *port, const char *selected_mech, const char *shadow_pass) ctx->issuer = port->hba->oauth_issuer; ctx->scope = port->hba->oauth_scope; + /* + * The allowlist is otherwise only enforced when pg_hba.conf is parsed. If + * a change to oauth_validator_libraries caused the last reload to fail, + * we're still using the old HBA lines, and their validator may no longer + * be permitted. Check again before loading it. + */ + if (!check_oauth_validator(port->hba, LOG, &err_msg)) + ereport(ERROR, + errcode(ERRCODE_CONFIG_FILE_ERROR), + errmsg("OAuth validator \"%s\" is not permitted by \"%s\"", + port->hba->oauth_validator, + "oauth_validator_libraries")); + load_validator_library(port->hba->oauth_validator); return ctx; diff --git a/src/test/modules/oauth_validator/t/001_server.pl b/src/test/modules/oauth_validator/t/001_server.pl index 444de01ea5d..7cb8028f36b 100644 --- a/src/test/modules/oauth_validator/t/001_server.pl +++ b/src/test/modules/oauth_validator/t/001_server.pl @@ -143,6 +143,17 @@ $log_start = $node->wait_for_log( $log_start); $bgconn->query_safe('SELECT 1'); +# The failed reload leaves the old HBA lines in place, but their validator is +# no longer allowed. +$node->connect_fails( + "user=test dbname=postgres oauth_issuer=$issuer oauth_client_id=f02c6361-0635", + "validator removed from oauth_validator_libraries is not used", + expected_stderr => + qr/OAuth validator "validator" is not permitted by "oauth_validator_libraries"/, + log_like => [ + qr/parameter "oauth_validator_libraries" must be set for authentication method "oauth"/ + ]); + $node->append_conf('postgresql.conf', "oauth_validator_libraries = 'validator'"); $node->reload; -- 2.55.0
^ permalink raw reply [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-03 18:06  Daniel Gustafsson <daniel@yesql.se>
  parent: Zsolt Parragi <zsolt.parragi@percona.com>
  1 sibling, 0 replies; 14+ messages in thread

From: Daniel Gustafsson @ 2026-11-03 18:06 UTC (permalink / raw)
  To: Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>; Jacob Champion <jacob.champion@enterprisedb.com>

> On 10 Oct 2026, at 11:57, Zsolt Parragi <zsolt.parragi@percona.com> wrote:

Sorry for being slow to get to this, working through the backlog of bugs in the
inbox now.

> The attached patch calls check_oauth_validator() again in
> oauth_init(), before loading the library, and fails the authentication
> if the validator isn't permitted anymore. Only logins on affected
> oauth lines fail, everything else keeps working with the old HBA lines
> as before.

Thanks for the patch, I agree that the current behaviour is incorrect wrt the
docs and we should fix this down to v18.

	+	if (!check_oauth_validator(port->hba, LOG, &err_msg))
	+		ereport(ERROR,

Since check_oauth_validator already performs error logging, why not let it
handle erroring out with a higher elevel than LOG?  Also, we should be using
COMMERROR here to keep details from bleeding through during authentication.
The attached v2 implements this, thoughts on that?

Another option would be a larger refactoring to move this re-checking into
load_validator_library() to make sure it cannot bypass due to programmer error,
but for a backpatchable fix I think the current approach is better.

--
Daniel Gustafsson

Attachments:

v2-0001-oauth-Recheck-oauth_validator_libraries-during-au.patch (application/octet-stream, 2.9K) download From 3caf616fa2d40fce925cb40d1e57375094167e58 Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson <dgustafsson@postgresql.org> Date: Tue, 3 Nov 2026 18:30:58 +0100 Subject: [PATCH v2] oauth: Recheck oauth_validator_libraries during authentication The validator allowlist is only enforced while parsing pg_hba.conf. If changing oauth_validator_libraries makes an existing oauth line invalid, the HBA reload fails and the old lines stay in use, so a removed validator keeps authenticating users. In particular, when setting the list to the empty string, the server doesn't refuse an OAuth connection, as documented. Backpatch down to v18 where OAuth was introduced. Author: Zsolt Parragi <zsolt.parragi@percona.com> Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://postgr.es/m/CAN4CZFNbWXwC=s4t9Xu1kitLsQvTe-EwpVtFCjixWCHBxRTraQ@mail.gmail.com Backpatch-through: 18 --- src/backend/libpq/auth-oauth.c | 8 ++++++++ src/test/modules/oauth_validator/t/001_server.pl | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/backend/libpq/auth-oauth.c b/src/backend/libpq/auth-oauth.c index fb830065fba..8715e5086db 100644 --- a/src/backend/libpq/auth-oauth.c +++ b/src/backend/libpq/auth-oauth.c @@ -109,6 +109,7 @@ static void * oauth_init(Port *port, const char *selected_mech, const char *shadow_pass) { struct oauth_ctx *ctx; + char *err_msg; if (strcmp(selected_mech, OAUTHBEARER_NAME) != 0) ereport(ERROR, @@ -127,6 +128,13 @@ oauth_init(Port *port, const char *selected_mech, const char *shadow_pass) ctx->issuer = port->hba->oauth_issuer; ctx->scope = port->hba->oauth_scope; + /* + * If a change to oauth_validator_libraries caused the last reload to + * fail, we're still using the old HBA lines, and their validator may no + * longer be permitted. Check again before loading it. + */ + check_oauth_validator(port->hba, COMMERROR, &err_msg); + load_validator_library(port->hba->oauth_validator); return ctx; diff --git a/src/test/modules/oauth_validator/t/001_server.pl b/src/test/modules/oauth_validator/t/001_server.pl index 444de01ea5d..339cf7bd18c 100644 --- a/src/test/modules/oauth_validator/t/001_server.pl +++ b/src/test/modules/oauth_validator/t/001_server.pl @@ -143,6 +143,16 @@ $log_start = $node->wait_for_log( $log_start); $bgconn->query_safe('SELECT 1'); +# The failed reload leaves the old HBA lines in place, but their validator is +# no longer allowed so the connection shall be refused. +$node->connect_fails( + "user=test dbname=postgres oauth_issuer=$issuer oauth_client_id=f02c6361-0635", + "validator removed from oauth_validator_libraries is not used", + expected_stderr => qr/could not fetch OpenID discovery document/, + log_like => [ + qr/parameter "oauth_validator_libraries" must be set for authentication method "oauth"/ + ]); + $node->append_conf('postgresql.conf', "oauth_validator_libraries = 'validator'"); $node->reload; -- 2.39.3 (Apple Git-146) =
^ permalink raw reply [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-03 21:54  Jacob Champion <jacob.champion@enterprisedb.com>
  parent: Zsolt Parragi <zsolt.parragi@percona.com>
  1 sibling, 2 replies; 14+ messages in thread

From: Jacob Champion @ 2026-11-03 21:54 UTC (permalink / raw)
  To: Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>; Daniel Gustafsson <daniel@yesql.se>

On Sat, Oct 10, 2026 at 2:58 AM Zsolt Parragi <zsolt.parragi@percona.com> wrote:
> Hello

Hi, thanks for the report! As a short detour from the patch itself, it
looks like I missed the group of emails sent on October 10, so
Daniel's responses today are the first I'm reading them. How many were
sent in total?

--Jacob






^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-04 02:48  shihao zhong <zhong950419@gmail.com>
  parent: Jacob Champion <jacob.champion@enterprisedb.com>
  1 sibling, 1 reply; 14+ messages in thread

From: shihao zhong @ 2026-11-04 02:48 UTC (permalink / raw)
  To: Jacob Champion <jacob.champion@enterprisedb.com>; +Cc: Zsolt Parragi <zsolt.parragi@percona.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>; Daniel Gustafsson <daniel@yesql.se>

Hi Daniel & Zsolt,

Thanks for working on this. This is my first time review oauth related
patches, and I hope my understanding is correct here, if not, please
correct me.

I tried v2 and the login still works.  v1 checked the return value of
check_oauth_validator(), but v2 drops that.

COMMERROR only logs, and nothing checks the return value.
With the list set to '' and reloaded, I can still log in and run queries:

  LOG:  parameter "oauth_validator_libraries" must be set ...
  LOG:  connection authenticated: identity="test" method=oauth

The attached patch on top of v2 fails the login when the check fails.

Thanks,
Shihao

Attachments:

nocfbot-v2-0002-Reject-the-login-when-the-validator-is-no-longer-all.patch (application/octet-stream, 2.2K) download From ce46e5cacc67b0da0038a698e8ff3cdb5ab4e71e Mon Sep 17 00:00:00 2001 From: shihao zhong <zhong950419@gmail.com> Date: Tue, 3 Nov 2026 21:27:52 -0500 Subject: [PATCH] Reject the login when the validator is no longer allowed check_oauth_validator() only logs at COMMERROR, so its return value has to be checked. Otherwise the removed validator is still loaded and the login succeeds. Raise the usual OAuth failure message when the check fails, and make the test expect it. The old test passed without the fix because the client fails at discovery either way. --- src/backend/libpq/auth-oauth.c | 6 +++++- src/test/modules/oauth_validator/t/001_server.pl | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend/libpq/auth-oauth.c b/src/backend/libpq/auth-oauth.c index 8715e5086db..2c9854fbdd7 100644 --- a/src/backend/libpq/auth-oauth.c +++ b/src/backend/libpq/auth-oauth.c @@ -133,7 +133,11 @@ oauth_init(Port *port, const char *selected_mech, const char *shadow_pass) * fail, we're still using the old HBA lines, and their validator may no * longer be permitted. Check again before loading it. */ - check_oauth_validator(port->hba, COMMERROR, &err_msg); + if (!check_oauth_validator(port->hba, COMMERROR, &err_msg)) + ereport(FATAL, + errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION), + errmsg("OAuth bearer authentication failed for user \"%s\"", + port->user_name)); load_validator_library(port->hba->oauth_validator); diff --git a/src/test/modules/oauth_validator/t/001_server.pl b/src/test/modules/oauth_validator/t/001_server.pl index 339cf7bd18c..b9333e5bca5 100644 --- a/src/test/modules/oauth_validator/t/001_server.pl +++ b/src/test/modules/oauth_validator/t/001_server.pl @@ -148,7 +148,8 @@ $bgconn->query_safe('SELECT 1'); $node->connect_fails( "user=test dbname=postgres oauth_issuer=$issuer oauth_client_id=f02c6361-0635", "validator removed from oauth_validator_libraries is not used", - expected_stderr => qr/could not fetch OpenID discovery document/, + expected_stderr => + qr/OAuth bearer authentication failed for user "test"/, log_like => [ qr/parameter "oauth_validator_libraries" must be set for authentication method "oauth"/ ]); -- 2.37.1 (Apple Git-137.1)
^ permalink raw reply [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-04 08:19  Zsolt Parragi <zsolt.parragi@percona.com>
  parent: Jacob Champion <jacob.champion@enterprisedb.com>
  1 sibling, 1 reply; 14+ messages in thread

From: Zsolt Parragi @ 2026-11-04 08:19 UTC (permalink / raw)
  To: Jacob Champion <jacob.champion@enterprisedb.com>; +Cc: pgsql-hackers@lists.postgresql.org, Daniel Gustafsson <daniel@yesql.se>

On Tue, 03 Nov 2026, Jacob Champion <jacob.champion@enterprisedb.com> wrote:
> Hi, thanks for the report! As a short detour from the patch itself, it
> looks like I missed the group of emails sent on October 10, so
> Daniel's responses today are the first I'm reading them. How many were
> sent in total?

There were 2 others.

* Custom oauth validator options:
  https://www.postgresql.org/message-id/CAN4CZFOZX7r4-i--ucw38mhb6z0WzC1U%2BVFt45mFwiw5qqqbXg%40mail.g...
* Another in the postmaster crash thread:
  https://www.postgresql.org/message-id/CAN4CZFP7ZMLB5Q1P4H__2d54om6fO%2BOEBZpWLpMwhFipobrEEw%40mail.g...

And there are also two earlier oauth-related threads:

* About the additional debug trace warning:
  https://www.postgresql.org/message-id/CAN4CZFOUG9csxguH_%2Bcz%3DnQ8HQVKLcVvr%3DqJSbga%2Btj-3FZhLA%40...
* About documenting/improving not requiring SSL:
  https://www.postgresql.org/message-id/CAN4CZFNy23wWKF%2B78QG3cfunjJpQWFc7eNP7qcYPB6Sg-NhTQQ%40mail.g...






^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-04 08:24  Daniel Gustafsson <daniel@yesql.se>
  parent: shihao zhong <zhong950419@gmail.com>
  0 siblings, 1 reply; 14+ messages in thread

From: Daniel Gustafsson @ 2026-11-04 08:24 UTC (permalink / raw)
  To: shihao zhong <zhong950419@gmail.com>; +Cc: Jacob Champion <jacob.champion@enterprisedb.com>; Zsolt Parragi <zsolt.parragi@percona.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

> On 4 Nov 2026, at 03:48, shihao zhong <zhong950419@gmail.com> wrote:

> I tried v2 and the login still works.  v1 checked the return value of
> check_oauth_validator(), but v2 drops that.
> 
> COMMERROR only logs, and nothing checks the return value. 

Thanks, I was clearly undercaffeinated.

--
Daniel Gustafsson







^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-04 09:09  Zsolt Parragi <zsolt.parragi@percona.com>
  parent: Daniel Gustafsson <daniel@yesql.se>
  0 siblings, 2 replies; 14+ messages in thread

From: Zsolt Parragi @ 2026-11-04 09:09 UTC (permalink / raw)
  To: Daniel Gustafsson <daniel@yesql.se>; +Cc: shihao zhong <zhong950419@gmail.com>; Jacob Champion <jacob.champion@enterprisedb.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

COMMERROR is a cosmetic change (during auth we send error or greater
to the client, not log), and the rest of the OAuth code uses ERROR,
which then gets promoted to FATAL.

The main question is how much information we should include in the
error message to the user, from that perspective Shihao's more generic
message might be better.

v3 is v1 + the COMMERROR and the error message change.

Attachments:

v3-0001-oauth-Recheck-oauth_validator_libraries-during-au.patch (application/octet-stream, 3.3K) download From 41a42035035819a58e7502d1c6211a235172193a Mon Sep 17 00:00:00 2001 From: Zsolt Parragi <zsolt.parragi@percona.com> Date: Sat, 10 Oct 2026 09:06:55 +0000 Subject: [PATCH v3] oauth: Recheck oauth_validator_libraries during authentication The validator allowlist is only enforced while parsing pg_hba.conf. If a change to oauth_validator_libraries makes an existing oauth line invalid, the HBA reload fails and the old lines stay in use, so a removed validator keeps authenticating users. In particular, setting the list to '' doesn't refuse OAuth connections, as documented. Check the HBA line against the current setting again before loading the validator. The details, including the pg_hba.conf line, only go to the server log; the client gets the usual authentication failure. Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Reviewed-by: Shihao Zhong <zhong950419@gmail.com> Discussion: https://postgr.es/m/CAN4CZFNbWXwC=s4t9Xu1kitLsQvTe-EwpVtFCjixWCHBxRTraQ@mail.gmail.com Backpatch-through: 18 --- src/backend/libpq/auth-oauth.c | 14 ++++++++++++++ src/test/modules/oauth_validator/t/001_server.pl | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/backend/libpq/auth-oauth.c b/src/backend/libpq/auth-oauth.c index fb830065fba..3fc6097ce42 100644 --- a/src/backend/libpq/auth-oauth.c +++ b/src/backend/libpq/auth-oauth.c @@ -109,6 +109,7 @@ static void * oauth_init(Port *port, const char *selected_mech, const char *shadow_pass) { struct oauth_ctx *ctx; + char *err_msg; if (strcmp(selected_mech, OAUTHBEARER_NAME) != 0) ereport(ERROR, @@ -127,6 +128,19 @@ oauth_init(Port *port, const char *selected_mech, const char *shadow_pass) ctx->issuer = port->hba->oauth_issuer; ctx->scope = port->hba->oauth_scope; + /* + * The allowlist is otherwise only enforced when pg_hba.conf is parsed. If + * a change to oauth_validator_libraries caused the last reload to fail, + * we're still using the old HBA lines, and their validator may no longer + * be permitted. Check again before loading it. The details go to the + * server log only; the client just sees the usual authentication failure. + */ + if (!check_oauth_validator(port->hba, COMMERROR, &err_msg)) + ereport(ERROR, + errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION), + errmsg("OAuth bearer authentication failed for user \"%s\"", + port->user_name)); + load_validator_library(port->hba->oauth_validator); return ctx; diff --git a/src/test/modules/oauth_validator/t/001_server.pl b/src/test/modules/oauth_validator/t/001_server.pl index 444de01ea5d..bc602b69a53 100644 --- a/src/test/modules/oauth_validator/t/001_server.pl +++ b/src/test/modules/oauth_validator/t/001_server.pl @@ -143,6 +143,17 @@ $log_start = $node->wait_for_log( $log_start); $bgconn->query_safe('SELECT 1'); +# The failed reload leaves the old HBA lines in place, but their validator is +# no longer allowed. +$node->connect_fails( + "user=test dbname=postgres oauth_issuer=$issuer oauth_client_id=f02c6361-0635", + "validator removed from oauth_validator_libraries is not used", + expected_stderr => + qr/OAuth bearer authentication failed for user "test"/, + log_like => [ + qr/parameter "oauth_validator_libraries" must be set for authentication method "oauth"/ + ]); + $node->append_conf('postgresql.conf', "oauth_validator_libraries = 'validator'"); $node->reload; -- 2.56.0
^ permalink raw reply [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-04 14:36  shihao zhong <zhong950419@gmail.com>
  parent: Zsolt Parragi <zsolt.parragi@percona.com>
  1 sibling, 0 replies; 14+ messages in thread

From: shihao zhong @ 2026-11-04 14:36 UTC (permalink / raw)
  To: Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: Daniel Gustafsson <daniel@yesql.se>; Jacob Champion <jacob.champion@enterprisedb.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

Hi Zsolt,

Thanks for v3.

I would keep the generic message. It is the same string auth_failed()
uses for a bad token. So the client cannot tell a removed validator
from a normal failure, which I think is also what Daniel wanted from
COMMERROR.

Thanks,
Shihao

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-05 21:17  Daniel Gustafsson <daniel@yesql.se>
  parent: Zsolt Parragi <zsolt.parragi@percona.com>
  1 sibling, 2 replies; 14+ messages in thread

From: Daniel Gustafsson @ 2026-11-05 21:17 UTC (permalink / raw)
  To: Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: shihao zhong <zhong950419@gmail.com>; Jacob Champion <jacob.champion@enterprisedb.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

> On 4 Nov 2026, at 10:09, Zsolt Parragi <zsolt.parragi@percona.com> wrote:

> v3 is v1 + the COMMERROR and the error message change.

I pushed this earlier today, but according the buildfarm the backpatch of the
test to 18 wasn't entirely correct.  Will fix when back at the laptop.

--
Daniel Gustafsson







^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-05 21:33  Jacob Champion <jacob.champion@enterprisedb.com>
  parent: Daniel Gustafsson <daniel@yesql.se>
  1 sibling, 0 replies; 14+ messages in thread

From: Jacob Champion @ 2026-11-05 21:33 UTC (permalink / raw)
  To: Daniel Gustafsson <daniel@yesql.se>; +Cc: Zsolt Parragi <zsolt.parragi@percona.com>; shihao zhong <zhong950419@gmail.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

On Thu, Nov 5, 2026 at 1:17 PM Daniel Gustafsson <daniel@yesql.se> wrote:
> I pushed this earlier today, but according the buildfarm the backpatch of the
> test to 18 wasn't entirely correct.  Will fix when back at the laptop.

Thanks!

This falls into that same class of "atomic behavior when the
configuration is inconsistent" which I missed in the SNI set, too, so
add that to my list of blind spots. It'd be nice (with all our copious
free time?) to try to improve the whole system there... That
intersects with Zsolt's threads on GUC+HBA-et-al and/or Nico's
interest in moving config into the DB itself.

--Jacob






^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-06 14:21  Daniel Gustafsson <daniel@yesql.se>
  parent: Zsolt Parragi <zsolt.parragi@percona.com>
  0 siblings, 0 replies; 14+ messages in thread

From: Daniel Gustafsson @ 2026-11-06 14:21 UTC (permalink / raw)
  To: Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: Jacob Champion <jacob.champion@enterprisedb.com>; pgsql-hackers@lists.postgresql.org

> On 4 Nov 2026, at 09:19, Zsolt Parragi <zsolt.parragi@percona.com> wrote:
> 
> On Tue, 03 Nov 2026, Jacob Champion <jacob.champion@enterprisedb.com> wrote:
>> Hi, thanks for the report! As a short detour from the patch itself, it
>> looks like I missed the group of emails sent on October 10, so
>> Daniel's responses today are the first I'm reading them. How many were
>> sent in total?
> 
> There were 2 others.
> 
> * Custom oauth validator options:
>  https://www.postgresql.org/message-id/CAN4CZFOZX7r4-i--ucw38mhb6z0WzC1U%2BVFt45mFwiw5qqqbXg%40mail.g...

This will be deferred to v20.

> * Another in the postmaster crash thread:
>  https://www.postgresql.org/message-id/CAN4CZFP7ZMLB5Q1P4H__2d54om6fO%2BOEBZpWLpMwhFipobrEEw%40mail.g...

This one was pushed and backpatched yesterday.

> * About the additional debug trace warning:
>  https://www.postgresql.org/message-id/CAN4CZFOUG9csxguH_%2Bcz%3DnQ8HQVKLcVvr%3DqJSbga%2Btj-3FZhLA%40...

This was on my radar but was forgotten about in the lead-up to events and other
things.  I still think it's valuable but not something I want to have go in
just before a release freeze.

> * About documenting/improving not requiring SSL:
>  https://www.postgresql.org/message-id/CAN4CZFNy23wWKF%2B78QG3cfunjJpQWFc7eNP7qcYPB6Sg-NhTQQ%40mail.g...

I just posted an updated patch for the documentation changes.

--
Daniel Gustafsson







^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-08 10:00  Alexander Lakhin <exclusion@gmail.com>
  parent: Daniel Gustafsson <daniel@yesql.se>
  1 sibling, 1 reply; 14+ messages in thread

From: Alexander Lakhin @ 2026-11-08 10:00 UTC (permalink / raw)
  To: Daniel Gustafsson <daniel@yesql.se>; Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: shihao zhong <zhong950419@gmail.com>; Jacob Champion <jacob.champion@enterprisedb.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

Hello Daniel and Zsolt,

05.11.2026 23:17, Daniel Gustafsson wrote:
> I pushed this earlier today, but according the buildfarm the backpatch of the
> test to 18 wasn't entirely correct.  Will fix when back at the laptop.

Recent changes to oauth_validator/001_server.pl increased its duration so
it fails now on overloaded (due to concurrent activity?) animals, like in
[1] and [2]:
# die: IPC::Run: timeout on timer #1 at /usr/share/perl5/IPC/Run.pm line 3361.
# Looks like your test exited with 29 just after 151.

# die: IPC::Run: timeout on timer #1 at /usr/share/perl5/IPC/Run.pm line 3361.
# Looks like your test exited with 2 just after 133.

Logs of these animals show that other tests also ran for longer in these
runs, e.g. compare [2]:
218/401 recovery - postgresql:recovery/027_stream_regress OK             1048.99s   11 subtests passed
392/401 oauth_validator - postgresql:oauth_validator/001_server ERROR           191.48s   exit status 2

vs the next successful run [3]
183/401 recovery - postgresql:recovery/027_stream_regress OK               88.70s   11 subtests passed
400/401 oauth_validator - postgresql:oauth_validator/001_server OK               55.08s   173 subtests passed

Out of 200+ animals, only 25 have "oauth" in PG_TEST_EXTRA plus libcurl
enabled -- this can explain why definitely slower animals didn't fail the
test.

Could you please look if the test can be made more resilient against such slowdowns?

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=grassquit&dt=2026-11-07%2000%3A31%3A47
[2] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=olingo&dt=2026-11-07%2000%3A31%3A30
[3] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=olingo&dt=2026-11-07%2002%3A52%3A57

Best regards,
Alexander

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-08 10:49  Zsolt Parragi <zsolt.parragi@percona.com>
  parent: Alexander Lakhin <exclusion@gmail.com>
  0 siblings, 1 reply; 14+ messages in thread

From: Zsolt Parragi @ 2026-11-08 10:49 UTC (permalink / raw)
  To: Alexander Lakhin <exclusion@gmail.com>; +Cc: pgsql-hackers@lists.postgresql.org, Daniel Gustafsson <daniel@yesql.se>; shihao zhong <zhong950419@gmail.com>; Jacob Champion <jacob.champion@enterprisedb.com>

> Could you please look if the test can be made more resilient against such slowdowns?

Attached a single line change that resets the timer for each query for
the background connection. I don't see anything wrong with the tests
otherwise, the problem is simply that we are using a single background
connection for a long time, and on a heavily overloaded machine with
asan, the test can sometimes exceed the timeout value.

Attachments:

v1-0001-oauth-Apply-bgconn-timeout-per-query-in-001_serve.patch (text/x-patch, 1.5K) download From eee33c5e3b385a2126048643ad4f05e770d39b86 Mon Sep 17 00:00:00 2001 From: Zsolt Parragi <zsolt.parragi@percona.com> Date: Sun, 8 Nov 2026 10:12:06 +0000 Subject: [PATCH v1] oauth: Apply bgconn timeout per query in 001_server The background psql session in oauth_validator/001_server lives for most of the test, but its timer was started once and never restarted, so timeout_default applied to the whole session rather than to each query. On slow or loaded buildfarm animals the test can exceed that and the next query fails with "IPC::Run: timeout on timer #1" even though nothing is stuck. Fix by restarting the timer per query. Backpatch to v18 where the test was introduced. Reported-by: Alexander Lakhin <exclusion@gmail.com> Discussion: https://postgr.es/m/078be990-1420-4ab5-997f-82e7afb86f7c@gmail.com Backpatch-through: 18 --- src/test/modules/oauth_validator/t/001_server.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/modules/oauth_validator/t/001_server.pl b/src/test/modules/oauth_validator/t/001_server.pl index 5308550d06c..69c58cec706 100644 --- a/src/test/modules/oauth_validator/t/001_server.pl +++ b/src/test/modules/oauth_validator/t/001_server.pl @@ -60,6 +60,7 @@ my $exec_backend = $node->safe_psql('postgres', 'SHOW debug_exec_backend'); # Save a background connection for later configuration changes. my $bgconn = $node->background_psql('postgres'); +$bgconn->set_query_timer_restart(); my $webserver = OAuth::Server->new(); $webserver->run(); -- 2.56.0
^ permalink raw reply [nested|flat] 14+ messages in thread

* Re: Emptying oauth_validator_libraries doesn't stop OAuth logins
@ 2026-11-09 11:58  Daniel Gustafsson <daniel@yesql.se>
  parent: Zsolt Parragi <zsolt.parragi@percona.com>
  0 siblings, 0 replies; 14+ messages in thread

From: Daniel Gustafsson @ 2026-11-09 11:58 UTC (permalink / raw)
  To: Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>; shihao zhong <zhong950419@gmail.com>; Jacob Champion <jacob.champion@enterprisedb.com>

> On 8 Nov 2026, at 11:49, Zsolt Parragi <zsolt.parragi@percona.com> wrote:
> 
>> Could you please look if the test can be made more resilient against such slowdowns?
> 
> Attached a single line change that resets the timer for each query for
> the background connection. I don't see anything wrong with the tests
> otherwise, the problem is simply that we are using a single background
> connection for a long time, and on a heavily overloaded machine with
> asan, the test can sometimes exceed the timeout value.

Agreed, looking this over I cannot find any other issue.  Will fix when the
backbranches are open again.

--
Daniel Gustafsson







^ permalink  raw  reply  [nested|flat] 14+ messages in thread


end of thread, other threads:[~2026-11-09 11:58 UTC | newest]

Thread overview: 14+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10 09:57 Emptying oauth_validator_libraries doesn't stop OAuth logins Zsolt Parragi <zsolt.parragi@percona.com>
2026-11-03 18:06 ` Daniel Gustafsson <daniel@yesql.se>
2026-11-03 21:54 ` Jacob Champion <jacob.champion@enterprisedb.com>
2026-11-04 02:48   ` shihao zhong <zhong950419@gmail.com>
2026-11-04 08:24     ` Daniel Gustafsson <daniel@yesql.se>
2026-11-04 09:09       ` Zsolt Parragi <zsolt.parragi@percona.com>
2026-11-04 14:36         ` shihao zhong <zhong950419@gmail.com>
2026-11-05 21:17         ` Daniel Gustafsson <daniel@yesql.se>
2026-11-05 21:33           ` Jacob Champion <jacob.champion@enterprisedb.com>
2026-11-08 10:00           ` Alexander Lakhin <exclusion@gmail.com>
2026-11-08 10:49             ` Zsolt Parragi <zsolt.parragi@percona.com>
2026-11-09 11:58               ` Daniel Gustafsson <daniel@yesql.se>
2026-11-04 08:19   ` Zsolt Parragi <zsolt.parragi@percona.com>
2026-11-06 14:21     ` Daniel Gustafsson <daniel@yesql.se>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox