Re: 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>
Subject: Re: txid_status returns NULL for recently commited transactions
Date: 2018-09-25 16:52:55
Message-ID: CANtu0ogYgH+3=6pbBhqgYAL9zDWxBNThTKiJ4d1k4DRR8corLA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Sorry, some auto formatting in recent email.

Again wtih fixed formatiing:

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
template1 289957661 4157344464
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

The strangest thing is ShmemVariableCache->oldestClogXid == 2207340131
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) == false

Could anyone help me with understanding of txid_status behaviour?

Thanks,
Michail.

вт, 25 сент. 2018 г. в 19:47, Michail Nikolaev <michail(dot)nikolaev(at)gmail(dot)com>:

> 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.
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-09-25 17:04:58 Re: txid_status returns NULL for recently commited transactions
Previous Message Don Seiler 2018-09-25 16:47:49 Re: [PATCH] Include application_name in "connection authorized" log message