diff options
| author | Robert Haas <rhaas@postgresql.org> | 2012-04-26 20:00:21 -0400 |
|---|---|---|
| committer | Robert Haas <rhaas@postgresql.org> | 2012-04-26 20:00:21 -0400 |
| commit | 3424bff90f40532527b9cf4f2ad9eaff750682f7 (patch) | |
| tree | 028c10eea2a93f672d9462ebb4dcef7097d316ca /src/backend/commands/vacuumlazy.c | |
| parent | 92df2203437603d40417fe711c3cb7066ac4fdf5 (diff) | |
| download | postgresql-3424bff90f40532527b9cf4f2ad9eaff750682f7.tar.gz | |
Prevent index-only scans from returning wrong answers under Hot Standby.
The alternative of disallowing index-only scans in HS operation was
discussed, but the consensus was that it was better to treat marking
a page all-visible as a recovery conflict for snapshots that could still
fail to see XIDs on that page. We may in the future try to soften this,
so that we simply force index scans to do heap fetches in cases where
this may be an issue, rather than throwing a hard conflict.
Diffstat (limited to 'src/backend/commands/vacuumlazy.c')
| -rw-r--r-- | src/backend/commands/vacuumlazy.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 60171470d3..0e0193d40e 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -448,6 +448,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, bool all_visible_according_to_vm; bool all_visible; bool has_dead_tuples; + TransactionId visibility_cutoff_xid = InvalidTransactionId; if (blkno == next_not_all_visible_block) { @@ -627,7 +628,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, { PageSetAllVisible(page); MarkBufferDirty(buf); - visibilitymap_set(onerel, blkno, InvalidXLogRecPtr, vmbuffer); + visibilitymap_set(onerel, blkno, InvalidXLogRecPtr, vmbuffer, + InvalidTransactionId); } UnlockReleaseBuffer(buf); @@ -759,6 +761,10 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, all_visible = false; break; } + + /* Track newest xmin on page. */ + if (TransactionIdFollows(xmin, visibility_cutoff_xid)) + visibility_cutoff_xid = xmin; } break; case HEAPTUPLE_RECENTLY_DEAD: @@ -853,7 +859,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, PageSetAllVisible(page); MarkBufferDirty(buf); } - visibilitymap_set(onerel, blkno, InvalidXLogRecPtr, vmbuffer); + visibilitymap_set(onerel, blkno, InvalidXLogRecPtr, vmbuffer, + visibility_cutoff_xid); } /* |
