removed memcpy() calls from inMemoryLog; added "const" qualifier to many LogEntry pointers.
This commit is contained in:
parent
7decae7172
commit
c1d8906d28
18 changed files with 111 additions and 86 deletions
|
@ -60,7 +60,7 @@ terms specified in this license.
|
|||
returning log entries depending on the context in which it was
|
||||
called.
|
||||
*/
|
||||
typedef int (guard_fcn_t)(LogEntry *, void *);
|
||||
typedef int (guard_fcn_t)(const LogEntry *, void *);
|
||||
|
||||
typedef struct {
|
||||
/** The LSN of the last log entry returned.*/
|
||||
|
@ -98,7 +98,7 @@ void LogTruncate(lsn_t lsn);
|
|||
|
||||
lsn_t LogTruncationPoint();
|
||||
|
||||
LogEntry * LogReadLSN(lsn_t lsn);
|
||||
const LogEntry * LogReadLSN(lsn_t lsn);
|
||||
|
||||
/**
|
||||
Inform the logging layer that a new transaction has begun.
|
||||
|
@ -125,6 +125,13 @@ lsn_t LogTransAbort(TransactionLog * l);
|
|||
*/
|
||||
LogEntry * LogUpdate(TransactionLog * l, Page * p, recordid rid, int operation, const byte * args);
|
||||
|
||||
/**
|
||||
Whenever a LogEntry is returned by a function that is defined by
|
||||
logger2.h or logHandle.h, the caller should eventually call this
|
||||
function to release any resources held by that entry.
|
||||
*/
|
||||
void FreeLogEntry(const LogEntry * e);
|
||||
|
||||
/**
|
||||
Write a compensation log record. These records are used to allow
|
||||
for efficient recovery, and possibly for log truncation. They
|
||||
|
|
|
@ -99,7 +99,7 @@ Operation getPrepare();
|
|||
/**
|
||||
Recovery's undo phase uses this logHandle iterator guard to implement Tprepare().
|
||||
*/
|
||||
int prepareGuard(LogEntry * e, void * state);
|
||||
int prepareGuard(const LogEntry * e, void * state);
|
||||
void * getPrepareGuardState();
|
||||
int prepareAction(void * state);
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
please see: http://mission.base.com/.
|
||||
|
||||
$Log$
|
||||
Revision 1.3 2006/04/11 02:20:21 sears
|
||||
removed memcpy() calls from inMemoryLog; added "const" qualifier to many LogEntry pointers.
|
||||
|
||||
Revision 1.2 2005/03/02 05:46:29 sears
|
||||
Compiles on FreeBSD!
|
||||
|
||||
|
@ -394,14 +397,14 @@ extern int pbl_LongSize( unsigned long value );
|
|||
extern int pbl_VarBufSize( unsigned char * buffer );
|
||||
|
||||
extern pblHashTable_t * pblHtCreate( );
|
||||
extern int pblHtInsert ( pblHashTable_t * h, void * key, size_t keylen,
|
||||
extern int pblHtInsert ( pblHashTable_t * h, const void * key, size_t keylen,
|
||||
void * dataptr);
|
||||
extern void * pblHtLookup ( pblHashTable_t * h, void * key, size_t keylen );
|
||||
extern void * pblHtLookup ( pblHashTable_t * h, const void * key, size_t keylen );
|
||||
extern void * pblHtFirst ( pblHashTable_t * h );
|
||||
extern void * pblHtNext ( pblHashTable_t * h );
|
||||
extern void * pblHtCurrent ( pblHashTable_t * h );
|
||||
extern void * pblHtCurrentKey ( pblHashTable_t * h );
|
||||
extern int pblHtRemove ( pblHashTable_t * h, void * key, size_t keylen );
|
||||
extern int pblHtRemove ( pblHashTable_t * h, const void * key, size_t keylen );
|
||||
extern int pblHtDelete ( pblHashTable_t * h );
|
||||
|
||||
/*
|
||||
|
|
|
@ -49,7 +49,7 @@ terms specified in this license.
|
|||
That should probably be set before calling this function.
|
||||
*/
|
||||
|
||||
static void set_offsets(LogHandle * h, LogEntry * e, lsn_t lastRead);
|
||||
static void set_offsets(LogHandle * h, const LogEntry * e, lsn_t lastRead);
|
||||
|
||||
/*-------------------------------------------------------*/
|
||||
|
||||
|
@ -73,15 +73,15 @@ LogHandle getGuardedHandle(lsn_t lsn, guard_fcn_t * guard, void * guard_state) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
LogEntry * nextInLog(LogHandle * h) {
|
||||
LogEntry * ret = LogReadLSN(h->next_offset);
|
||||
const LogEntry * nextInLog(LogHandle * h) {
|
||||
const LogEntry * ret = LogReadLSN(h->next_offset);
|
||||
if(ret != NULL) {
|
||||
set_offsets(h, ret, h->next_offset);
|
||||
}
|
||||
|
||||
if(h->guard) {
|
||||
if(!(h->guard(ret, h->guard_state))) {
|
||||
free(ret);
|
||||
FreeLogEntry(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ LogEntry * nextInLog(LogHandle * h) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
LogEntry * previousInTransaction(LogHandle * h) {
|
||||
LogEntry * ret = NULL;
|
||||
const LogEntry * previousInTransaction(LogHandle * h) {
|
||||
const LogEntry * ret = NULL;
|
||||
if(h->prev_offset > 0) {
|
||||
/* printf("A"); fflush(NULL); */
|
||||
ret = LogReadLSN(h->prev_offset);
|
||||
|
@ -102,7 +102,7 @@ LogEntry * previousInTransaction(LogHandle * h) {
|
|||
/*printf("C"); fflush(NULL);*/
|
||||
|
||||
if(!h->guard(ret, h->guard_state)) {
|
||||
free(ret);
|
||||
FreeLogEntry(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
/*printf("D"); fflush(NULL);*/
|
||||
|
@ -121,7 +121,7 @@ LogEntry * previousInTransaction(LogHandle * h) {
|
|||
logging implementation, not here. (One possibility is to have
|
||||
readLSNEntry return it explicitly.)
|
||||
*/
|
||||
static void set_offsets(LogHandle * h, LogEntry * e, lsn_t lastRead) {
|
||||
static void set_offsets(LogHandle * h, const LogEntry * e, lsn_t lastRead) {
|
||||
if(loggerType == LOG_TO_FILE) {
|
||||
h->next_offset = lastRead + sizeofLogEntry(e)+sizeof(lsn_t);
|
||||
} else if(loggerType == LOG_TO_MEMORY) {
|
||||
|
|
|
@ -78,7 +78,7 @@ LogHandle getGuardedHandle(lsn_t lsn, guard_fcn_t * f, void * guard_state);
|
|||
EOF.
|
||||
|
||||
*/
|
||||
LogEntry * nextInLog(LogHandle * h);
|
||||
const LogEntry * nextInLog(LogHandle * h);
|
||||
/**
|
||||
Returns a pointer to the previous log entry in this
|
||||
transaction. This is used to undo transactions. If the logHandle
|
||||
|
@ -95,7 +95,7 @@ LogEntry * nextInLog(LogHandle * h);
|
|||
@return NULL if there is no previous LogEntry for this
|
||||
transaction, or if the guard indicates that we're done by returning 0.
|
||||
*/
|
||||
LogEntry * previousInTransaction(LogHandle * h);
|
||||
const LogEntry * previousInTransaction(LogHandle * h);
|
||||
/*
|
||||
void closeHandle(LogHandle h);
|
||||
*/
|
||||
|
|
|
@ -244,14 +244,14 @@ int writeLogEntry(LogEntry * e) {
|
|||
if(!nextAvailableLSN) {
|
||||
|
||||
LogHandle lh;
|
||||
LogEntry * le;
|
||||
const LogEntry * le;
|
||||
|
||||
nextAvailableLSN = sizeof(lsn_t);
|
||||
lh = getLSNHandle(nextAvailableLSN);
|
||||
|
||||
while((le = nextInLog(&lh))) {
|
||||
nextAvailableLSN = le->LSN + sizeofLogEntry(le) + sizeof(long);;
|
||||
free(le);
|
||||
FreeLogEntry(le);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ LogEntry * readLSNEntry(lsn_t LSN) {
|
|||
int truncateLog(lsn_t LSN) {
|
||||
FILE *tmpLog;
|
||||
|
||||
LogEntry * le;
|
||||
const LogEntry * le;
|
||||
LogHandle lh;
|
||||
|
||||
long size;
|
||||
|
@ -474,7 +474,7 @@ int truncateLog(lsn_t LSN) {
|
|||
size = sizeofLogEntry(le);
|
||||
myFwrite(&size, sizeof(lsn_t), tmpLog);
|
||||
myFwrite(le, size, tmpLog);
|
||||
free (le);
|
||||
FreeLogEntry(le);
|
||||
}
|
||||
|
||||
fflush(tmpLog);
|
||||
|
|
|
@ -54,12 +54,14 @@ terms specified in this license.
|
|||
int loggerType = LOG_TO_MEMORY;
|
||||
|
||||
void genericLogWrite(LogEntry * e) {
|
||||
assert(loggerType != -1); // Otherwise, we haven't been initialized.
|
||||
if(loggerType == LOG_TO_FILE) {
|
||||
writeLogEntry(e);
|
||||
return;
|
||||
} else if (loggerType == LOG_TO_MEMORY) {
|
||||
writeLogEntry_InMemoryLog(e);
|
||||
return;
|
||||
}
|
||||
abort(); // we dont have an appropriate implementation, or weren't initialized...
|
||||
}
|
||||
|
||||
int LogInit(int logType) {
|
||||
|
@ -85,22 +87,23 @@ int LogDeinit() {
|
|||
}
|
||||
|
||||
void LogForce(lsn_t lsn) {
|
||||
assert(loggerType != -1);
|
||||
if(LOG_TO_FILE == loggerType) {
|
||||
if(flushedLSN() < lsn) {
|
||||
syncLog();
|
||||
}
|
||||
assert(flushedLSN() >= lsn);
|
||||
return;
|
||||
} else if(LOG_TO_MEMORY == loggerType) {
|
||||
assert(flushedLSN_InMemoryLog() >= lsn);
|
||||
return;
|
||||
}
|
||||
abort();
|
||||
}
|
||||
void LogTruncate(lsn_t lsn) {
|
||||
truncateLog(lsn);
|
||||
}
|
||||
|
||||
lsn_t LogTruncationPoint() {
|
||||
assert(loggerType != -1);
|
||||
if(LOG_TO_FILE == loggerType) {
|
||||
return firstLogEntry();
|
||||
} else if(LOG_TO_MEMORY == loggerType) {
|
||||
|
@ -108,8 +111,7 @@ lsn_t LogTruncationPoint() {
|
|||
}
|
||||
abort();
|
||||
}
|
||||
LogEntry * LogReadLSN(lsn_t lsn) {
|
||||
assert(loggerType != -1);
|
||||
const LogEntry * LogReadLSN(lsn_t lsn) {
|
||||
if(LOG_TO_FILE == loggerType) {
|
||||
return readLSNEntry(lsn);
|
||||
} else if(LOG_TO_MEMORY == loggerType) {
|
||||
|
@ -118,6 +120,20 @@ LogEntry * LogReadLSN(lsn_t lsn) {
|
|||
abort();
|
||||
}
|
||||
|
||||
void FreeLogEntry(const LogEntry * e) {
|
||||
if(LOG_TO_FILE == loggerType) {
|
||||
free(e);
|
||||
return;
|
||||
} else if(LOG_TO_MEMORY == loggerType) {
|
||||
if(e->LSN == -1) {
|
||||
free(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
TransactionLog LogTransBegin(int xid) {
|
||||
TransactionLog tl;
|
||||
tl.xid = xid;
|
||||
|
@ -139,7 +155,7 @@ static lsn_t LogTransCommon(TransactionLog * l, int type) {
|
|||
|
||||
ret = e->LSN;
|
||||
|
||||
free(e);
|
||||
FreeLogEntry(e);
|
||||
|
||||
return ret;
|
||||
|
||||
|
@ -270,6 +286,6 @@ lsn_t LogCLR(int xid, lsn_t LSN, recordid rid, lsn_t prevLSN) {
|
|||
e->LSN, LSN, prevLSN);
|
||||
|
||||
ret = e->LSN;
|
||||
free(e);
|
||||
FreeLogEntry(e);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ void redoUpdate(const LogEntry * e) {
|
|||
|
||||
releasePage(p);
|
||||
} else if(e->type == CLRLOG) {
|
||||
LogEntry * f = LogReadLSN(e->contents.clr.thisUpdateLSN);
|
||||
const LogEntry * f = LogReadLSN(e->contents.clr.thisUpdateLSN);
|
||||
recordid rid = f->contents.update.rid;
|
||||
Page * p = NULL;
|
||||
|
||||
|
@ -109,6 +109,7 @@ void redoUpdate(const LogEntry * e) {
|
|||
}
|
||||
|
||||
releasePage(p);
|
||||
FreeLogEntry(f);
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ void * TbeginNestedTopAction(int xid, int op, const byte * dat, int datSize) {
|
|||
}
|
||||
pblHtInsert(nestedTopActions, &xid, sizeof(int), prevLSN);
|
||||
pthread_mutex_unlock(&transactional_2_mutex);
|
||||
free(e);
|
||||
FreeLogEntry(e);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ void * getPrepareGuardState() {
|
|||
}
|
||||
|
||||
|
||||
int prepareGuard(LogEntry * e, void * state) {
|
||||
int prepareGuard(const LogEntry * e, void * state) {
|
||||
PrepareGuardState * pgs = state;
|
||||
int ret = pgs->continueIterating;
|
||||
if(e->type == UPDATELOG) {
|
||||
|
|
|
@ -54,7 +54,7 @@ static LinkedListPtr rollbackLSNs = NULL;
|
|||
*/
|
||||
static void Analysis () {
|
||||
|
||||
LogEntry * e;
|
||||
const LogEntry * e;
|
||||
|
||||
LogHandle lh = getLogHandle();
|
||||
|
||||
|
@ -141,14 +141,14 @@ static void Analysis () {
|
|||
default:
|
||||
assert (0);
|
||||
}
|
||||
free (e);
|
||||
FreeLogEntry(e);
|
||||
}
|
||||
TsetXIDCount(highestXid);
|
||||
}
|
||||
|
||||
static void Redo() {
|
||||
LogHandle lh = getLogHandle();
|
||||
LogEntry * e;
|
||||
const LogEntry * e;
|
||||
|
||||
while((e = nextInLog(&lh))) {
|
||||
|
||||
|
@ -170,7 +170,7 @@ static void Redo() {
|
|||
globalLockManager.commit(e->xid);
|
||||
} // if transaction aborted, wait until undo is complete before notifying the globalLockManager.
|
||||
}
|
||||
free(e);
|
||||
FreeLogEntry(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ static void Undo(int recovery) {
|
|||
|
||||
|
||||
while(rollbackLSNs != NULL) {
|
||||
LogEntry * e;
|
||||
const LogEntry * e;
|
||||
lsn_t rollback = popMaxVal(&rollbackLSNs);
|
||||
|
||||
prepare_guard_state = getPrepareGuardState();
|
||||
|
@ -260,7 +260,7 @@ static void Undo(int recovery) {
|
|||
printf ("Unknown log type to undo (TYPE=%d, XID= %d, LSN=%ld), skipping...\n", e->type, e->xid, e->LSN);
|
||||
break;
|
||||
}
|
||||
free(e);
|
||||
FreeLogEntry(e);
|
||||
}
|
||||
int transactionWasPrepared = prepareAction(prepare_guard_state);
|
||||
free(prepare_guard_state);
|
||||
|
|
|
@ -173,7 +173,7 @@ static compensated_function void TupdateHelper(int xid, recordid rid, const void
|
|||
|
||||
doUpdate(e, p);
|
||||
|
||||
free(e);
|
||||
FreeLogEntry(e);
|
||||
}
|
||||
|
||||
compensated_function void Tupdate(int xid, recordid rid, const void *dat, int op) {
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
please see: http://mission.base.com/.
|
||||
|
||||
$Log$
|
||||
Revision 1.8 2006/04/11 02:20:21 sears
|
||||
removed memcpy() calls from inMemoryLog; added "const" qualifier to many LogEntry pointers.
|
||||
|
||||
Revision 1.7 2004/10/20 06:54:39 sears
|
||||
parameter tweak..
|
||||
|
||||
|
@ -209,7 +212,7 @@ pblHashTable_t * pblHtCreate( void )
|
|||
|
||||
int pblHtInsert(
|
||||
pblHashTable_t * h, /** hash table to insert to */
|
||||
void * key, /** key to insert */
|
||||
const void * key, /** key to insert */
|
||||
size_t keylen, /** length of that key */
|
||||
void * dataptr /** dataptr to insert */
|
||||
)
|
||||
|
@ -277,7 +280,7 @@ void * dataptr /** dataptr to insert */
|
|||
|
||||
void * pblHtLookup(
|
||||
pblHashTable_t * h, /** hash table to search in */
|
||||
void * key, /** key to search */
|
||||
const void * key, /** key to search */
|
||||
size_t keylen /** length of that key */
|
||||
)
|
||||
{
|
||||
|
@ -479,7 +482,7 @@ pblHashTable_t * h /** hash table to look in */
|
|||
|
||||
int pblHtRemove(
|
||||
pblHashTable_t * h, /** hash table to remove from */
|
||||
void * key, /** OPT: key to remove */
|
||||
const void * key, /** OPT: key to remove */
|
||||
size_t keylen /** OPT: length of that key */
|
||||
)
|
||||
{
|
||||
|
|
|
@ -185,8 +185,8 @@ pobj_start (void)
|
|||
int
|
||||
pobj_end (void)
|
||||
{
|
||||
long active_xid;
|
||||
long active_nested;
|
||||
void * active_xid;
|
||||
void * active_nested;
|
||||
|
||||
if (! g_is_init)
|
||||
return -1;
|
||||
|
@ -202,7 +202,7 @@ pobj_end (void)
|
|||
if (active_xid >= 0) {
|
||||
if (pthread_setspecific (g_active_xid_key, NULL))
|
||||
return -1;
|
||||
Tcommit (active_xid);
|
||||
Tcommit ((int)active_xid);
|
||||
}
|
||||
else
|
||||
return -1; /* Attempt to close a non-open transaction. */
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
#include <check.h>
|
||||
|
||||
#include <lladd/transactional.h>
|
||||
/*#include <lladd/logger/logEntry.h> */
|
||||
#include "../../src/lladd/logger/logHandle.h"
|
||||
#include "../../src/lladd/logger/logWriter.h"
|
||||
#include "../../src/lladd/latches.h"
|
||||
#include "../../src/lladd/page.h"
|
||||
#include "../../src/lladd/page/slotted.h"
|
||||
|
@ -117,11 +114,7 @@ void * workerThreadWriting(void * q) {
|
|||
assert(p->id == rids[i].page);
|
||||
|
||||
for(k = 0; k < 100; k++) {
|
||||
int * j =NULL;
|
||||
// assert(p->loadlatch->lock->readers);
|
||||
assert(p->id == rids[i].page);
|
||||
free(j = malloc(sizeof(int)));
|
||||
assert(j);
|
||||
}
|
||||
|
||||
/* sched_yield(); */
|
||||
|
|
|
@ -132,7 +132,7 @@ START_TEST(indirectAlloc) {
|
|||
|
||||
|
||||
|
||||
printf("{page = %d, slot = %d, size = %ld}\n", rid.page, rid.slot, rid.size);
|
||||
printf("{page = %d, slot = %d, size = %lld}\n", rid.page, rid.slot, rid.size);
|
||||
|
||||
releasePage(p);
|
||||
|
||||
|
@ -156,7 +156,7 @@ START_TEST(indirectAlloc) {
|
|||
|
||||
|
||||
|
||||
printf("{page = %d, slot = %d, size = %ld}\n", rid.page, rid.slot, rid.size);
|
||||
printf("{page = %d, slot = %d, size = %lld}\n", rid.page, rid.slot, rid.size);
|
||||
|
||||
releasePage(p);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ static void setup_log() {
|
|||
|
||||
for(i = 0 ; i < 1000; i++) {
|
||||
LogEntry * e = allocCommonLogEntry(prevLSN, xid, XBEGIN);
|
||||
LogEntry * f;
|
||||
const LogEntry * f;
|
||||
recordid rid;
|
||||
byte * args = (byte*)"Test 123.";
|
||||
long args_size = 10; /* Including null */
|
||||
|
@ -93,22 +93,22 @@ static void setup_log() {
|
|||
fail_unless(sizeofLogEntry(e) == sizeofLogEntry(f), "Log entry changed size!!");
|
||||
fail_unless(0 == memcmp(e,f,sizeofLogEntry(e)), "Log entries did not agree!!");
|
||||
|
||||
free (e);
|
||||
free (f);
|
||||
FreeLogEntry (e);
|
||||
FreeLogEntry (f);
|
||||
|
||||
e = allocUpdateLogEntry(prevLSN, xid, 1, rid, args, args_size, (byte*) &preImage);
|
||||
|
||||
genericLogWrite(e);
|
||||
prevLSN = e->prevLSN;
|
||||
|
||||
f = allocCLRLogEntry(100, 1, 200, rid, 0); //prevLSN);
|
||||
LogEntry * g = allocCLRLogEntry(100, 1, 200, rid, 0); //prevLSN);
|
||||
|
||||
genericLogWrite(f);
|
||||
assert (f->type == CLRLOG);
|
||||
prevLSN = f->LSN;
|
||||
genericLogWrite(g);
|
||||
assert (g->type == CLRLOG);
|
||||
prevLSN = g->LSN;
|
||||
|
||||
free (e);
|
||||
free (f);
|
||||
FreeLogEntry (e);
|
||||
FreeLogEntry (g);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ static void setup_log() {
|
|||
*/
|
||||
START_TEST(logWriterTest)
|
||||
{
|
||||
LogEntry * e;
|
||||
const LogEntry * e;
|
||||
LogHandle h;
|
||||
int i = 0;
|
||||
|
||||
|
@ -148,7 +148,7 @@ START_TEST(logWriterTest)
|
|||
/* LogReadLSN(sizeof(lsn_t)); */
|
||||
|
||||
while((e = nextInLog(&h))) {
|
||||
free(e);
|
||||
FreeLogEntry(e);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -169,14 +169,14 @@ END_TEST
|
|||
allocated? */
|
||||
|
||||
START_TEST(logHandleColdReverseIterator) {
|
||||
LogEntry * e;
|
||||
const LogEntry * e;
|
||||
setup_log();
|
||||
LogHandle lh = getLogHandle();
|
||||
int i = 0;
|
||||
|
||||
|
||||
while(((e = nextInLog(&lh)) && (i < 100)) ) {
|
||||
free(e);
|
||||
FreeLogEntry(e);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ START_TEST(logHandleColdReverseIterator) {
|
|||
lh = getLSNHandle(e->LSN); // was 'getLogHandle...'
|
||||
while((e = previousInTransaction(&lh))) {
|
||||
i++;
|
||||
free(e);
|
||||
FreeLogEntry(e);
|
||||
}
|
||||
/* printf("i = %d\n", i); */
|
||||
// assert(i == 1);
|
||||
|
@ -203,10 +203,10 @@ END_TEST
|
|||
Build a simple log, truncate it, and then test the logWriter routines against it.
|
||||
*/
|
||||
START_TEST(logWriterTruncate) {
|
||||
LogEntry * le;
|
||||
LogEntry * le2;
|
||||
LogEntry * le3 = NULL;
|
||||
LogEntry * tmp;
|
||||
const LogEntry * le;
|
||||
const LogEntry * le2;
|
||||
const LogEntry * le3 = NULL;
|
||||
const LogEntry * tmp;
|
||||
setup_log();
|
||||
|
||||
LogHandle lh = getLogHandle();
|
||||
|
@ -233,31 +233,31 @@ START_TEST(logWriterTruncate) {
|
|||
fail_unless(NULL != tmp, NULL);
|
||||
fail_unless(tmp->LSN == le->LSN, NULL);
|
||||
|
||||
free(tmp);
|
||||
FreeLogEntry(tmp);
|
||||
tmp = LogReadLSN(le2->LSN);
|
||||
|
||||
fail_unless(NULL != tmp, NULL);
|
||||
fail_unless(tmp->LSN == le2->LSN, NULL);
|
||||
|
||||
free(tmp);
|
||||
FreeLogEntry(tmp);
|
||||
tmp = LogReadLSN(le3->LSN);
|
||||
|
||||
fail_unless(NULL != tmp, NULL);
|
||||
fail_unless(tmp->LSN == le3->LSN, NULL);
|
||||
|
||||
free(tmp);
|
||||
FreeLogEntry(tmp);
|
||||
|
||||
lh = getLogHandle();
|
||||
|
||||
i = 0;
|
||||
|
||||
free(le);
|
||||
free(le2);
|
||||
free(le3);
|
||||
FreeLogEntry(le);
|
||||
FreeLogEntry(le2);
|
||||
FreeLogEntry(le3);
|
||||
|
||||
while((le = nextInLog(&lh))) {
|
||||
i++;
|
||||
free(le);
|
||||
FreeLogEntry(le);
|
||||
}
|
||||
|
||||
|
||||
|
@ -277,7 +277,7 @@ static void* worker_thread(void * arg) {
|
|||
long i = 0;
|
||||
int truncated_to = 4;
|
||||
|
||||
LogEntry * le = allocCommonLogEntry(-1, -1, XBEGIN);
|
||||
|
||||
|
||||
int lsns[ENTRIES_PER_THREAD];
|
||||
|
||||
|
@ -285,6 +285,7 @@ static void* worker_thread(void * arg) {
|
|||
/* fail_unless(NULL != le, NULL); */
|
||||
|
||||
while(i < ENTRIES_PER_THREAD) {
|
||||
LogEntry * le = allocCommonLogEntry(-1, -1, XBEGIN);
|
||||
int threshold;
|
||||
long entry;
|
||||
int needToTruncate = 0;
|
||||
|
@ -331,9 +332,9 @@ static void* worker_thread(void * arg) {
|
|||
if(lsns[entry] > truncated_to && entry < i) {
|
||||
pthread_mutex_unlock(&random_mutex);
|
||||
/*printf("X %d\n", (LogReadLSN(lsns[entry])->xid == entry+key)); fflush(stdout); */
|
||||
LogEntry * e = LogReadLSN(lsns[entry]);
|
||||
const LogEntry * e = LogReadLSN(lsns[entry]);
|
||||
assert(e->xid == entry+key);
|
||||
free(e);
|
||||
FreeLogEntry(e);
|
||||
/* fail_unless(LogReadLSN(lsns[entry])->xid == entry+key, NULL); */
|
||||
} else {
|
||||
pthread_mutex_unlock(&random_mutex);
|
||||
|
@ -343,10 +344,10 @@ static void* worker_thread(void * arg) {
|
|||
/* Try to interleave requests as much as possible */
|
||||
/*pthread_yield(); */
|
||||
sched_yield();
|
||||
|
||||
FreeLogEntry(le);
|
||||
}
|
||||
|
||||
free(le);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
#include "../src/lladd/logger/logWriter.h"
|
||||
|
||||
|
||||
static char * logEntryToString(LogEntry * le) {
|
||||
static char * logEntryToString(const LogEntry * le) {
|
||||
char * ret = NULL;
|
||||
|
||||
switch(le->type) {
|
||||
case UPDATELOG:
|
||||
{
|
||||
recordid rid = le->contents.clr.rid;
|
||||
asprintf(&ret, "UPDATE\tlsn=%9ld\tprevlsn=%9ld\txid=%4d\trid={%8d %5d %5ld}\tfuncId=%3d\targSize=%9d\n", le->LSN, le->prevLSN, le->xid,
|
||||
asprintf(&ret, "UPDATE\tlsn=%9ld\tprevlsn=%9ld\txid=%4d\trid={%8d %5d %5lld}\tfuncId=%3d\targSize=%9d\n", le->LSN, le->prevLSN, le->xid,
|
||||
rid.page, rid.slot, rid.size, le->contents.update.funcID, le->contents.update.argSize );
|
||||
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ static char * logEntryToString(LogEntry * le) {
|
|||
case CLRLOG:
|
||||
{
|
||||
recordid rid = le->contents.clr.rid;
|
||||
asprintf(&ret, "CLR \tlsn=%9ld\tprevlsn=%9ld\txid=%4d\trid={%8d %5d %5ld}\tthisUpdateLSN=%9ld\tundoNextLSN=%9ld\n", le->LSN, le->prevLSN, le->xid,
|
||||
asprintf(&ret, "CLR \tlsn=%9ld\tprevlsn=%9ld\txid=%4d\trid={%8d %5d %5lld}\tthisUpdateLSN=%9ld\tundoNextLSN=%9ld\n", le->LSN, le->prevLSN, le->xid,
|
||||
rid.page, rid.slot, rid.size, (long int)le->contents.clr.thisUpdateLSN, (long int)le->contents.clr.undoNextLSN );
|
||||
}
|
||||
break;
|
||||
|
@ -55,7 +55,7 @@ void setupOperationsTable();
|
|||
|
||||
int main() {
|
||||
LogHandle lh;
|
||||
LogEntry * le;
|
||||
const LogEntry * le;
|
||||
|
||||
setupOperationsTable();
|
||||
|
||||
|
@ -73,6 +73,7 @@ int main() {
|
|||
|
||||
free(s);
|
||||
}
|
||||
FreeLogEntry(le);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue