Peter Geoghegan wrote: > As you know, on version 9.4+, as of commit 37484ad2a, we decided that > we are "largely ignoring the value to which it [xmin] is set". The > expectation became that raw xmin is available after freezing, but > mostly for forensic purposes. I think Alvaro should now memorialize > the idea that its value is actually critical in some place > (htup_details.h?).
I'd love to be certain that we preserve the original value in all cases. > On Wed, Oct 4, 2017 at 6:46 AM, Alvaro Herrera <alvhe...@alvh.no-ip.org> > wrote: > > I independently arrived at the same conclusion. Since I was trying with > > 9.3, the patch differs -- in the old version we must explicitely test > > for the FrozenTransactionId value, instead of using GetRawXmin. > > Obviously you're going to have to be prepared for a raw xmin of > FrozenTransactionId, even on 9.4+, due to pg_upgrade. Hmm. It would be good to be able to get rid of that case, actually, because I now think it's less safe (see below). At any rate, I was thinking in a new routine to encapsulate the logic, /* * Check the tuple XMIN against prior XMAX, if any */ if (!HeapTupleUpdateXmaxMatchesXmin(priorXmax, HeapTupleHeaderGetXmin(htup))) break; where ..XmaxMatchesXmin would know about checking for possibly frozen tuples. > I can see why it > would be safe (or at least no more dangerous) to rely on > HeapTupleHeaderGetRawXmin() in the way mentioned here, at least on > installations that initdb'd on a version after commit 37484ad2a > (version 9.4+). However, I'm not sure why what you propose here would > be safe when even raw xmin happens to be FrozenTransactionId. Are you > sure that that's truly race-free? If it's really true that we only > need to check for FrozenTransactionId on 9.3, why not just do that on > all versions, and never bother with HeapTupleHeaderGetRawXmin()? > ("Sheer paranoia" is a valid answer; I just want us to be clear on the > reasoning.) I think the RawXmin is the better mechanism. I'm not absolutely certain that the windows is completely closed in 9.3; as I understand things, it is possible for transaction A to prune an aborted heap-only tuple, then transaction B to insert a frozen tuple in the same location, then transaction C follows a link to the HOT that was pruned. I think we'd end up considering that the new frozen tuple is part of the chain, which is wrong ... In 9.4 we can compare the real xmin. I hope I am proved wrong about this, because if not, I think we're looking at an essentially unsolvable problem in 9.3. > Obviously any race would have a ridiculously tiny window, but it's not > obvious why this protocol would be completely race-free (in the event > of a FrozenTransactionId raw xmin). As far as I understand, this problem only emerges if one part of a HOT chain reaches the min freeze age while another part of the same chain is still visible by some running transaction. It is particularly noticeably in our current test case because we use a min freeze age of 0, with many concurrrent modifying the same page. What this says to me is that VACUUM FREEZE is mildly dangerous when there's lots of high concurrent HOT UPDATE activity. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (firstname.lastname@example.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers