1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-15 03:41:20 +03:00

Avoid early reuse of btree pages, causing incorrect query results.

When we allowed read-only transactions to skip assigning XIDs
we introduced the possibility that a fully deleted btree page
could be reused. This broke the index link sequence which could
then lead to indexscans silently returning fewer rows than would
have been correct. The actual incidence of silent errors from
this is thought to be very low because of the exact workload
required and locking pre-conditions. Fix is to remove pages only
if index page opaque->btpo.xact precedes RecentGlobalXmin.

Noah Misch, reviewed by Simon Riggs
This commit is contained in:
Simon Riggs
2012-06-01 12:21:45 +01:00
parent 3e4d3a32b2
commit d3abbbebe5
3 changed files with 20 additions and 26 deletions

View File

@@ -968,7 +968,11 @@ btree_redo(XLogRecPtr lsn, XLogRecord *record)
/*
* Btree reuse page records exist to provide a conflict point
* when we reuse pages in the index via the FSM. That's all it
* does though.
* does though. latestRemovedXid was the page's btpo.xact. The
* btpo.xact < RecentGlobalXmin test in _bt_page_recyclable()
* conceptually mirrors the pgxact->xmin > limitXmin test in
* GetConflictingVirtualXIDs(). Consequently, one XID value
* achieves the same exclusion effect on master and standby.
*/
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) XLogRecGetData(record);