Alvaro Herrera wrote: > Excerpts from Bruce Momjian's message of vie abr 01 16:50:29 -0300 2011: > > > To do the right thing every computation that passes over the xid > > wraparound bounary should subtract FirstNormalTransactionId, not just > > those that fall in the boundry. That would prevent the value from going > > backward and still allow the mapping you liked; it isn't worth it, but > > that is the right answer. > > This code is only concerned calculating an immediate the wrap horizon > for the autovacuuming run that's about to take place. If it's wrong in > one or three counts doesn't mean much. Consider what would happen if > load was high and it would have taken 100 extra milliseconds to get to > that bit: ReadNewTransactionId would have returned a value 3 > transactions later. Furthermore, before this value is even used at all > for vacuuming, there has to be a whole lot of inter-process signalling, > a fork, and a new backend startup. > > I think this should be left alone. As you said, it isn't worth it.
Agreed it is not worth it but I think we should at least C comment something. I think at a minimum we should set it to FirstNormalTransactionId. I am not so concerned about this case but about other cases where we are computing xid distances across the invalid range. -- Bruce Momjian <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c new file mode 100644 index efc8e7c..244930f *** a/src/backend/postmaster/autovacuum.c --- b/src/backend/postmaster/autovacuum.c *************** do_start_worker(void) *** 1107,1114 **** */ recentXid = ReadNewTransactionId(); xidForceLimit = recentXid - autovacuum_freeze_max_age; ! /* ensure it's a "normal" XID, else TransactionIdPrecedes misbehaves */ ! if (xidForceLimit < FirstNormalTransactionId) xidForceLimit -= FirstNormalTransactionId; /* --- 1107,1120 ---- */ recentXid = ReadNewTransactionId(); xidForceLimit = recentXid - autovacuum_freeze_max_age; ! /* ! * Adjust for xids in the invalid range, less than FirstNormalTransactionId. ! * We map the xids as though the invalid range did not exist. ! * We cannot simplify the test below because of underflow ! * issues with unsigned values. ! */ ! if (xidForceLimit < FirstNormalTransactionId || /* in invalid range? */ ! recentXid < autovacuum_freeze_max_age) /* did we underflow? */ xidForceLimit -= FirstNormalTransactionId; /*
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers