Test publication.sql racing with subscription.sql might fail due to cache lookup error

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Test publication.sql racing with subscription.sql might fail due to cache lookup error
Date: 2026-10-12 20:00:01
Message-ID: c0abc51e-208d-4aaa-8edd-cdf61e1326c4@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello hackers,

Today tamandua emitted a new failure of publication.sql [1]:
# diff -U3 /home/bf/bf-build/tamandua/HEAD/pgsql/src/test/regress/expected/publication.out
/home/bf/bf-build/tamandua/HEAD/pgsql.build/testrun/test_plan_advice/001_replan_regress/data/results/publication.out
# --- /home/bf/bf-build/tamandua/HEAD/pgsql/src/test/regress/expected/publication.out 2026-09-26 17:11:33.701652728 +0200
# +++
/home/bf/bf-build/tamandua/HEAD/pgsql.build/testrun/test_plan_advice/001_replan_regress/data/results/publication.out
2026-10-12 11:50:53.473655771 +0200
# @@ -1349,31 +1349,31 @@
#  DETAIL:  Column lists cannot be specified in publications containing FOR TABLES IN SCHEMA elements.
#  -- ok - only publish schema
#  CREATE PUBLICATION testpub_tbl9 FOR TABLES IN SCHEMA public;
# +ERROR:  cache lookup failed for relation 36073
#  -- failure - add a table with column list when there is already a schema in the
#  -- publication

postmaster.log contains:
2026-10-12 11:50:51.429 CEST [418046][client backend][98/742:0] LOG:  statement: CREATE PUBLICATION testpub_tbl9 FOR
TABLES IN SCHEMA public;
2026-10-12 11:50:51.432 CEST [418061][client backend][99/395:0] LOG:  statement: DROP TABLE public.test_move;
2026-10-12 11:50:51.436 CEST [418061][client backend][99/396:0] LOG:  statement: SET client_min_messages = WARNING;
2026-10-12 11:50:51.441 CEST [418046][client backend][98/742:14613] ERROR:  cache lookup failed for relation 36073
2026-10-12 11:50:51.441 CEST [418046][client backend][98/742:14613] STATEMENT:  CREATE PUBLICATION testpub_tbl9 FOR
TABLES IN SCHEMA public;

I've reproduced this with an isolated script:
for ((n=1;n<=10;n++)); do
echo "ITERATION $n"

for i in {1..100}; do echo "
CREATE TABLE public.test_move (id int);
DROP TABLE public.test_move;
"; done | psql >psql_sub.log &

for i in {1..100}; do echo "
DROP TABLE IF EXISTS testpub_root;
CREATE TABLE testpub_root(a int) PARTITION BY RANGE(a);
CREATE TABLE testpub_part1 PARTITION OF testpub_root FOR VALUES FROM (0) TO (100);

CREATE PUBLICATION testpub_tbl9 FOR TABLES IN SCHEMA public;
DROP PUBLICATION testpub_tbl9;
"; done | psql -v ON_ERROR_STOP=1 >psql_pub.log || break
wait
done
wait
grep -A1 'ERROR:  cache lookup failed' server.log

It fails for me as below:
ITERATION 1
NOTICE:  table "testpub_root" does not exist, skipping
ERROR:  cache lookup failed for relation 16880
2026-10-12 15:21:47.421 EDT|u2|regression|6acd334b.34270f|ERROR: cache lookup failed for relation 16880
2026-10-12 15:21:47.421 EDT|u2|regression|6acd334b.34270f|STATEMENT:  CREATE PUBLICATION testpub_tbl9 FOR TABLES IN
SCHEMA public;
or
...
ITERATION 2
ERROR:  cache lookup failed for relation 17514
2026-10-12 15:21:05.597 EDT|u2|regression|6acd3321.3426de|ERROR: cache lookup failed for relation 17514
2026-10-12 15:21:05.597 EDT|u2|regression|6acd3321.3426de|STATEMENT:  DROP PUBLICATION testpub_tbl9;

Reproduced starting from 5a2832465 (with slightly different syntax).

The manipulations with public.test_move (actually, DROP matters here) were
added by a5918fdd on 2026-07-02, so it took only 3 months to hit this.

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=tamandua&dt=2026-10-12%2009%3A46%3A05

Best regards,
Alexander

Browse pgsql-hackers by date

  From Date Subject
Next Message Dhruv Aron 2026-10-12 20:01:50 Re: Restructured Shared Buffer Hash Table
Previous Message Tomas Vondra 2026-10-12 19:38:55 Re: index prefetching