Re: Segmentation fault in 7.3 while vacuuming

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Frank van Vugt <ftm.van.vugt@foxi.nl>
Cc: Bruce Momjian <pgman@candle.pha.pa.us>, pgsql-general@postgresql.org
Date: 2002-12-05T22:51:48Z
Lists: pgsql-hackers, pgsql-general
I said:
> Frank van Vugt <ftm.van.vugt@foxi.nl> writes:
>> ** while using a client written in TrollTech's QT v3.1 that creates a number
>> of temporary tables, uses a number lot of 'copy' statements and at the end 
>> tries to 'vacuum full analyse' the database

> Drat --- looks like the local buffer manager code has gotten out of sync
> with the relcache code.

Here is the fix if you need to patch this locally.

			regards, tom lane


*** src/backend/storage/buffer/localbuf.c.orig	Wed Sep  4 16:31:25 2002
--- src/backend/storage/buffer/localbuf.c	Thu Dec  5 17:48:10 2002
***************
*** 90,108 ****
  	{
  		Relation	bufrel = RelationNodeCacheGetRelation(bufHdr->tag.rnode);
  
- 		/*
- 		 * The relcache is not supposed to throw away temp rels, so this
- 		 * should always succeed.
- 		 */
- 		Assert(bufrel != NULL);
- 
  		/* flush this page */
! 		smgrwrite(DEFAULT_SMGR, bufrel, bufHdr->tag.blockNum,
! 				  (char *) MAKE_PTR(bufHdr->data));
! 		LocalBufferFlushCount++;
  
! 		/* drop refcount incremented by RelationNodeCacheGetRelation */
! 		RelationDecrementReferenceCount(bufrel);
  	}
  
  	/*
--- 90,113 ----
  	{
  		Relation	bufrel = RelationNodeCacheGetRelation(bufHdr->tag.rnode);
  
  		/* flush this page */
! 		if (bufrel == (Relation) NULL)
! 		{
! 			smgrblindwrt(DEFAULT_SMGR,
! 						 bufHdr->tag.rnode,
! 						 bufHdr->tag.blockNum,
! 						 (char *) MAKE_PTR(bufHdr->data));
! 		}
! 		else
! 		{
! 			smgrwrite(DEFAULT_SMGR, bufrel,
! 					  bufHdr->tag.blockNum,
! 					  (char *) MAKE_PTR(bufHdr->data));
! 			/* drop refcount incremented by RelationNodeCacheGetRelation */
! 			RelationDecrementReferenceCount(bufrel);
! 		}
  
! 		LocalBufferFlushCount++;
  	}
  
  	/*