LocalTransactionId vs txid_current

From: Luca Ferrari <fluca1978(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: LocalTransactionId vs txid_current
Date: 2019-10-24 13:28:14
Message-ID: CAKoxK+5eMWse5igGGzZpSUkCGx_ZDhwT7GmTuouYdWxJt6w+eA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm exploring DTrace, and I thought that LocalTransactionId as
described in <https://www.postgresql.org/docs/12/dynamic-trace.html>
would have a relationship with txid_current(), but apparently I'm not
getting it:

template1=# begin;
template1=# select txid_current();
txid_current
--------------
488
template1=# commit;

but DTrace shows me:

% sudo ./postgresql.d 33381
[TRANSACTION START] 28 postgres (33381) called StartTransaction
[TRANSACTION COMMIT] 28 postgres (33381) called CommitTransaction

with my script being:

{
printf("[TRANSACTION START] %d %s (%d) called %s\n", args[0],
execname, pid, probefunc);
@tx["begin"] = count();
self->tx_ts = timestamp;
}

postgresql$1:::transaction-commit
/self->tx_ts/
{
printf("[TRANSACTION COMMIT] %d %s (%d) called %s\n", args[0],
execname, pid, probefunc);
@tx["commit"] = count();
@tx_secs["commit"] = quantize( ( timestamp - self->tx_ts ) / 1000 );
self->tx_ts = 0;
}

The args[0] is continuously incremented each time a new transaction is
started, even if it is not supposed to get a non-virtual txid:

template1=# begin;
template1=# rollback;

shows:

% sudo ./postgresql.d 33381
[TRANSACTION START] 29 postgres (33381) called StartTransaction

If i restart the server the args[0] starts from 4, that reminds me
about the min xid available.
Any way to get from LocalTransactionId to txid_current (if assigned)?

Thanks,
Luca

Responses

Browse pgsql-general by date

  From Date Subject
Next Message stan 2019-10-24 13:51:21 Re: A very puzzling backup/restore problem
Previous Message Vikas Sharma 2019-10-24 13:10:30 PGPool version 4.0.6-1