pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: kyzevan23@mail.ru
Subject: BUG #18212: Functions txid_status() and pg_xact_status() return invalid status of the specified transaction
Date: Fri, 24 Nov 2023 06:28:26 +0000
Message-ID: <18212-547307f8adf57262@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      18212
Logged by:          Egor Chindyaskin
Email address:      kyzevan23@mail.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



view thread (10+ messages)  latest in thread

Message-ID: <18212-547307f8adf57262@postgresql.org>
Permalink:  ../18212-547307f8adf57262@postgresql.org/
Also on:    postgresql.org/message-id/18212-547307f8adf57262@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, kyzevan23@mail.ru
  Subject: Re: BUG #18212: Functions txid_status() and pg_xact_status() return invalid status of the specified transaction
  In-Reply-To: <18212-547307f8adf57262@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox