Re: Bug: Buffer cache is not scan resistant - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Bug: Buffer cache is not scan resistant
Date
Msg-id 22773.1173130599@sss.pgh.pa.us
Whole thread Raw
In response to Re: Bug: Buffer cache is not scan resistant  (Mark Kirkwood <markir@paradise.net.nz>)
Responses Re: Bug: Buffer cache is not scan resistant  (Mark Kirkwood <markir@paradise.net.nz>)
List pgsql-hackers
Mark Kirkwood <markir@paradise.net.nz> writes:
> Tom Lane wrote:
>> Mark, can you detect "hiccups" in the read rate using
>> your setup?

> I think so, here's the vmstat output for 400MB of shared_buffers during
> the scan:

Hm, not really a smoking gun there.  But just for grins, would you try
this patch and see if the numbers change?

            regards, tom lane

*** src/backend/storage/buffer/freelist.c.orig    Fri Jan  5 18:02:12 2007
--- src/backend/storage/buffer/freelist.c    Mon Mar  5 16:33:11 2007
***************
*** 104,116 ****
           * it; decrement the usage_count and keep scanning.
           */
          LockBufHdr(buf);
-         if (buf->refcount == 0 && buf->usage_count == 0)
-             return buf;
          if (buf->usage_count > 0)
          {
              buf->usage_count--;
!             trycounter = NBuffers;
          }
          else if (--trycounter == 0)
          {
              /*
--- 104,116 ----
           * it; decrement the usage_count and keep scanning.
           */
          LockBufHdr(buf);
          if (buf->usage_count > 0)
          {
              buf->usage_count--;
!             trycounter = NBuffers + 1;
          }
+         if (buf->refcount == 0 && buf->usage_count == 0)
+             return buf;
          else if (--trycounter == 0)
          {
              /*

pgsql-hackers by date:

Previous
From: Mark Kirkwood
Date:
Subject: Re: Bug: Buffer cache is not scan resistant
Next
From: Andrew Dunstan
Date:
Subject: Re: proposal: custom variables management