aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/buffer/localbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/buffer/localbuf.c')
-rw-r--r--src/backend/storage/buffer/localbuf.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c
index b8715b54651..4efb34b75a1 100644
--- a/src/backend/storage/buffer/localbuf.c
+++ b/src/backend/storage/buffer/localbuf.c
@@ -21,9 +21,10 @@
#include "pgstat.h"
#include "storage/buf_internals.h"
#include "storage/bufmgr.h"
+#include "storage/fd.h"
#include "utils/guc_hooks.h"
#include "utils/memutils.h"
-#include "utils/resowner_private.h"
+#include "utils/resowner.h"
/*#define LBDEBUG*/
@@ -130,7 +131,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum,
if (LocalBufHash == NULL)
InitLocalBuffers();
- ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
+ ResourceOwnerEnlarge(CurrentResourceOwner);
/* See if the desired buffer already exists */
hresult = (LocalBufferLookupEnt *)
@@ -182,7 +183,7 @@ GetLocalVictimBuffer(void)
uint32 buf_state;
BufferDesc *bufHdr;
- ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
+ ResourceOwnerEnlarge(CurrentResourceOwner);
/*
* Need to get a new buffer. We use a clock sweep algorithm (essentially
@@ -675,13 +676,19 @@ PinLocalBuffer(BufferDesc *buf_hdr, bool adjust_usagecount)
void
UnpinLocalBuffer(Buffer buffer)
{
+ UnpinLocalBufferNoOwner(buffer);
+ ResourceOwnerForgetBuffer(CurrentResourceOwner, buffer);
+}
+
+void
+UnpinLocalBufferNoOwner(Buffer buffer)
+{
int buffid = -buffer - 1;
Assert(BufferIsLocal(buffer));
Assert(LocalRefCount[buffid] > 0);
Assert(NLocalPinnedBuffers > 0);
- ResourceOwnerForgetBuffer(CurrentResourceOwner, buffer);
if (--LocalRefCount[buffid] == 0)
NLocalPinnedBuffers--;
}
@@ -785,8 +792,12 @@ CheckForLocalBufferLeaks(void)
if (LocalRefCount[i] != 0)
{
Buffer b = -i - 1;
+ char *s;
+
+ s = DebugPrintBufferRefcount(b);
+ elog(WARNING, "local buffer refcount leak: %s", s);
+ pfree(s);
- PrintBufferLeakWarning(b);
RefCountErrors++;
}
}