repro.txt

text/plain

Filename: repro.txt
Type: text/plain
Part: 0
Message: False "pg_serial": apparent wraparound” in logs
### create the pgbench script
echo "\set idv random(1, 10000)" > /tmp/pgbench.sql
echo "BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;" >> /tmp/pgbench.sql
echo "UPDATE tab1 SET id2 = id2 WHERE id = :idv;" >> /tmp/pgbench.sql
echo "COMMIT;" >> /tmp/pgbench.sql

### create the driver script
cat <<EOT > /tmp/repro.sh
psql<<EOF
begin transaction isolation level serializable;
select count(*) from tab1;
-- start a pgbench in the background
\! nohup pgbench -c90 -f/tmp/pgbench.sql -T 120 &
select pg_sleep(100);
COMMIT;
CHECKPOINT;
select pg_sleep(30);
EOF
EOT

chmod a+x /tmp/repro.sh


### create the table
psql<<EOF
drop table if exists tab1;
create table tab1 (id int primary key, id2 int);
insert into tab1 select n, 0 from generate_series(1, 10000) as n;
EOF

### run the repro
/tmp/repro.sh

### afterwards, cat the logfile
....
2023-08-23 00:28:43.499 UTC [2372685] LOG:  could not truncate directory "pg_serial": apparent wraparound
...