LocalTransactionId vs txid_current - Mailing list pgsql-general

From Luca Ferrari
Subject LocalTransactionId vs txid_current
Date
Msg-id CAKoxK+5eMWse5igGGzZpSUkCGx_ZDhwT7GmTuouYdWxJt6w+eA@mail.gmail.com
Whole thread Raw
Responses Re: LocalTransactionId vs txid_current
List 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



pgsql-general by date:

Previous
From: Vikas Sharma
Date:
Subject: PGPool version 4.0.6-1
Next
From: stan
Date:
Subject: Re: A very puzzling backup/restore problem