From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | kyzevan23(at)mail(dot)ru |
Subject: | BUG #18212: Functions txid_status() and pg_xact_status() return invalid status of the specified transaction |
Date: | 2023-11-24 06:28:26 |
Message-ID: | 18212-547307f8adf57262@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 18212
Logged by: Egor Chindyaskin
Email address: kyzevan23(at)mail(dot)ru
PostgreSQL version: 16.1
Operating system: Ubuntu 23.10
Description:
Hello! Recently, Me and Andrew Bille came across a situation where the
txid_status() and pg_xact_status() functions return invalid status of the
specified transaction if xid is very far ahead.
The following script reproduces the situation:
# This script uses pg_resetwal and dd. This is a hack to move xid far
ahead
PGDATA=/tmp/pgsql/data
killall postgres
rm -rf $PGDATA
initdb -U postgres -k -D $PGDATA
pg_ctl -D $PGDATA -l log start
psql -U postgres -c "UPDATE pg_database SET datallowconn = 't' WHERE datname
= 'template0';"
pg_ctl -D $PGDATA -l log stop
pg_resetwal -x 536870911 -l 000000010000000000000004 $PGDATA
dd if=/dev/zero of=$PGDATA/pg_xact/01FF bs=8192 count=2048
pg_ctl -D $PGDATA -l log start
vacuumdb --all -U postgres
pg_ctl -D $PGDATA -l log stop
pg_resetwal -x 1073741822 -l 000000010000000000000004 $PGDATA
dd if=/dev/zero of=$PGDATA/pg_xact/03FF bs=8192 count=2048
pg_ctl -D $PGDATA -l log start
vacuumdb --all -U postgres
pg_ctl -D $PGDATA -l log stop
pg_resetwal -x 1610612733 -l 000000010000000000000004 $PGDATA
dd if=/dev/zero of=$PGDATA/pg_xact/05FF bs=8192 count=2048
pg_ctl -D $PGDATA -l log start
vacuumdb --all -U postgres
pg_ctl -D $PGDATA -l log stop
pg_resetwal -x 2147484382 -l 000000010000000000000004 $PGDATA
dd if=/dev/zero of=$PGDATA/pg_xact/0800 bs=8192 count=2048
pg_ctl -D $PGDATA -l log start
vacuumdb --all -U postgres
psql -U postgres -c "SELECT txid_current()"
psql -U postgres -c "SELECT txid_status(3)" -c "SELECT
pg_xact_status('3'::xid8)"
As a result, we get that, instead of the expected NULL, the functions return
the "in progress" status of transaction 3, which is far in the past:
...
txid_current
--------------
2147484382
(1 row)
txid_status
-------------
in progress
(1 row)
pg_xact_status
----------------
in progress
(1 row)
---
Best regards,
Egor Chindyaskin
Postgres Professional: http://postgrespro.com
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2023-11-24 08:35:08 | BUG #18213: Standby's repeatable read isolation level transaction encountered a "nonrepeatable read" problem |
Previous Message | Alexander Lakhin | 2023-11-24 04:00:01 | Re: BUG #17828: postgres_fdw leaks file descriptors on error and aborts aborted transaction in lack of fds |