xid_wraparound/002_limits.pl might fail due to transient warning

Started by Alexander Lakhinabout 2 months ago2 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

This thread has been committed, so CI has stopped here. Anything below is the last result it produced.

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t253276
psql -h localhost -U postgres

Built from patchset v2 (message #2), September 02, 2026 at 03:16 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t253276_2 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t253276_2 && git checkout t253276_2

Patchset v2 (message #2) is on t253276_2

Jump to latest
#1Alexander Lakhin
exclusion@gmail.com

Hello hackers,

New buildfarm animal partridge (aarch64, maybe with slow storage)
produced several unprecedented failures of 002_limits, e.g., [1]https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=partridge&dt=2026-07-22%2011%3A37%3A59, [2]https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=partridge&dt=2026-07-24%2000%3A00%3A42:
389/400 xid_wraparound - postgresql:xid_wraparound/002_limits ERROR           601.34s   exit status 1

[01:32:22.020](6.936s) not ok 3
[01:32:22.023](0.003s) #   Failed test at
/home/buildfarm/pg-buildfarm/builds/HEAD/pgsql/src/test/modules/xid_wraparound/t/002_limits.pl line 130.
[01:32:22.024](0.001s) #          got: 'start
# oldxact
# after 1 billion
# after 2 billion
# reached warn-limit
# after VACUUM
# after VACUUM'
#     expected: 'start
# oldxact
# after 1 billion
# after 2 billion
# reached warn-limit
# after VACUUM'

That is:
# Wait until autovacuum has processed the other databases and advanced
# the system-wide oldest-XID.
$ret =
  $node->poll_query_until('postgres',
    qq[INSERT INTO wraparoundtest VALUES ('after VACUUM')],
    'INSERT 0 1');

has been successfully executed two times instead of one.

002_limits_wraparound.log contains:
2026-07-24 01:32:21.791 UTC client backend[3424568] 002_limits.pl LOG:  statement: INSERT INTO wraparoundtest VALUES
('after VACUUM')
2026-07-24 01:32:21.793 UTC client backend[3424568] 002_limits.pl WARNING:  database "template0" must be vacuumed within
87544676 transactions
2026-07-24 01:32:21.793 UTC client backend[3424568] 002_limits.pl DETAIL:  Approximately 4.08% of transaction IDs are
available for use.
2026-07-24 01:32:21.793 UTC client backend[3424568] 002_limits.pl HINT:  To avoid transaction ID assignment failures,
execute a database-wide VACUUM in that database.
    You might also need to commit or roll back old prepared transactions, or drop stale replication slots.
2026-07-24 01:32:21.947 UTC client backend[3424573] 002_limits.pl LOG:  statement: INSERT INTO wraparoundtest VALUES
('after VACUUM')

First INSERT succeeded, but with the WARNING, which didn't satisfy
poll_query_until(). I've reproduced similar failures with extra
autovacuum/vacuum settings, but the reproducer is still too
timing-dependent to share, so maybe this illustration will do:
--- a/src/test/modules/xid_wraparound/t/002_limits.pl
+++ b/src/test/modules/xid_wraparound/t/002_limits.pl
@@ -95,6 +95,10 @@ is($warn_limit, 1, "warn-limit reached");
  # We can still INSERT, despite the warnings.
  $node->safe_psql('postgres',
      qq[INSERT INTO wraparoundtest VALUES ('reached warn-limit')]);
+$ret =
+  $node->poll_query_until('postgres',
+    qq[INSERT INTO wraparoundtest VALUES ('reached warn-limit')],
+    'INSERT 0 1');

PROVE_TESTS="t/002*" PG_TEST_EXTRA="xid_wraparound" PG_TEST_TIMEOUT_DEFAULT=5 make -s check -C
src/test/modules/xid_wraparound/
gives:
t/002_limits.pl .. 1/? # poll_query_until timed out executing this query:
# INSERT INTO wraparoundtest VALUES ('reached warn-limit')
# expecting this output:
# INSERT 0 1
# last actual query output:
# INSERT 0 1
# with stderr:
# WARNING:  database "postgres" must be vacuumed within 97483575 transactions
# DETAIL:  Approximately 4.54% of transaction IDs are available for use.
# HINT:  To avoid transaction ID assignment failures, execute a database-wide VACUUM in that database.
# You might also need to commit or roll back old prepared transactions, or drop stale replication slots.

Probably this can be fixed with (it works for my repro):
$ret =
  $node->poll_query_until('postgres',
    qq[SET client_min_messages='ERROR'; INSERT INTO wraparoundtest VALUES ('after VACUUM')],
    "SET\nINSERT 0 1");

[1]: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=partridge&dt=2026-07-22%2011%3A37%3A59
[2]: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=partridge&dt=2026-07-24%2000%3A00%3A42

Best regards,
Alexander

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alexander Lakhin (#1)
Re: xid_wraparound/002_limits.pl might fail due to transient warning

Alexander Lakhin <exclusion@gmail.com> writes:

Hello hackers,
New buildfarm animal partridge (aarch64, maybe with slow storage)
produced several unprecedented failures of 002_limits, e.g., [1], [2]:

I went looking at this tonight and then found your message. I think
the reason we're not seeing a lot of these in the buildfarm is that
not that many animals are running this test suite (it requires putting
xid_wraparound in PG_TEST_EXTRA). I concur with your conclusion that
poll_query_until is iterating the INSERT an extra time, but I think
a less magic solution would be to just change the test's match rule
to allow that to happen, more or less as attached.

regards, tom lane

Attachments:

t253276_2
stabilize-002_limits-wraparound-test.patchtext/x-diff; charset=us-ascii; name=stabilize-002_limits-wraparound-test.patchDownload+9-3