From b443043d18b5fffeeb15dd3c75b569946465a76d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 7 Jan 2006 22:46:07 +0000 Subject: [PATCH] Add RelationOpenSmgr() calls to ensure rd_smgr is valid when we try to use it. While it normally has been opened earlier during btree index build, testing shows that it's possible for the link to be closed again if an sinval reset occurs while the index is being built. --- src/backend/access/nbtree/nbtsort.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index 01104015118..b4a056a0607 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -56,7 +56,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.90 2004/12/31 21:59:22 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.90.4.1 2006/01/07 22:46:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -273,6 +273,9 @@ _bt_blnewpage(uint32 level) static void _bt_blwritepage(BTWriteState *wstate, Page page, BlockNumber blkno) { + /* Ensure rd_smgr is open (could have been closed by relcache flush!) */ + RelationOpenSmgr(wstate->index); + /* XLOG stuff */ if (wstate->btws_use_wal) { @@ -817,5 +820,8 @@ _bt_load(BTWriteState *wstate, BTSpool *btspool, BTSpool *btspool2) * disk when the crash occurs. */ if (!wstate->index->rd_istemp) + { + RelationOpenSmgr(wstate->index); smgrimmedsync(wstate->index->rd_smgr); + } } -- 2.39.5