Skip to content

Commit 96675bf

Browse files
committed
Fix bug in the WAL recovery code to finish an incomplete split.
CacheInvalidateRelcache() crashes if called in WAL recovery, because the invalidation infrastructure hasn't been initialized yet. Back-patch to 8.2, where the bug was introduced.
1 parent 109940c commit 96675bf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backend/access/nbtree/nbtinsert.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.166 2008/05/12 00:00:45 alvherre Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.167 2008/06/11 08:38:56 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -747,7 +747,8 @@ _bt_insertonpg(Relation rel,
747747
/* release buffers; send out relcache inval if metapage changed */
748748
if (BufferIsValid(metabuf))
749749
{
750-
CacheInvalidateRelcache(rel);
750+
if (!InRecovery)
751+
CacheInvalidateRelcache(rel);
751752
_bt_relbuf(rel, metabuf);
752753
}
753754

@@ -1792,7 +1793,8 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
17921793
END_CRIT_SECTION();
17931794

17941795
/* send out relcache inval for metapage change */
1795-
CacheInvalidateRelcache(rel);
1796+
if (!InRecovery)
1797+
CacheInvalidateRelcache(rel);
17961798

17971799
/* done with metapage */
17981800
_bt_relbuf(rel, metabuf);

0 commit comments

Comments
 (0)