Re: [HACKERS] Re: ERROR: out of free buffers: time to abort ! - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Re: ERROR: out of free buffers: time to abort !
Date
Msg-id 9208.947372235@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Re: ERROR: out of free buffers: time to abort !  (Ed Loehr <eloehr@austin.rr.com>)
List pgsql-hackers
Ed Loehr <eloehr@austin.rr.com> writes:
> Tom Lane wrote:
>> Yes, a postmaster restart would clean up the buffer reference counts.
>> I think there were also some less drastic code paths that would clean
>> them up --- you might try something as simple as deliberately inducing
>> an SQL error now and then, so that error cleanup runs.

> What *kind* of SQL error would trigger the cleanup?

Actually, on looking at the code it doesn't seem that error recovery
will fix things --- nothing short of a postmaster restart will do it.

Instead of hacking up your application code to work around this problem,
why don't you try applying the following patch to the 6.5.3 sources.
You may get some "Buffer Leak" notice messages, but it ought to work
better than it does now.  (I think --- this is off-the-cuff and not
tested ... but the complete changes that I put into current sources are
much too large to risk back-patching.)

Keep us posted.
        regards, tom lane

*** src/backend/storage/buffer/bufmgr.c~    Sat Jan  8 17:44:58 2000
--- src/backend/storage/buffer/bufmgr.c    Sat Jan  8 17:49:15 2000
***************
*** 1202,1213 ****     for (i = 1; i <= NBuffers; i++)     {         CommitInfoNeedsSave[i - 1] = 0;         if
(BufferIsValid(i))        {             while (PrivateRefCount[i - 1] > 0)                 ReleaseBuffer(i);         }
 
-         LastRefCount[i - 1] = 0;     }      ResetLocalBufferPool();
--- 1202,1218 ----     for (i = 1; i <= NBuffers; i++)     {         CommitInfoNeedsSave[i - 1] = 0;
+         /*
+          * quick hack: any refcount still being held in LastRefCount
+          * needs to be released.
+          */
+         PrivateRefCount[i - 1] += LastRefCount[i - 1];
+         LastRefCount[i - 1] = 0;         if (BufferIsValid(i))         {             while (PrivateRefCount[i - 1] >
0)                ReleaseBuffer(i);         }     }      ResetLocalBufferPool();
 
***************
*** 1228,1233 ****
--- 1233,1244 ----      for (i = 1; i <= NBuffers; i++)     {
+         /*
+          * quick hack: any refcount still being held in LastRefCount
+          * needs to be released.
+          */
+         PrivateRefCount[i - 1] += LastRefCount[i - 1];
+         LastRefCount[i - 1] = 0;         if (BufferIsValid(i))         {             BufferDesc *buf =
&(BufferDescriptors[i- 1]);
 


pgsql-hackers by date:

Previous
From: The Hermit Hacker
Date:
Subject: Re: [HACKERS] LIBPQ patches ...
Next
From: Alfred Perlstein
Date:
Subject: Re: [HACKERS] LIBPQ patches ...