Re: buffer assertion tripping under repeat pgbench load

Greg Smith <greg@2ndquadrant.com>

From: Greg Smith <greg@2ndQuadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@2ndquadrant.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2012-12-23T19:42:05Z
Lists: pgsql-hackers
On 12/23/12 1:10 PM, Tom Lane wrote:

> It might also be interesting to know if there is more than one
> still-pinned buffer --- that is, if you're going to hack the code, fix
> it to elog(LOG) each pinned buffer and then panic after completing the
> loop.


Easy enough; I kept it so the actual source of panic is still an 
assertion failure:

diff --git a/src/backend/storage/buffer/bufmgr.c 
b/src/backend/storage/buffer/bufmgr.c
index dddb6c0..df43643 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -1697,11 +1697,21 @@ AtEOXact_Buffers(bool isCommit)
         if (assert_enabled)
         {
                 int                     i;
+               int                     RefCountErrors = 0;

                 for (i = 0; i < NBuffers; i++)
                 {
-                       Assert(PrivateRefCount[i] == 0);
+
+                       if (PrivateRefCount[i] != 0)
+                       {
+                               BufferDesc *bufHdr = &BufferDescriptors[i];
+                               elog(LOG, "refcount of %s is %u should 
be 0, globally: %u",
+                                    relpathbackend(bufHdr->tag.rnode, 
InvalidBackendId, bufHdr->tag.forkNum),
+                                    PrivateRefCount[i], bufHdr->refcount);
+                               RefCountErrors++;
+                       }
                 }
+               Assert(RefCountErrors == 0);
         }
  #endif


Commits

  1. Follow TLI of last replayed record, not recovery target TLI, in walsenders.

  2. Avoid holding vmbuffer pin after VACUUM.