fix_bt_getbuf_newpage_crash.patch

text/x-patch

Filename: fix_bt_getbuf_newpage_crash.patch
Type: text/x-patch
Part: 0
Message: Re: [HACKERS] Possibly too stringent Assert() in b-tree code

Patch

Format: unified
File+
src/backend/access/nbtree/nbtpage.c 5 2
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index a24e64156a..b39634cafd 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -782,9 +782,12 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access)
 					/*
 					 * If we are generating WAL for Hot Standby then create a
 					 * WAL record that will allow us to conflict with queries
-					 * running on standby.
+					 * running on standby. No need to do that if the page is
+					 * all-zoeroed since no one cannot be interested in the
+					 * page on standbys. See _bt_page_recyclable().
 					 */
-					if (XLogStandbyInfoActive() && RelationNeedsWAL(rel))
+					if (XLogStandbyInfoActive() && RelationNeedsWAL(rel) &&
+						!PageIsNew())
 					{
 						BTPageOpaque opaque = (BTPageOpaque) PageGetSpecialPointer(page);