Re: Old row version in hot chain become visible after a freeze
Wong, Yi Wen <yiwong@amazon.com>
From: "Wong, Yi Wen" <yiwong@amazon.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>,
Michael Paquier <michael.paquier@gmail.com>
Cc: 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-12T18:38:02Z
Lists: pgsql-bugs
> > The > > resulting patch, which I like better than the previously proposed idea > > of skipping the freeze, takes the approach of handling freeze correctly > > for the cases where the tuple still exists after pruning. > > That's also something I was wondering when looking at the first patch. > I am unfortunately not as skilled as you are with this area of the > code (this thread has brought its quantity of study!), so I was not > able to draw a clear line with what needs to be done. But I am clearly > +1 with this approach. I have tried out the new patch and it works great as well! +1 from me. > > I also tweaked lazy_record_dead_tuple to fail with ERROR if the tuple > > cannot be recorded, as observed by Yi Wen. AFAICS that's not reachable > > because of the way the array is allocated, so an elog(ERROR) is > > sufficient. I agree the fail is rare (and probably doesn't happen in real cases, although the comment does imply with a sufficiently low working_memory it might?). However, I'd dispute that ERROR is sufficient --PANIC is probably appropriate here because FREEZE is not WAL-logged until the end of the page; so we'd end up with unfrozen Xids hanging around with an appropriately timed crash. I wouldn't worry much about the PANIC tripping because like you said, this seems unreachable normally. The errmsg should come with a errhint saying "Increase maintenance_work_mem". I've done some code inspection to try to figure out if crashing at any point around before FREEZE and the later lazy_vacuum_page phase is safe (i.e. older Xids might be left behind on restart/crash); it seems to me it shouldn't be a problem until new_min_xid and new_min_multi isn't updated until later for the truncate. Yi Wen
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