if LONG_TEST is defined, check for pinned pages on exit.

This test is currently implemented inefficiently, otherwise it would always be enabled.
This commit is contained in:
Sears Russell 2006-07-25 01:00:46 +00:00
parent a5a234635e
commit 2a9cb788a6

View file

@ -61,6 +61,11 @@ terms specified in this license.
#include <pbl/pbl.h> #include <pbl/pbl.h>
#include <lladd/truncation.h> #include <lladd/truncation.h>
#ifdef LONG_TEST
pthread_mutex_t pinCount_mutex = PTHREAD_MUTEX_INITIALIZER;
int pinCount = 0;
#endif
static pblHashTable_t *activePages; /* page lookup */ static pblHashTable_t *activePages; /* page lookup */
/*static Page * activePagePtrs[MAX_BUFFER_SIZE];*/ /*static Page * activePagePtrs[MAX_BUFFER_SIZE];*/
@ -117,7 +122,11 @@ void bufDeinit() {
closePageFile(); closePageFile();
pageDeInit(); pageDeInit();
#ifdef LONG_TEST
if(pinCount != 0) {
printf("WARNING: At exit, %d pages were still pinned!\n", pinCount);
}
#endif
return; return;
} }
/** /**
@ -127,10 +136,19 @@ void bufDeinit() {
void simulateBufferManagerCrash() { void simulateBufferManagerCrash() {
closeBlobStore(); closeBlobStore();
closePageFile(); closePageFile();
#ifdef LONG_TEST
pinCount = 0;
#endif
} }
void releasePage (Page * p) { void releasePage (Page * p) {
unlock(p->loadlatch); unlock(p->loadlatch);
#ifdef LONG_TEST
pthread_mutex_lock(&pinCount_mutex);
pinCount --;
pthread_mutex_unlock(&pinCount_mutex);
#endif
} }
int bufTransCommit(int xid, lsn_t lsn) { int bufTransCommit(int xid, lsn_t lsn) {
@ -269,9 +287,17 @@ static Page * getPage(int pageid, int locktype) {
} }
compensated_function Page *loadPage(int xid, int pageid) { compensated_function Page *loadPage(int xid, int pageid) {
try_ret(NULL) { try_ret(NULL) {
if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); } if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); }
} end_ret(NULL); } end_ret(NULL);
Page * ret = getPage(pageid, RO); Page * ret = getPage(pageid, RO);
#ifdef LONG_TEST
pthread_mutex_lock(&pinCount_mutex);
pinCount ++;
pthread_mutex_unlock(&pinCount_mutex);
#endif
return ret; return ret;
} }