Re: CI slowdown due to PG_TEST_INITDB_EXTRA_OPTS
Re: CI slowdown due to PG_TEST_INITDB_EXTRA_OPTS
On Sat, 18 Jul 2026 at 20:48, Tom Lane wrote: > It looks like any one job mostly uses the same value of > PG_TEST_INITDB_EXTRA_OPTS. Could we record what was used to set up > the template, and allow using it if that matches? Yeah, that seems to work pretty well. See attached. I'm getting similar test timings in CI with this as Andres got for the Linux runs that he did when removing PG_TEST_INITDB_EXTRA_OPTS. For MacOS I see basically no improvement though, I guess that's probably because the debug_xxx options actually incur significant overhead. Maybe it's worth trying to move them to one of the faster runs. But that seems like a separate discussion.
Re: CI slowdown due to PG_TEST_INITDB_EXTRA_OPTS
От:
Andres Freund <andres@anarazel.de>
Дата:
Hi,
On 2026-07-20 23:47:16 +0200, Jelte Fennema-Nio wrote:
> On Sat, 18 Jul 2026 at 20:48, Tom Lane wrote:
> > It looks like any one job mostly uses the same value of
> > PG_TEST_INITDB_EXTRA_OPTS. Could we record what was used to set up
> > the template, and allow using it if that matches?
That seems like a somewhat complicated mechanism. But mainly I feel like it's
a workaround around the config-customization-via-env-var having to go through
exactly one file. None of the uses of PG_TEST_INITDB_EXTRA_OPTS in CI actually
needs it to be an initdb option, it's just a way to set configuration options
for the server via an environment variable.
I wonder if the best thing would be to add PG_TEST_SERVER_POSTGRES_OPTS or
such, which Cluster.pm and regress.c would add to postgresql.conf.
> For MacOS I see basically no improvement though, I guess that's probably
> because the debug_xxx options actually incur significant overhead. Maybe
> it's worth trying to move them to one of the faster runs. But that seems
> like a separate discussion.
Hm. I see very consistent improvements locally on an m4 mac mini. On CI the
runtime of the macos job is crazily variable, e.g. the last few runs on master
had these runtimes for macos' "Test world":
14m59s, 17m24s, 12m13s, 18m38s, 13m15s, 12m22s
No idea what causes that degree of variability. I guess the effect of
neighboring tasks is the most likely explanation...
In contrast, meson-64 has these "Test world" times for the same commits:
19m46s, 19m40s, 18m38s, 18m14s, 19m15s, 18m23s
(meson-64 is slow due to asan)
With the configuration for meson-64 instead done via:
- name: 'configure extra opts'
run: |
echo "io_method=io_uring" >> src/tools/ci/pg_ci_base.conf
cat src/tools/ci/pg_ci_base.conf
I see ~13m30s for meson-64.
Greetings,
Andres Freund
Re: CI slowdown due to PG_TEST_INITDB_EXTRA_OPTS
Hi, On Tue, 21 Jul 2026 at 03:56, Andres Freund wrote: > On 2026-07-20 23:47:16 +0200, Jelte Fennema-Nio wrote: > > On Sat, 18 Jul 2026 at 20:48, Tom Lane wrote: > > > It looks like any one job mostly uses the same value of > > > PG_TEST_INITDB_EXTRA_OPTS. Could we record what was used to set up > > > the template, and allow using it if that matches? > > I wonder if the best thing would be to add PG_TEST_SERVER_POSTGRES_OPTS or > such, which Cluster.pm and regress.c would add to postgresql.conf. Attached is an attempt to implement 'PG_TEST_SERVER_POSTGRES_OPTS'. Like Jelte, I didn't see any improvement for MacOS. -- Regards, Nazir Bilal Yavuz Microsoft
Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace
Hi, I ran into a postmaster crash while investigating a static analyzer report against 18.6. I reproduced it on master (92aaf50e230, --enable-cassert, Debian 13/aarch64). To reproduce, set the following in postgresql.conf: oauth_validator_libraries = ' ' and add an OAuth line without validator= to pg_hba.conf: host all all 127.0.0.1/32 oauth issuer="https://example.com" scope="openid" On reload the server log ends here: LOG: received SIGHUP, reloading configuration files LOG: parameter "oauth_validator_libraries" changed to " " gdb then reports SIGSEGV in check_oauth_validator(), via load_hba(). The running instance goes down with every session on it. The same configuration also prevents startup. pg_hba_file_rules() parses the file from a regular backend, so the same NULL dereference there kills the backend and the postmaster restarts the cluster. check_oauth_validator() treats an unset list as an error by looking at the raw GUC string, but SplitDirectoriesString() accepts a string of spaces and returns NIL. The subsequent elemlist->length dereferences that. This is a misconfiguration rather than a security issue -- the GUC has PGC_SIGHUP context and is marked GUC_SUPERUSER_ONLY. I've attached a patch against master that checks the parsed list instead. It also adds a TAP test for reload. The patched master built without warnings, and "make check" in src/test/modules/oauth_validator passed with PG_TEST_EXTRA=oauth. This appears to affect v18 onward, where OAuth support was added, so it may need back-patching. The v18 error message has different wording and would need a small adjustment. Could someone take a look at the attached patch and let me know if this is the right fix? Thanks, Yuriy
Re: Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 14 Sep 2026, at 13:22, Grigorev Jurij wrote: > Could someone take a look at the attached patch and let me know > if this is the right fix? Thanks for the report, that does indeed seem like the right fix. Added to my list of patches to review and apply before the next minors -- Daniel Gustafsson
Re: Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
- if (oauth_validator_libraries_string[0] == '\0')
- {
- ereport(elevel,
- errcode(ERRCODE_CONFIG_FILE_ERROR),
- errmsg("parameter \"%s\" must be set for authentication method \"%s\"",
- "oauth_validator_libraries", "oauth"),
- errcontext("line %d of configuration file \"%s\"",
- line_num, file_name));
- *err_msg = psprintf("parameter \"%s\" must be set for authentication method \"%s\"",
- "oauth_validator_libraries", "oauth");
- return false;
- }
-
/* SplitDirectoriesString needs a modifiable copy */
rawstring = pstrdup(oauth_validator_libraries_string);
pstrdup calls strlen which segfault on NULL. oauth_validator_libraries_string
has a default value of "" so it cannot be set to NULL by user action, but the
global variable backing the GUC is initialized as NULL so I wonder if it's
worth adding defensive programming like the below, or perhaps an Assert?
/* SplitDirectoriesString needs a modifiable copy */
- rawstring = pstrdup(oauth_validator_libraries_string);
+ rawstring = pstrdup(oauth_validator_libraries_string ?
+ oauth_validator_libraries_string : "");
--
Daniel Gustafsson
Re: Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace
Hi Daniel,
You're right. I would rather not treat NULL as an empty setting, since
that would turn an internal programming error into the user-facing
"must be set" error. Attached v3 adds:
Assert(oauth_validator_libraries_string != NULL);
before the pstrdup().
I also moved the whitespace-only TAP case to after the
pg_hba_file_rules() check. Its previous position made the test racy:
wait_for_log() synchronized with the postmaster reload, but not
necessarily with the process-local GUC state of the existing bgconn.
As a result, pg_hba_file_rules() could run in a backend that still had
the whitespace value loaded and return unexpected empty fields.
Moving the case after that assertion avoids making the
pg_hba_file_rules() result depend on the timing of SIGHUP processing in
bgconn. After restoring the setting, the test runs SHOW
oauth_validator_libraries through bgconn, ensuring that the backend has
processed the second SIGHUP before the later tests continue.
Thanks,
YuriyRe: Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace
От:
Jacob Champion <jacob.champion@enterprisedb.com>
Дата:
On Tue, Sep 15, 2026 at 2:43 PM Daniel Gustafsson wrote: > pstrdup calls strlen which segfault on NULL. oauth_validator_libraries_string > has a default value of "" so it cannot be set to NULL by user action, but the > global variable backing the GUC is initialized as NULL so I wonder if it's > worth adding defensive programming like the below, or perhaps an Assert? It looks like there are no GUC_LIST_INPUT params with a NULL .boot_val. I don't know if that's by design, but it's probably for the best given the decision in ff4597acd4c. There may be a bit of a tug-of-war going on between committers who prefer the explicit Assert() crash vs committers who are fine with the SEGV. (I prefer the assertion when it better documents intent, but at time of authorship I'm not sure I would have wanted to argue about it. :D) Thanks, --Jacob
Re: Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 17 Sep 2026, at 00:16, Jacob Champion wrote: > There may be a bit of a tug-of-war going on between committers who > prefer the explicit Assert() crash vs committers who are fine with the > SEGV. (I prefer the assertion when it better documents intent, but at > time of authorship I'm not sure I would have wanted to argue about it. > :D) I agree with the documenting aspect of the Assert. -- Daniel Gustafsson
Re: Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
Pushed with tiny bits of tweaking and with a backpatch down to 18. Thanks! ./daniel
Re: CI slowdown due to PG_TEST_INITDB_EXTRA_OPTS
От:
Jelte Fennema-Nio <postgres@jeltef.nl>
Дата:
On Wed, 22 Jul 2026 at 08:56, Nazir Bilal Yavuz wrote: > Attached is an attempt to implement 'PG_TEST_SERVER_POSTGRES_OPTS'. I'm starting to get kinda annoyed that this (or my earlier version) hasn't been committed yet, or at least made some progress. There's a trivial way to improve CI runtime by 25-30%. Why has this patch been in limbo for more than 2 months?
Re: Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace
От:
Alexander Lakhin <exclusion@gmail.com>
Дата:
Hello Daniel,
18.09.2026 01:24, Daniel Gustafsson wrote:
18.09.2026 01:24, Daniel Gustafsson wrote:
Pushed with tiny bits of tweaking and with a backpatch down to 18. Thanks! ./daniel
The test addition coined with bca67e5a3 is not very robust,
unfortunately. Buildfarm animal serinus found a way to break it [1]
as below:
# Failed test 'oauth_validator_libraries restored'
# at /home/bf/bf-build/serinus/HEAD/pgsql/src/test/modules/oauth_validator/t/001_server.pl line 152.
# got: ' '
# expected: 'validator'
# Looks like you failed 1 test of 171.
I've managed to reproduce this locally with a sleep:
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -569,6 +569,7 @@ ProcessConfigFileInternal(GucContext context, bool applySettings, int elevel)
item->name, item->value)));
}
item->applied = true;
+pg_usleep(100000);
}
else if (scres == 0)
{
It makes oauth_validator/001_server fail deterministically for me.
Could you take a look, please?
[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=serinus&dt=2026-09-29%2013%3A57%3A41
Best regards,
Alexander
Re: Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace
От:
Jacob Champion <jacob.champion@enterprisedb.com>
Дата:
On Wed, Sep 30, 2026 at 11:00 AM Alexander Lakhin wrote:
> The test addition coined with bca67e5a3 is not very robust,
> unfortunately. Buildfarm animal serinus found a way to break it [1]
> as below:
Bleh. These SIGHUP/log file races are really annoying, and I'm going
to need to trawl the list to see if anyone's proposed a more general
solution. (I keep thinking about assigning an xid as a generation
number to an in-memory configuration...)
For now, is the following test giving us much, or can we remove it?
We've already done the wait_for_log(). If that "sequence point" turns
out to be inadequate for some other reason, we'd have to fix it
anyway.
> is($bgconn->query_safe('SHOW oauth_validator_libraries'),
> 'validator', 'oauth_validator_libraries restored');
Thanks,
--Jacob
Re: CI slowdown due to PG_TEST_INITDB_EXTRA_OPTS
От:
Heikki Linnakangas <hlinnaka@iki.fi>
Дата:
On 23/09/2026 21:42, Jelte Fennema-Nio wrote: > On Wed, 22 Jul 2026 at 08:56, Nazir Bilal Yavuz wrote: >> Attached is an attempt to implement 'PG_TEST_SERVER_POSTGRES_OPTS'. > > I'm starting to get kinda annoyed that this (or my earlier version) > hasn't been committed yet, or at least made some progress. There's a > trivial way to improve CI runtime by 25-30%. Why has this patch been > in limbo for more than 2 months? Committed, thanks! - Heikki
Re: CI slowdown due to PG_TEST_INITDB_EXTRA_OPTS
От:
Andres Freund <andres@anarazel.de>
Дата:
Hi, On 2026-11-18 16:14:28 +0200, Heikki Linnakangas wrote: > On 23/09/2026 21:42, Jelte Fennema-Nio wrote: > > On Wed, 22 Jul 2026 at 08:56, Nazir Bilal Yavuz wrote: > > > Attached is an attempt to implement 'PG_TEST_SERVER_POSTGRES_OPTS'. > > > > I'm starting to get kinda annoyed that this (or my earlier version) > > hasn't been committed yet, or at least made some progress. There's a > > trivial way to improve CI runtime by 25-30%. Why has this patch been > > in limbo for more than 2 months? > Committed, thanks! Thanks for doing that! I'd like to see this backpatched, in preparation to backpatching CI. I don't want to start out with a larger set of differences than necessary. Any arguments against doing that? Greetings, Andres Freund
Re: CI slowdown due to PG_TEST_INITDB_EXTRA_OPTS
Hi, On Wed, 18 Nov 2026 at 23:07, Andres Freund wrote: > > On 2026-11-18 16:14:28 +0200, Heikki Linnakangas wrote: > > On 23/09/2026 21:42, Jelte Fennema-Nio wrote: > > > On Wed, 22 Jul 2026 at 08:56, Nazir Bilal Yavuz wrote: > > > > Attached is an attempt to implement 'PG_TEST_SERVER_POSTGRES_OPTS'. > > > > > > I'm starting to get kinda annoyed that this (or my earlier version) > > > hasn't been committed yet, or at least made some progress. There's a > > > trivial way to improve CI runtime by 25-30%. Why has this patch been > > > in limbo for more than 2 months? > > > Committed, thanks! > > Thanks for doing that! > > I'd like to see this backpatched, in preparation to backpatching CI. I don't > want to start out with a larger set of differences than necessary. I think this makes sense. There is one problem, 'PG_TEST_INITDB_EXTRA_OPTS' is introduced in the PG_17 [1] and not backpatched to 15 (where CI introduced). Because of this, 'PG_TEST_INITDB_EXTRA_OPTS' mentions are removed from REL_[15,16] patch for now. Backpatching [1] is another option, though. [1] https://github.com/postgres/postgres/commit/995d400ceca3e552f84fe19f150fb03327bdc0c2 -- Regards, Nazir Bilal Yavuz Microsoft
Re: CI slowdown due to PG_TEST_INITDB_EXTRA_OPTS
От:
Heikki Linnakangas <hlinnaka@iki.fi>
Дата:
On 19/11/2026 09:57, Nazir Bilal Yavuz wrote: > On Wed, 18 Nov 2026 at 23:07, Andres Freund wrote: >> >> On 2026-11-18 16:14:28 +0200, Heikki Linnakangas wrote: >>> On 23/09/2026 21:42, Jelte Fennema-Nio wrote: >>>> On Wed, 22 Jul 2026 at 08:56, Nazir Bilal Yavuz wrote: >>>>> Attached is an attempt to implement 'PG_TEST_SERVER_POSTGRES_OPTS'. >>>> >>>> I'm starting to get kinda annoyed that this (or my earlier version) >>>> hasn't been committed yet, or at least made some progress. There's a >>>> trivial way to improve CI runtime by 25-30%. Why has this patch been >>>> in limbo for more than 2 months? >> >>> Committed, thanks! >> >> Thanks for doing that! >> >> I'd like to see this backpatched, in preparation to backpatching CI. I don't >> want to start out with a larger set of differences than necessary. > > I think this makes sense. > > There is one problem, 'PG_TEST_INITDB_EXTRA_OPTS' is introduced in the > PG_17 [1] and not backpatched to 15 (where CI introduced). Because of > this, 'PG_TEST_INITDB_EXTRA_OPTS' mentions are removed from > REL_[15,16] patch for now. Backpatching [1] is another option, though. > > [1] https://github.com/postgres/postgres/commit/995d400ceca3e552f84fe19f150fb03327bdc0c2 I considered backpatching to 19, the patch would've applied cleanly. I didn't check branches older than that. But the fact that it added a new option to pg_regress gave me pause. That feels like a new feature, also visible to users, rather than just CI changes. I wouldn't object to backpatching it anyway, but that's why I didn't do it right away. - Heikki