Re: race condition in pg_class - Mailing list pgsql-hackers

From Alexander Lakhin
Subject Re: race condition in pg_class
Date
Msg-id 9f7cc148-55d1-4062-8229-b6886d7aa380@gmail.com
Whole thread Raw
In response to Re: race condition in pg_class  (Alexander Lakhin <exclusion@gmail.com>)
Responses Re: race condition in pg_class
List pgsql-hackers
Hello Noah,

20.07.2024 11:00, Alexander Lakhin wrote:
>
> 28.06.2024 08:13, Noah Misch wrote:
>> Pushed.
>
> A recent buildfarm test failure [1] showed that the
> intra-grant-inplace-db.spec test added with 0844b3968 may fail
> on a slow machine (per my understanding):

Could you please look at one more interesting failure produced by
001_pgbench_with_server.pl [1]?
regress_log_001_pgbench_with_server:
[13:11:27.325](0.001s) ok 3 - concurrent OID generation stderr /(?^:^$)/
# Running: pgbench ...
[13:11:29.481](2.156s) not ok 4 - concurrent GRANT/VACUUM status (got 2 vs expected 0) # TODO PROC_IN_VACUUM scan
breakage
[13:11:29.483](0.002s) #   Failed (TODO) test 'concurrent GRANT/VACUUM status (got 2 vs expected 0)'
#   at C:/tools/xmsys64/home/pgrunner/bf/root/REL_18_STABLE/pgsql/src/bin/pgbench/t/001_pgbench_with_server.pl line
77.
[13:11:29.484](0.001s) not ok 5 - concurrent GRANT/VACUUM stdout /(?^:processed: 250/250)/ # TODO PROC_IN_VACUUM scan 
breakage
[13:11:29.485](0.001s) #   Failed (TODO) test 'concurrent GRANT/VACUUM stdout /(?^:processed: 250/250)/'
...
[13:11:29.486](0.001s) not ok 6 - concurrent GRANT/VACUUM stderr /(?^:^$)/ # TODO PROC_IN_VACUUM scan breakage
[13:11:29.486](0.000s) #   Failed (TODO) test 'concurrent GRANT/VACUUM stderr /(?^:^$)/'
#   at C:/tools/xmsys64/home/pgrunner/bf/root/REL_18_STABLE/pgsql/src/bin/pgbench/t/001_pgbench_with_server.pl line
77.
[13:11:29.487](0.001s) #                   'pgbench: error: client 1 script 1 aborted in command 0 query 0: ERROR:  
relation 266643 deleted while still in use
# pgbench: error: Run was aborted; the above results are incomplete.
# '
#     doesn't match '(?^:^$)'

001_pgbench_with_server_main.log contains:
2026-02-12 13:11:28.603 UTC [6012:36] 001_pgbench_with_server.pl ERROR:  relation 266643 deleted while still in use
2026-02-12 13:11:28.603 UTC [6012:37] 001_pgbench_with_server.pl STATEMENT:  VACUUM ddl_target;

I'm able to reproduce this error with:
numcouples=40
for ((j=1;j<=numcouples;j++)); do
createdb db$j
echo "CREATE TABLE t(i int);" | psql -d db$j
done

for ((i=1;i<=1000;i++)); do
   echo "iteration $i"
   for ((j=1;j<=numcouples;j++)); do
     for ((k=1;k<=100;k++)); do echo "GRANT SELECT ON t TO public /* $k */;"; done | psql -d db$j >psql-grant-$j.log
2>&1&
 
     for ((k=1;k<=10;k++)); do echo "VACUUM t /* $k */;"; done | psql -d db$j >psql-vacuum-$j.log 2>&1 &
   done
   wait
   grep -E 'ERROR: ' server.log && break;
done

This fails for me as below:
...
iteration 47
2026-02-16 07:13:14.855 EET|law|db13|6992a76a.a6983|ERROR:  relation 16434 deleted while still in use

...
iteration 6
2026-02-16 07:13:42.537 EET|law|db20|6992a786.ab3bc|ERROR:  pg_class entry for relid 16462 vanished during vacuuming

...
iteration 7
2026-02-16 07:14:01.182 EET|law|db2|6992a799.ad54f|ERROR:  could not open relation with OID 16390

...
iteration 9
2026-02-16 07:14:26.160 EET|law|db12|6992a7b2.aedf8|ERROR:  relation 16430 deleted while still in use
...

[1]
https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=fairywren&dt=2026-02-12%2012%3A17%3A56&stg=pgbench-check

Best regards,
Alexander



pgsql-hackers by date:

Previous
From: vignesh C
Date:
Subject: Re: pgstat include expansion
Next
From: "David G. Johnston"
Date:
Subject: Re: Skipping schema changes in publication