diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 78a8adc..b6d4a74 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -1713,12 +1713,20 @@ AtEOXact_Buffers(bool isCommit) #ifdef USE_ASSERT_CHECKING if (assert_enabled) { - int i; + Buffer i; + int RefCountErrors = 0; - for (i = 0; i < NBuffers; i++) + for (i = 1; i <= NBuffers; i++) { - Assert(PrivateRefCount[i] == 0); + if (PrivateRefCount[i - 1] != 0) + { + PrintBufferLeakWarning(i); + RefCountErrors++; + } } + if (RefCountErrors > 0) + elog(WARNING, "buffers with non-zero refcount is %d", RefCountErrors); + Assert(RefCountErrors == 0); } #endif @@ -1753,12 +1761,21 @@ AtProcExit_Buffers(int code, Datum arg) #ifdef USE_ASSERT_CHECKING if (assert_enabled) { - int i; + Buffer i; + int RefCountErrors = 0; - for (i = 0; i < NBuffers; i++) + for (i = 1; i <= NBuffers; i++) { - Assert(PrivateRefCount[i] == 0); + if (PrivateRefCount[i - 1] != 0) + { + PrintBufferLeakWarning(i); + RefCountErrors++; + } } + if (RefCountErrors > 0) + elog(WARNING, "buffers with non-zero refcount is %d", RefCountErrors); + Assert(RefCountErrors == 0); + } #endif