Re: Old row version in hot chain become visible after a freeze
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: "Wong, Yi Wen" <yiwong@amazon.com>
Cc: Michael Paquier <michael.paquier@gmail.com>, Peter Geoghegan <pg@bowt.ie>, "Wood, Dan" <hexpert@amazon.com>, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>, Andres Freund <andres@anarazel.de>
Date: 2017-09-28T13:44:00Z
Lists: pgsql-bugs
Wong, Yi Wen wrote: > 2) Flip the order of HeapTupleHeaderIsHeapOnly(tuple) and HeapTupleHeaderIsHotUpdated(tuple). This is merely a > microoptimization on a non-performance critical path because HeapOnly is a broader condititon than HotUpdated :-) Actually, is this correct? AFAICS, IsHeapOnly refers to the *new* version of the tuple in a HOT update, whereas IsHotUpdated refers to the *old* version. We surely must never freeze a IsHotUpdated tuple (because that would bring a dead tuple back to life, which is the bug at hand), but what is the argument against freezing a IsHeapOnly tuple? I think the way this test is written comes from some fuzzy thinking -- somebody (probably me) copied the test from lazy_scan_heap, but that routine has two different reasons for each of those two conditions (one is merely an optimization, the other is necessary for correctness). But in the spot we're patching, one of them is wrong. I could observe that this bug causes xids older than cutoff xid to remain in xmax occasionally with that test in place. Removing the "IsHeapOnly" part and keeping only IsHotUpdated makes that go away. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Fix freezing of a dead HOT-updated tuple
- fb6de78a291b 9.5.10 landed
- d149aa762c05 9.3.20 landed
- 46c35116ae1a 10.0 landed
- 3a135bdb1b5e 9.6.6 landed
- 232c7cbcbbc6 9.4.15 landed
- 20b655224249 11.0 landed
-
Fix potential data corruption during freeze
- 31b8db8e6c1f 10.0 cited
-
Clarify the contract of partition_rbound_cmp().
- f1dae097f294 10.0 cited