Thread: Why is RegisterPredicateLockingXid called while holding XidGenLock?
Inquiring minds want to know ... This seems like a pretty lousy place to do it, first because of the contention hit from holding that high-traffic lock any longer than necessary, and second because every added chance for error between ExtendCLOG() and TransactionIdAdvance(ShmemVariableCache->nextXid) gives us another way to fail in the way recently mentioned by Joe Conway: http://archives.postgresql.org/message-id/4DBE4E7D.80501@joeconway.com Even if it's actually necessary to set up that data structure while holding XidGenLock, I would *really* like the call to not be exactly where it is. regards, tom lane
On Thu, May 05, 2011 at 11:12:40PM -0400, Tom Lane wrote: > Even if it's actually necessary to set up that data structure while > holding XidGenLock, I would *really* like the call to not be exactly > where it is. Good question. I don't believe it needs to be while XidGenLock is being held at all; certainly not in this particular place. All that really matters is that it happens before any backend starts seeing said xid in tuple headers. I believe the call can be moved over to AssignTransactionId. I'd probably put it at the end of that function, but it can go anywhere between there and where it is now. Do you have any preference? Dan -- Dan R. K. Ports MIT CSAIL http://drkp.net/
Dan Ports <drkp@csail.mit.edu> writes: > On Thu, May 05, 2011 at 11:12:40PM -0400, Tom Lane wrote: >> Even if it's actually necessary to set up that data structure while >> holding XidGenLock, I would *really* like the call to not be exactly >> where it is. > Good question. > I don't believe it needs to be while XidGenLock is being held at all; > certainly not in this particular place. All that really matters is that > it happens before any backend starts seeing said xid in tuple headers. > I believe the call can be moved over to AssignTransactionId. I'd > probably put it at the end of that function, but it can go anywhere > between there and where it is now. Do you have any preference? Yeah, I was thinking that it'd be better to pull it out of GetNewTransactionId and put it in a higher level. No strong preference about where in AssignTransactionId to put it. Is there any chance that it would be significant whether we do it before or after taking the lock on the XID (XactLockTableInsert)? regards, tom lane