diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 739daa1153..de4c617b0e 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -4424,21 +4424,24 @@ void PrintBufferDescs(void) { int i; + uint32 buf_state; for (i = 0; i < NBuffers; ++i) { BufferDesc *buf = GetBufferDescriptor(i); Buffer b = BufferDescriptorGetBuffer(buf); - /* theoretically we should lock the bufhdr here */ + buf_state = LockBufHdr(buf); elog(LOG, "[%02d] (freeNext=%d, rel=%s, " - "blockNum=%u, flags=0x%x, refcount=%u %d)", + "blockNum=%u, refcount=%u %d)", i, buf->freeNext, relpathbackend(BufTagGetRelFileLocator(&buf->tag), INVALID_PROC_NUMBER, BufTagGetForkNum(&buf->tag)), - buf->tag.blockNum, buf->flags, - buf->refcount, GetPrivateRefCount(b)); + buf->tag.blockNum, + BUF_STATE_GET_REFCOUNT(buf_state), GetPrivateRefCount(b)); + + UnlockBufHdr(buf, buf_state); } } #endif @@ -4448,6 +4451,7 @@ void PrintPinnedBufs(void) { int i; + uint32 buf_state; for (i = 0; i < NBuffers; ++i) { @@ -4456,15 +4460,17 @@ PrintPinnedBufs(void) if (GetPrivateRefCount(b) > 0) { - /* theoretically we should lock the bufhdr here */ + buf_state = LockBufHdr(buf); elog(LOG, "[%02d] (freeNext=%d, rel=%s, " - "blockNum=%u, flags=0x%x, refcount=%u %d)", + "blockNum=%u, refcount=%u %d)", i, buf->freeNext, relpathperm(BufTagGetRelFileLocator(&buf->tag), BufTagGetForkNum(&buf->tag)), - buf->tag.blockNum, buf->flags, - buf->refcount, GetPrivateRefCount(b)); + buf->tag.blockNum, + BUF_STATE_GET_REFCOUNT(buf_state), GetPrivateRefCount(b)); + + UnlockBufHdr(buf, buf_state); } } } diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 3fdd29bd0b..9e1ae5682e 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -278,6 +278,7 @@ extern XLogRecPtr BufferGetLSNAtomic(Buffer buffer); #ifdef NOT_USED extern void PrintPinnedBufs(void); +extern void PrintBufferDescs(void); #endif extern void BufferGetTag(Buffer buffer, RelFileLocator *rlocator, ForkNumber *forknum, BlockNumber *blknum);