Re: Lazy xid assignment V3

From: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, "PostgreSQL-patches" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Lazy xid assignment V3
Date: 2007-09-03 17:52:07
Message-ID: 46DC49C7.4090003@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> "Florian G. Pflug" <fgp(at)phlo(dot)org> writes:
>> Tom Lane wrote:
>>> "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com> writes:
>>>> Should there be new a log_line_prefix percent code for virtual
>>>> transaction ids? Or should we change the meaning of %x to be virtual
>>>> transaction id instead of the real one.
>>> I think the latter should be sufficient, especially if we also are showing
>>> vxid in pg_locks and pg_stat_activity.
>
>> Hm.. Wouldn't that kind of defeat the idea of a log, if you need the
>> output of pg_locks to interpret it? Maybe we should just show both
>> values for %x? Or just the xid if it's set, and the vid otherwise?
>
> Well, how do you interpret xid in the log today, if not by reference
> to those views? The last option seems quite unworkable, especially
> for CSV-based logs.

I don't think people usually interpret the xid in logs in any way. It's
just a handy unique (unique enough, ignoring xid wraparound) identifier
for the transaction that you can use to figure out what each separate
transaction is doing. For that purpose, it doesn't matter if it doesn't
match the normal on-disk xid, using vid instead of xid works just fine.

Hmm. Or is it unique enough after all? Do we reuse session ids after a
server restart?

For debugging PostgreSQL bugs, though, having the real xid in the logs
is really nice. You can then compare the logs against the tuples on the
disk.

>> Even in the case of a conflict, two transactions still wouldn't be
>> running with the same vid. Rather, the second one would block until
>> the first exits, because we hold an ExclusiveLock on the vid.
>
> It's definitely sufficient then ...

Yeah. If we did want to do something more, we could acquire the lock on
vid conditionally, and use another vid if acquiring the lock fails. But
I don't think it's necessary.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Florian G. Pflug 2007-09-03 18:05:22 Re: Lazy xid assignment V3
Previous Message Florian G. Pflug 2007-09-03 17:15:11 Re: Lazy xid assignment V3