Was init'ing buffer manager without de-init'ing it; Cleaned out old comments.
This commit is contained in:
parent
05ad97b37b
commit
2b1ac8dbc0
1 changed files with 29 additions and 33 deletions
|
@ -40,11 +40,19 @@ permission to use and distribute the software in accordance with the
|
||||||
terms specified in this license.
|
terms specified in this license.
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@file check_logWriter
|
||||||
|
|
||||||
|
Tests logWriter.
|
||||||
|
|
||||||
|
@todo Change tests to apply to all logger implementations.
|
||||||
|
|
||||||
|
(Also Get rid of include for logWriter.h)
|
||||||
|
*/
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <check.h>
|
#include <check.h>
|
||||||
|
|
||||||
#include <lladd/transactional.h>
|
#include <lladd/transactional.h>
|
||||||
/*#include <lladd/logger/logEntry.h> */
|
|
||||||
#include "../../src/lladd/logger/logHandle.h"
|
#include "../../src/lladd/logger/logHandle.h"
|
||||||
#include <lladd/logger/logger2.h>
|
#include <lladd/logger/logger2.h>
|
||||||
#include "../../src/lladd/logger/logWriter.h"
|
#include "../../src/lladd/logger/logWriter.h"
|
||||||
|
@ -68,6 +76,8 @@ static void setup_log() {
|
||||||
deleteLogWriter();
|
deleteLogWriter();
|
||||||
lladd_enableAutoTruncation = 0;
|
lladd_enableAutoTruncation = 0;
|
||||||
Tinit();
|
Tinit();
|
||||||
|
lsn_t firstLSN;
|
||||||
|
int first = 1;
|
||||||
|
|
||||||
for(i = 0 ; i < 1000; i++) {
|
for(i = 0 ; i < 1000; i++) {
|
||||||
LogEntry * e = allocCommonLogEntry(prevLSN, xid, XBEGIN);
|
LogEntry * e = allocCommonLogEntry(prevLSN, xid, XBEGIN);
|
||||||
|
@ -84,6 +94,11 @@ static void setup_log() {
|
||||||
LogWrite(e);
|
LogWrite(e);
|
||||||
prevLSN = e->LSN;
|
prevLSN = e->LSN;
|
||||||
|
|
||||||
|
if(first) {
|
||||||
|
first = 0;
|
||||||
|
firstLSN = prevLSN;
|
||||||
|
}
|
||||||
|
|
||||||
f = LogReadLSN(prevLSN);
|
f = LogReadLSN(prevLSN);
|
||||||
|
|
||||||
fail_unless(sizeofLogEntry(e) == sizeofLogEntry(f), "Log entry changed size!!");
|
fail_unless(sizeofLogEntry(e) == sizeofLogEntry(f), "Log entry changed size!!");
|
||||||
|
@ -99,7 +114,7 @@ static void setup_log() {
|
||||||
|
|
||||||
// LogEntry * g = allocCLRLogEntry(100, 1, 200, rid, 0); //prevLSN);
|
// LogEntry * g = allocCLRLogEntry(100, 1, 200, rid, 0); //prevLSN);
|
||||||
LogEntry * g = allocCLRLogEntry(e); // XXX will probably break
|
LogEntry * g = allocCLRLogEntry(e); // XXX will probably break
|
||||||
|
g->prevLSN = firstLSN;
|
||||||
LogWrite(g);
|
LogWrite(g);
|
||||||
assert (g->type == CLRLOG);
|
assert (g->type == CLRLOG);
|
||||||
prevLSN = g->LSN;
|
prevLSN = g->LSN;
|
||||||
|
@ -107,8 +122,6 @@ static void setup_log() {
|
||||||
FreeLogEntry (e);
|
FreeLogEntry (e);
|
||||||
FreeLogEntry (g);
|
FreeLogEntry (g);
|
||||||
}
|
}
|
||||||
// truncationDeinit();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@test
|
@test
|
||||||
|
@ -169,13 +182,12 @@ START_TEST(logHandleColdReverseIterator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
// printf("getLogHandle(%ld)\n", e->LSN);
|
lh = getLSNHandle(e->LSN);
|
||||||
lh = getLSNHandle(e->LSN); // was 'getLogHandle...'
|
|
||||||
while((e = previousInTransaction(&lh))) {
|
while((e = previousInTransaction(&lh))) {
|
||||||
i++;
|
i++;
|
||||||
FreeLogEntry(e);
|
FreeLogEntry(e);
|
||||||
}
|
}
|
||||||
assert(i < 4); /* We should almost immediately hit a clr that goes to the beginning of the log... */
|
assert(i <= 4); /* We should almost immediately hit a clr that goes to the beginning of the log... */
|
||||||
Tdeinit();
|
Tdeinit();
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
@ -207,8 +219,6 @@ START_TEST(loggerTruncate) {
|
||||||
le3 = nextInLog(&lh);
|
le3 = nextInLog(&lh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// truncateLog(le->LSN);
|
|
||||||
LogTruncate(le->LSN);
|
LogTruncate(le->LSN);
|
||||||
|
|
||||||
tmp = LogReadLSN(le->LSN);
|
tmp = LogReadLSN(le->LSN);
|
||||||
|
@ -256,7 +266,7 @@ pthread_mutex_t random_mutex;
|
||||||
|
|
||||||
lsn_t truncated_to = 4;
|
lsn_t truncated_to = 4;
|
||||||
|
|
||||||
#define NO_CONCURRENCY
|
#undef NO_CONCURRENCY
|
||||||
#ifdef NO_CONCURRENCY
|
#ifdef NO_CONCURRENCY
|
||||||
pthread_mutex_t big = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t big = PTHREAD_MUTEX_INITIALIZER;
|
||||||
#endif
|
#endif
|
||||||
|
@ -266,8 +276,10 @@ static void* worker_thread(void * arg) {
|
||||||
|
|
||||||
lsn_t lsns[ENTRIES_PER_THREAD];
|
lsn_t lsns[ENTRIES_PER_THREAD];
|
||||||
|
|
||||||
|
for(i = 0; i < ENTRIES_PER_THREAD; i++) {
|
||||||
/* fail_unless(NULL != le, NULL); */
|
lsns[i] = 0;
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
|
||||||
while(i < ENTRIES_PER_THREAD) {
|
while(i < ENTRIES_PER_THREAD) {
|
||||||
LogEntry * le = allocCommonLogEntry(-1, -1, XBEGIN);
|
LogEntry * le = allocCommonLogEntry(-1, -1, XBEGIN);
|
||||||
|
@ -313,17 +325,14 @@ static void* worker_thread(void * arg) {
|
||||||
#ifdef NO_CONCURRENCY
|
#ifdef NO_CONCURRENCY
|
||||||
pthread_mutex_unlock(&big);
|
pthread_mutex_unlock(&big);
|
||||||
#endif
|
#endif
|
||||||
//printf("reportedLSN: %ld\n", le->LSN);
|
|
||||||
lsns[i] = le->LSN;
|
lsns[i] = le->LSN;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
/* fail_unless(1, NULL); */
|
|
||||||
pthread_mutex_lock(&random_mutex);
|
pthread_mutex_lock(&random_mutex);
|
||||||
#ifdef NO_CONCURRENCY
|
#ifdef NO_CONCURRENCY
|
||||||
//pthread_mutex_lock(&big);
|
pthread_mutex_lock(&big);
|
||||||
#endif
|
#endif
|
||||||
if(lsns[entry] > truncated_to && entry < i) {
|
if(lsns[entry] > truncated_to && entry < i) {
|
||||||
/*printf("X %d\n", (LogReadLSN(lsns[entry])->xid == entry+key)); fflush(stdout); */
|
|
||||||
lsn_t lsn = lsns[entry];
|
lsn_t lsn = lsns[entry];
|
||||||
pthread_mutex_unlock(&random_mutex);
|
pthread_mutex_unlock(&random_mutex);
|
||||||
|
|
||||||
|
@ -331,17 +340,14 @@ static void* worker_thread(void * arg) {
|
||||||
|
|
||||||
assert(e->xid == entry+key);
|
assert(e->xid == entry+key);
|
||||||
FreeLogEntry(e);
|
FreeLogEntry(e);
|
||||||
/* fail_unless(LogReadLSN(lsns[entry])->xid == entry+key, NULL); */
|
|
||||||
} else {
|
} else {
|
||||||
pthread_mutex_unlock(&random_mutex);
|
pthread_mutex_unlock(&random_mutex);
|
||||||
}
|
}
|
||||||
#ifdef NO_CONCURRENCY
|
#ifdef NO_CONCURRENCY
|
||||||
//pthread_mutex_unlock(&big);
|
pthread_mutex_unlock(&big);
|
||||||
#endif
|
#endif
|
||||||
/* fail_unless(1, NULL); */
|
|
||||||
|
|
||||||
/* Try to interleave requests as much as possible */
|
/* Try to interleave requests as much as possible */
|
||||||
/*pthread_yield(); */
|
|
||||||
sched_yield();
|
sched_yield();
|
||||||
FreeLogEntry(le);
|
FreeLogEntry(le);
|
||||||
}
|
}
|
||||||
|
@ -373,12 +379,9 @@ START_TEST(loggerCheckThreaded) {
|
||||||
|
|
||||||
for(i = 0; i < THREAD_COUNT; i++) {
|
for(i = 0; i < THREAD_COUNT; i++) {
|
||||||
pthread_create(&workers[i], NULL, worker_thread, &i);
|
pthread_create(&workers[i], NULL, worker_thread, &i);
|
||||||
// printf("%d", i); fflush(stdout);
|
|
||||||
}
|
}
|
||||||
// printf("\n\n\n\n\n");
|
|
||||||
for(i = 0; i < THREAD_COUNT; i++) {
|
for(i = 0; i < THREAD_COUNT; i++) {
|
||||||
pthread_join(workers[i], NULL);
|
pthread_join(workers[i], NULL);
|
||||||
// printf("%d", i); fflush(stdout);
|
|
||||||
}
|
}
|
||||||
Tdeinit();
|
Tdeinit();
|
||||||
|
|
||||||
|
@ -409,8 +412,6 @@ void reopenLogWorkload(int truncating) {
|
||||||
|
|
||||||
if(i == SYNC_POINT) {
|
if(i == SYNC_POINT) {
|
||||||
if(truncating) {
|
if(truncating) {
|
||||||
// printf("Called LogTruncate()");
|
|
||||||
// fflush(stdout);
|
|
||||||
LogTruncate(entries[i]->LSN);
|
LogTruncate(entries[i]->LSN);
|
||||||
startLSN = entries[i]->LSN;
|
startLSN = entries[i]->LSN;
|
||||||
}
|
}
|
||||||
|
@ -423,7 +424,7 @@ void reopenLogWorkload(int truncating) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(truncating) {
|
if(truncating) {
|
||||||
h = getLogHandle(); //getLSNHandle(startLSN);
|
h = getLogHandle();
|
||||||
i = SYNC_POINT;
|
i = SYNC_POINT;
|
||||||
} else {
|
} else {
|
||||||
h = getLogHandle();
|
h = getLogHandle();
|
||||||
|
@ -477,6 +478,7 @@ void reopenLogWorkload(int truncating) {
|
||||||
|
|
||||||
lladd_enableAutoTruncation = 1;
|
lladd_enableAutoTruncation = 1;
|
||||||
|
|
||||||
|
bufDeinit(BUFFER_MANAGER_REOPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(loggerReopenTest) {
|
START_TEST(loggerReopenTest) {
|
||||||
|
@ -488,12 +490,6 @@ START_TEST(loggerReopenTest) {
|
||||||
START_TEST(loggerTruncateReopenTest) {
|
START_TEST(loggerTruncateReopenTest) {
|
||||||
deleteLogWriter();
|
deleteLogWriter();
|
||||||
reopenLogWorkload(1);
|
reopenLogWorkload(1);
|
||||||
/* reopenLogWorkload();
|
|
||||||
Tinit();
|
|
||||||
truncateNow();
|
|
||||||
Tdeinit();
|
|
||||||
Tinit();
|
|
||||||
Tdeinit(); */
|
|
||||||
} END_TEST
|
} END_TEST
|
||||||
|
|
||||||
Suite * check_suite(void) {
|
Suite * check_suite(void) {
|
||||||
|
|
Loading…
Reference in a new issue