txid_status returns NULL for recently commited transactions

From: Michail Nikolaev <michail(dot)nikolaev(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, dsarafannikov(at)yandex(dot)ru
Subject: txid_status returns NULL for recently commited transactions
Date: 2018-09-25 16:47:40
Message-ID: CANtu0ojcsB3c0g-7dzzh0vPiU77PAxRqtpQXm3P0dY5-3TKQ1A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello everyone.

I see strange beaviour of txid_status with one of my production servers.

SELECT txid_status(txid_current()) -> NULL
SELECT txid_current() -> 4447342811

It also returns null for recent commited and aborted transactions.

SELECT datname, age(datfrozenxid), datfrozenxid FROM pg_database;
template 0239961994 4207340131
postgres 289957756 4157344369 <(415)%20734-4369>
template1 289957661 4157344464 <(415)%20734-4464>
project 682347934 3764954191

GDB shows it happens because of TransactionIdPrecedes(xid,
ShmemVariableCache->oldestClogXid)) at txid.c:155.

xid_epoch = 1
xid = 150227913
now_epoch = 1
now_epoch_last_xid = 150468261
ShmemVariableCache->oldestClogXid = 2207340131 <(220)%20734-0131>

The strangest thing is ShmemVariableCache->oldestClogXid == 2207340131
<(220)%20734-0131> which is greater than current xid without an epoch
(150227913) .

Postgres was updated from 9.6 to PostgreSQL 10.4 (Ubuntu
10.4-2.pgdg14.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu
4.8.4-2ubuntu1~14.04.4) 4.8.4, 64-bit.

Also, another small issue:

On the same database:
SELECT txid_status(BIGINT '4294967295') -> 'commited'.
SELECT txid_status(BIGINT '4294967296') -> NULL

Both tx ids are from my head and not valid.
First 'commited' happends because int32 overflow:
TransactionIdPrecedes(59856482, 2207340131 <(220)%20734-0131>) == false

Could anyone help me with understanding of txid_status behaviour?

Thanks,
Michail.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Don Seiler 2018-09-25 16:47:49 Re: [PATCH] Include application_name in "connection authorized" log message
Previous Message Tom Lane 2018-09-25 16:05:42 Re: Allowing printf("%m") only where it actually works