pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedLocalTransactionId vs txid_current
2+ messages / 2 participants
[nested] [flat]
* LocalTransactionId vs txid_current
@ 2019-10-24 13:28 Luca Ferrari <fluca1978@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Luca Ferrari @ 2019-10-24 13:28 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: LocalTransactionId vs txid_current
@ 2019-10-24 14:45 Tom Lane <tgl@sss.pgh.pa.us>
parent: Luca Ferrari <fluca1978@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2019-10-24 14:45 UTC (permalink / raw)
To: Luca Ferrari <fluca1978@gmail.com>; +Cc: pgsql-general
Luca Ferrari <fluca1978@gmail.com> writes:
> 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(),
It does not. txid_current returns a globally valid transaction ID,
while local transaction IDs are just taken from a counter within
the session and have no meaning to other sessions.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-10-24 14:45 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24 13:28 LocalTransactionId vs txid_current Luca Ferrari <fluca1978@gmail.com>
2019-10-24 14:45 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox