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