Lazy xid assignment V4

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Lazy xid assignment V4
Date: 2007-09-04 17:22:44
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers pgsql-patches


Here is an updated patch, following the discussion.
The patch can be found at:
(I seems I still can't get attachments through to this list)

Most changes are just small fixes and tweaks. Those are
.) Introduced %v for log_line_prefix
.) I missed a few places when I renamed ResourceOwnerId to
VirtualTransactionId. (In lock.c/.h and lmgr.c/.h +
a few comments). Should be fixed now.
.) Fixed some typos and outdated-ness in comments.

Two changes are a bit larger

1) 2PC was broken in V3. I added code that skips LOCKTYPE_VIRTUALTRANSACTION
locks when writing the locks to the 2PC state file, but I didn't
add the same exception to the code that reassigns the locks to
a dummy PGROC afterwards. So the locks weren't released at PREPARE
time. Fixed now.

2) The more I thought about the sessionId, the less I liked it.
It adds a new per-backend identifier, beside pid and BackendId,
only to than *still* have wraparound issues. That seems a bit

I therefore got rid of the sessionId completely, and replaced it
with MyBackendId. To guarantee that VirtualTransactionIds are
not reused too quickly, I added an array nextLocalTransactionIds
to shared memory, with one entry per backendId. That seems much cleaner -
it doesn't add yet another per-backend identifier, doesn't need
yet another variable initialized at backend start, and solved the
wraparound problem too.

It *does* cost a bit of shared memory, but not much. For
max_backends=2048 the array is as large as *one* shared buffer.

It doesn't need any locking, either, because each backend
only ever touches it's own entry in the array.

Because the backendId part of VirtualTransactionIds is now
always a rather small number (<= MaxBackends), and might
be interesting to know, I changed the string representation to
show the backendId in decimal notation.

greetings, Florian Pflug


Browse pgsql-hackers by date

  From Date Subject
Next Message Pavan Deolasee 2007-09-04 17:37:21 Re: Lazy xid assignment V4
Previous Message Tom Lane 2007-09-04 17:22:01 Re: pg_dump and insert multi-rows option

Browse pgsql-patches by date

  From Date Subject
Next Message Pavan Deolasee 2007-09-04 17:37:21 Re: Lazy xid assignment V4
Previous Message Andrew Dunstan 2007-09-04 16:46:19 Re: [HACKERS] enum types and binary queries