diff options
author | Robert Haas <rhaas@postgresql.org> | 2013-06-06 10:03:37 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2013-06-06 10:21:47 -0400 |
commit | a6370fd9ed3dbad6070b789eae916d6a037e4773 (patch) | |
tree | 132fb8655a6aa0a5a31dd36347103a9e5fecc338 | |
parent | e2c84bc9f5f1f2f9570c882d10c2cbdf6fe9e47d (diff) | |
download | postgresql-a6370fd9ed3dbad6070b789eae916d6a037e4773.tar.gz postgresql-a6370fd9ed3dbad6070b789eae916d6a037e4773.zip |
Ensure that XLOG_HEAP2_VISIBLE always targets an initialized page.
Andres Freund
-rw-r--r-- | src/backend/commands/vacuumlazy.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 7e46f9e9343..078b822059c 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -663,6 +663,24 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, /* empty pages are always all-visible */ if (!PageIsAllVisible(page)) { + /* + * It's possible that another backend has extended the heap, + * initialized the page, and then failed to WAL-log the page + * due to an ERROR. Since heap extension is not WAL-logged, + * recovery might try to replay our record setting the + * page all-visible and find that the page isn't initialized, + * which will cause a PANIC. To prevent that, check whether + * the page has been previously WAL-logged, and if not, do that + * now. + * + * XXX: It would be nice to use a logging method supporting + * standard buffers here since log_newpage_buffer() will write + * the full block instead of omitting the hole. + */ + if (RelationNeedsWAL(onerel) && + PageGetLSN(page) == InvalidXLogRecPtr) + log_newpage_buffer(buf); + PageSetAllVisible(page); MarkBufferDirty(buf); visibilitymap_set(onerel, blkno, buf, InvalidXLogRecPtr, |