2004-07-06 01:22:18 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include <lladd/common.h>
|
2004-07-20 03:40:57 +00:00
|
|
|
#include "latches.h"
|
2004-06-24 21:10:31 +00:00
|
|
|
#include <lladd/transactional.h>
|
2004-07-06 01:22:18 +00:00
|
|
|
|
2004-06-28 22:48:02 +00:00
|
|
|
#include <lladd/recovery.h>
|
2004-07-14 21:25:59 +00:00
|
|
|
#include "logger/logWriter.h"
|
2004-07-06 01:22:18 +00:00
|
|
|
#include <lladd/bufferManager.h>
|
2005-02-10 03:51:09 +00:00
|
|
|
#include <lladd/lockManager.h>
|
2005-02-14 02:49:59 +00:00
|
|
|
#include <lladd/compensations.h>
|
2005-02-10 03:51:09 +00:00
|
|
|
|
2004-07-30 01:28:39 +00:00
|
|
|
#include "page.h"
|
2004-07-06 01:22:18 +00:00
|
|
|
#include <lladd/logger/logger2.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
2004-08-03 02:04:56 +00:00
|
|
|
#include "page/indirect.h"
|
2004-06-24 21:10:31 +00:00
|
|
|
|
|
|
|
TransactionLog XactionTable[MAX_TRANSACTIONS];
|
|
|
|
int numActiveXactions = 0;
|
|
|
|
int xidCount = 0;
|
2004-07-20 03:40:57 +00:00
|
|
|
|
2005-02-16 04:11:14 +00:00
|
|
|
const recordid ROOT_RECORD = {1, 0, -1};
|
|
|
|
const recordid NULLRID = {0,0,-1};
|
2004-08-03 02:04:56 +00:00
|
|
|
|
2004-07-20 03:40:57 +00:00
|
|
|
/**
|
|
|
|
Locking for transactional2.c works as follows:
|
|
|
|
|
|
|
|
numActiveXactions, xidCount are protected, XactionTable is not.
|
|
|
|
This implies that we do not support multi-threaded transactions,
|
|
|
|
at least for now.
|
|
|
|
*/
|
|
|
|
pthread_mutex_t transactional_2_mutex;
|
|
|
|
|
2004-06-24 21:10:31 +00:00
|
|
|
#define INVALID_XTABLE_XID -1
|
2004-07-27 21:30:54 +00:00
|
|
|
#define PENDING_XTABLE_XID -2
|
2004-06-30 01:09:57 +00:00
|
|
|
/** Needed for debugging -- sometimes we don't want to run all of Tinit() */
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2004-06-30 01:09:57 +00:00
|
|
|
void setupOperationsTable() {
|
2004-06-24 21:10:31 +00:00
|
|
|
memset(XactionTable, INVALID_XTABLE_XID, sizeof(TransactionLog)*MAX_TRANSACTIONS);
|
|
|
|
operationsTable[OPERATION_SET] = getSet();
|
|
|
|
operationsTable[OPERATION_INCREMENT] = getIncrement();
|
|
|
|
operationsTable[OPERATION_DECREMENT] = getDecrement();
|
2004-08-03 02:04:56 +00:00
|
|
|
operationsTable[OPERATION_ALLOC] = getAlloc();
|
2004-06-24 21:10:31 +00:00
|
|
|
operationsTable[OPERATION_PREPARE] = getPrepare();
|
2004-07-06 01:22:18 +00:00
|
|
|
/* operationsTable[OPERATION_LHINSERT] = getLHInsert();
|
|
|
|
operationsTable[OPERATION_LHREMOVE] = getLHRemove(); */
|
2004-06-24 21:10:31 +00:00
|
|
|
operationsTable[OPERATION_DEALLOC] = getDealloc();
|
2004-10-02 07:29:34 +00:00
|
|
|
operationsTable[OPERATION_REALLOC] = getRealloc();
|
2004-08-21 00:03:30 +00:00
|
|
|
/* operationsTable[OPERATION_PAGE_ALLOC] = getPageAlloc();
|
|
|
|
operationsTable[OPERATION_PAGE_DEALLOC] = getPageDealloc(); */
|
2004-08-03 02:04:56 +00:00
|
|
|
operationsTable[OPERATION_PAGE_SET] = getPageSet();
|
|
|
|
|
2004-08-21 00:03:30 +00:00
|
|
|
operationsTable[OPERATION_UPDATE_FREESPACE] = getUpdateFreespace();
|
|
|
|
operationsTable[OPERATION_UPDATE_FREESPACE_INVERSE] = getUpdateFreespaceInverse();
|
|
|
|
operationsTable[OPERATION_UPDATE_FREELIST] = getUpdateFreelist();
|
|
|
|
operationsTable[OPERATION_UPDATE_FREELIST_INVERSE] = getUpdateFreelistInverse();
|
|
|
|
|
|
|
|
operationsTable[OPERATION_FREE_PAGE] = getFreePageOperation();
|
|
|
|
operationsTable[OPERATION_ALLOC_FREED] = getAllocFreedPage();
|
|
|
|
operationsTable[OPERATION_UNALLOC_FREED] = getUnallocFreedPage();
|
2004-10-02 07:29:34 +00:00
|
|
|
operationsTable[OPERATION_NOOP] = getNoop();
|
|
|
|
operationsTable[OPERATION_INSTANT_SET] = getInstantSet();
|
2004-10-06 06:08:09 +00:00
|
|
|
operationsTable[OPERATION_ARRAY_LIST_ALLOC] = getArrayListAlloc();
|
|
|
|
operationsTable[OPERATION_INITIALIZE_FIXED_PAGE] = getInitFixed();
|
|
|
|
operationsTable[OPERATION_UNINITIALIZE_PAGE] = getUnInitPage();
|
2004-06-30 01:09:57 +00:00
|
|
|
|
2004-10-18 18:24:54 +00:00
|
|
|
operationsTable[OPERATION_LINEAR_INSERT] = getLinearInsert();
|
|
|
|
operationsTable[OPERATION_UNDO_LINEAR_INSERT] = getUndoLinearInsert();
|
|
|
|
operationsTable[OPERATION_LINEAR_DELETE] = getLinearDelete();
|
|
|
|
operationsTable[OPERATION_UNDO_LINEAR_DELETE] = getUndoLinearDelete();
|
2004-12-03 00:27:47 +00:00
|
|
|
|
|
|
|
operationsTable[OPERATION_SET_RANGE] = getSetRange();
|
|
|
|
operationsTable[OPERATION_SET_RANGE_INVERSE] = getSetRangeInverse();
|
2005-01-14 10:08:10 +00:00
|
|
|
|
|
|
|
operationsTable[OPERATION_LINKED_LIST_INSERT] = getLinkedListInsert();
|
|
|
|
operationsTable[OPERATION_LINKED_LIST_REMOVE] = getLinkedListRemove();
|
2004-10-18 18:24:54 +00:00
|
|
|
|
2005-01-15 01:45:27 +00:00
|
|
|
operationsTable[OPERATION_LINEAR_HASH_INSERT] = getLinearHashInsert();
|
|
|
|
operationsTable[OPERATION_LINEAR_HASH_REMOVE] = getLinearHashRemove();
|
2005-03-01 07:32:02 +00:00
|
|
|
|
|
|
|
int i;
|
2005-01-15 01:45:27 +00:00
|
|
|
|
2005-03-01 07:32:02 +00:00
|
|
|
/* for(i = 0; i <= OPERATION_LINEAR_HASH_REMOVE; i++) {
|
|
|
|
if(operationsTable[i].id != i) {
|
|
|
|
printf("mismatch %d -> %d\n", i, operationsTable[i].id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2004-06-30 01:09:57 +00:00
|
|
|
}
|
|
|
|
|
2004-10-06 06:08:09 +00:00
|
|
|
|
2004-06-30 01:09:57 +00:00
|
|
|
int Tinit() {
|
|
|
|
|
2004-07-20 03:40:57 +00:00
|
|
|
pthread_mutex_init(&transactional_2_mutex, NULL);
|
|
|
|
|
2004-06-30 01:09:57 +00:00
|
|
|
setupOperationsTable();
|
2004-06-24 21:10:31 +00:00
|
|
|
|
|
|
|
bufInit();
|
|
|
|
|
|
|
|
openLogWriter();
|
|
|
|
|
2005-02-24 21:12:36 +00:00
|
|
|
try_ret(compensation_error()) {
|
|
|
|
pageOperationsInit();
|
|
|
|
} end_ret(compensation_error());
|
2004-11-29 21:28:13 +00:00
|
|
|
initNestedTopActions();
|
2004-10-17 02:17:00 +00:00
|
|
|
ThashInit();
|
2005-02-14 02:49:59 +00:00
|
|
|
|
|
|
|
compensations_init();
|
2005-02-24 21:12:36 +00:00
|
|
|
|
2005-02-14 02:49:59 +00:00
|
|
|
setupLockManagerCallbacksNil();
|
|
|
|
//setupLockManagerCallbacksPage();
|
2005-02-24 21:12:36 +00:00
|
|
|
|
2005-02-10 03:51:09 +00:00
|
|
|
InitiateRecovery();
|
2005-02-24 21:12:36 +00:00
|
|
|
|
2004-06-24 21:10:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Tbegin() {
|
|
|
|
|
|
|
|
int i, index = 0;
|
2004-07-20 03:40:57 +00:00
|
|
|
int xidCount_tmp;
|
|
|
|
|
|
|
|
pthread_mutex_lock(&transactional_2_mutex);
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2004-07-27 21:30:54 +00:00
|
|
|
if( numActiveXactions == MAX_TRANSACTIONS ) {
|
|
|
|
pthread_mutex_unlock(&transactional_2_mutex);
|
|
|
|
return EXCEED_MAX_TRANSACTIONS;
|
|
|
|
}
|
2004-06-24 21:10:31 +00:00
|
|
|
else
|
|
|
|
numActiveXactions++;
|
|
|
|
|
|
|
|
for( i = 0; i < MAX_TRANSACTIONS; i++ ) {
|
|
|
|
xidCount++;
|
|
|
|
if( XactionTable[xidCount%MAX_TRANSACTIONS].xid == INVALID_XTABLE_XID ) {
|
|
|
|
index = xidCount%MAX_TRANSACTIONS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-20 03:40:57 +00:00
|
|
|
xidCount_tmp = xidCount;
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2004-07-20 03:40:57 +00:00
|
|
|
assert( i < MAX_TRANSACTIONS );
|
|
|
|
|
2004-07-27 21:30:54 +00:00
|
|
|
XactionTable[index].xid = PENDING_XTABLE_XID;
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2004-07-27 21:30:54 +00:00
|
|
|
pthread_mutex_unlock(&transactional_2_mutex);
|
|
|
|
|
|
|
|
XactionTable[index] = LogTransBegin(xidCount_tmp);
|
2004-07-23 20:21:44 +00:00
|
|
|
|
2005-02-10 03:51:09 +00:00
|
|
|
if(globalLockManager.begin) { globalLockManager.begin(XactionTable[index].xid); }
|
|
|
|
|
2004-06-24 21:10:31 +00:00
|
|
|
return XactionTable[index].xid;
|
|
|
|
}
|
|
|
|
|
2005-02-24 21:12:36 +00:00
|
|
|
static compensated_function void TupdateHelper(int xid, recordid rid, const void * dat, int op, Page * p) {
|
2004-06-24 21:10:31 +00:00
|
|
|
LogEntry * e;
|
2005-02-24 21:12:36 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
if(globalLockManager.writeLockPage) {
|
|
|
|
globalLockManager.writeLockPage(xid, rid.page);
|
|
|
|
}
|
|
|
|
} end;
|
|
|
|
|
|
|
|
|
|
|
|
e = LogUpdate(&XactionTable[xid % MAX_TRANSACTIONS], p, rid, op, dat);
|
|
|
|
|
|
|
|
assert(XactionTable[xid % MAX_TRANSACTIONS].prevLSN == e->LSN);
|
|
|
|
|
|
|
|
DEBUG("T update() e->LSN: %ld\n", e->LSN);
|
|
|
|
|
|
|
|
doUpdate(e, p);
|
|
|
|
|
|
|
|
free(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
compensated_function void Tupdate(int xid, recordid rid, const void *dat, int op) {
|
2004-07-21 02:13:28 +00:00
|
|
|
Page * p;
|
2004-07-20 03:40:57 +00:00
|
|
|
#ifdef DEBUGGING
|
|
|
|
pthread_mutex_lock(&transactional_2_mutex);
|
2004-06-24 21:10:31 +00:00
|
|
|
assert(numActiveXactions <= MAX_TRANSACTIONS);
|
2004-07-20 03:40:57 +00:00
|
|
|
pthread_mutex_unlock(&transactional_2_mutex);
|
|
|
|
#endif
|
2005-02-24 21:12:36 +00:00
|
|
|
try {
|
|
|
|
p = loadPage(xid, rid.page);
|
|
|
|
} end;
|
2004-08-03 02:04:56 +00:00
|
|
|
if(*page_type_ptr(p) == INDIRECT_PAGE) {
|
|
|
|
releasePage(p);
|
2005-02-24 21:12:36 +00:00
|
|
|
try {
|
|
|
|
rid = dereferenceRID(xid, rid);
|
|
|
|
p = loadPage(xid, rid.page);
|
|
|
|
} end;
|
2004-10-18 18:24:54 +00:00
|
|
|
/** @todo Kludge! Shouldn't special case operations in transactional2. */
|
|
|
|
} else if(*page_type_ptr(p) == ARRAY_LIST_PAGE &&
|
|
|
|
op != OPERATION_LINEAR_INSERT &&
|
|
|
|
op != OPERATION_UNDO_LINEAR_INSERT &&
|
|
|
|
op != OPERATION_LINEAR_DELETE &&
|
|
|
|
op != OPERATION_UNDO_LINEAR_DELETE ) {
|
2004-10-06 06:08:09 +00:00
|
|
|
rid = dereferenceArrayListRid(p, rid.slot);
|
|
|
|
releasePage(p);
|
2005-02-24 21:12:36 +00:00
|
|
|
try {
|
|
|
|
p = loadPage(xid, rid.page);
|
|
|
|
} end;
|
2004-10-06 06:08:09 +00:00
|
|
|
}
|
2004-08-03 02:04:56 +00:00
|
|
|
|
2005-02-22 03:10:54 +00:00
|
|
|
/** @todo For logical undo logs, grabbing a lock makes no sense! */
|
2005-02-24 21:12:36 +00:00
|
|
|
begin_action(releasePage, p) {
|
|
|
|
TupdateHelper(xid, rid, dat, op, p);
|
|
|
|
/* if(globalLockManager.writeLockPage) {
|
2005-02-22 03:10:54 +00:00
|
|
|
globalLockManager.writeLockPage(xid, rid.page);
|
2005-02-24 21:12:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
e = LogUpdate(&XactionTable[xid % MAX_TRANSACTIONS], p, rid, op, dat);
|
|
|
|
|
|
|
|
} en d_action;
|
|
|
|
|
|
|
|
assert(XactionTable[xid % MAX_TRANSACTIONS].prevLSN == e->LSN);
|
|
|
|
|
|
|
|
DEBUG("Tupdate() e->LSN: %ld\n", e->LSN);
|
|
|
|
|
|
|
|
doUpdate(e, p);
|
|
|
|
releasePage(p);*/
|
|
|
|
} compensate;
|
2004-07-27 01:04:35 +00:00
|
|
|
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
|
|
|
|
2005-02-22 03:10:54 +00:00
|
|
|
compensated_function void alTupdate(int xid, recordid rid, const void *dat, int op) {
|
2005-02-24 21:12:36 +00:00
|
|
|
Page * p ;
|
|
|
|
try {
|
2005-02-10 03:51:09 +00:00
|
|
|
p = loadPage(xid, rid.page);
|
2005-02-24 21:12:36 +00:00
|
|
|
} end;
|
2004-10-27 01:40:09 +00:00
|
|
|
|
2005-02-24 21:12:36 +00:00
|
|
|
begin_action(releasePage, p) {
|
|
|
|
TupdateHelper(xid, rid, dat, op, p);
|
|
|
|
} compensate;
|
|
|
|
|
2004-10-27 01:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-19 21:16:37 +00:00
|
|
|
void TreadUnlocked(int xid, recordid rid, void * dat) {
|
2005-02-24 21:12:36 +00:00
|
|
|
Page * p;
|
|
|
|
try {
|
|
|
|
p = loadPage(xid, rid.page);
|
|
|
|
} end;
|
2004-10-19 21:16:37 +00:00
|
|
|
int page_type = *page_type_ptr(p);
|
|
|
|
if(page_type == SLOTTED_PAGE || page_type == FIXED_PAGE || !page_type ) {
|
|
|
|
|
|
|
|
} else if(page_type == INDIRECT_PAGE) {
|
|
|
|
releasePage(p);
|
|
|
|
|
2005-02-24 21:12:36 +00:00
|
|
|
try {
|
|
|
|
rid = dereferenceRIDUnlocked(xid, rid);
|
|
|
|
p = loadPage(xid, rid.page);
|
|
|
|
} end;
|
2004-10-19 21:16:37 +00:00
|
|
|
} else if(page_type == ARRAY_LIST_PAGE) {
|
|
|
|
rid = dereferenceArrayListRidUnlocked(p, rid.slot);
|
|
|
|
releasePage(p);
|
2005-02-24 21:12:36 +00:00
|
|
|
try {
|
|
|
|
p = loadPage(xid, rid.page);
|
|
|
|
} end;
|
2004-10-19 21:16:37 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
readRecordUnlocked(xid, p, rid, dat);
|
|
|
|
releasePage(p);
|
|
|
|
}
|
|
|
|
|
2005-02-22 03:10:54 +00:00
|
|
|
compensated_function void Tread(int xid, recordid rid, void * dat) {
|
|
|
|
Page * p;
|
|
|
|
try {
|
|
|
|
p = loadPage(xid, rid.page);
|
|
|
|
} end;
|
2004-08-17 01:46:17 +00:00
|
|
|
int page_type = *page_type_ptr(p);
|
2004-10-19 21:16:37 +00:00
|
|
|
if(page_type == SLOTTED_PAGE || page_type == FIXED_PAGE || !page_type ) {
|
2004-10-06 06:08:09 +00:00
|
|
|
|
2004-08-17 01:46:17 +00:00
|
|
|
} else if(page_type == INDIRECT_PAGE) {
|
2004-08-03 02:04:56 +00:00
|
|
|
releasePage(p);
|
2005-02-22 03:10:54 +00:00
|
|
|
try {
|
|
|
|
rid = dereferenceRID(xid, rid);
|
|
|
|
} end;
|
|
|
|
try {
|
|
|
|
p = loadPage(xid, rid.page);
|
|
|
|
} end;
|
2004-10-06 06:08:09 +00:00
|
|
|
|
|
|
|
} else if(page_type == ARRAY_LIST_PAGE) {
|
|
|
|
rid = dereferenceArrayListRid(p, rid.slot);
|
|
|
|
releasePage(p);
|
2005-02-22 03:10:54 +00:00
|
|
|
try {
|
|
|
|
p = loadPage(xid, rid.page);
|
|
|
|
} end;
|
2004-10-06 06:08:09 +00:00
|
|
|
|
2004-08-03 02:04:56 +00:00
|
|
|
} else {
|
|
|
|
abort();
|
|
|
|
}
|
2004-10-06 06:08:09 +00:00
|
|
|
readRecord(xid, p, rid, dat);
|
2004-07-23 20:21:44 +00:00
|
|
|
releasePage(p);
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Tcommit(int xid) {
|
2004-06-28 21:10:10 +00:00
|
|
|
lsn_t lsn;
|
2004-07-20 03:40:57 +00:00
|
|
|
#ifdef DEBUGGING
|
|
|
|
pthread_mutex_lock(&transactional_2_mutex);
|
2004-06-24 21:10:31 +00:00
|
|
|
assert(numActiveXactions <= MAX_TRANSACTIONS);
|
2004-07-27 01:04:35 +00:00
|
|
|
pthread_mutex_unlock(&transactional_2_mutex);
|
2004-07-20 03:40:57 +00:00
|
|
|
#endif
|
|
|
|
|
2004-06-28 21:10:10 +00:00
|
|
|
lsn = LogTransCommit(&XactionTable[xid % MAX_TRANSACTIONS]);
|
|
|
|
bufTransCommit(xid, lsn); /* unlocks pages */
|
2004-07-23 20:21:44 +00:00
|
|
|
|
2004-07-20 03:40:57 +00:00
|
|
|
pthread_mutex_lock(&transactional_2_mutex);
|
2004-07-23 20:21:44 +00:00
|
|
|
XactionTable[xid%MAX_TRANSACTIONS].xid = INVALID_XTABLE_XID;
|
2004-06-24 21:10:31 +00:00
|
|
|
numActiveXactions--;
|
|
|
|
assert( numActiveXactions >= 0 );
|
2004-07-20 03:40:57 +00:00
|
|
|
pthread_mutex_unlock(&transactional_2_mutex);
|
|
|
|
|
2004-06-24 21:10:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Tabort(int xid) {
|
2004-06-28 21:10:10 +00:00
|
|
|
lsn_t lsn;
|
2004-07-23 20:21:44 +00:00
|
|
|
|
|
|
|
TransactionLog * t =&XactionTable[xid%MAX_TRANSACTIONS];
|
2004-06-28 21:10:10 +00:00
|
|
|
|
2004-07-23 20:21:44 +00:00
|
|
|
lsn = LogTransAbort(t /*&XactionTable[xid%MAX_TRANSACTIONS]*/);
|
2004-06-28 22:48:02 +00:00
|
|
|
|
2004-07-23 20:21:44 +00:00
|
|
|
/** @todo is the order of the next two calls important? */
|
|
|
|
undoTrans(*t/*XactionTable[xid%MAX_TRANSACTIONS]*/);
|
|
|
|
bufTransAbort(xid, lsn);
|
2004-06-28 22:48:02 +00:00
|
|
|
|
2004-07-20 03:40:57 +00:00
|
|
|
pthread_mutex_lock(&transactional_2_mutex);
|
2004-07-23 20:21:44 +00:00
|
|
|
|
|
|
|
XactionTable[xid%MAX_TRANSACTIONS].xid = INVALID_XTABLE_XID;
|
2004-07-20 03:40:57 +00:00
|
|
|
numActiveXactions--;
|
2004-06-24 21:10:31 +00:00
|
|
|
assert( numActiveXactions >= 0 );
|
2004-07-20 03:40:57 +00:00
|
|
|
pthread_mutex_unlock(&transactional_2_mutex);
|
2004-06-24 21:10:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Tdeinit() {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for( i = 0; i < MAX_TRANSACTIONS; i++ ) {
|
|
|
|
if( XactionTable[i].xid != INVALID_XTABLE_XID ) {
|
|
|
|
Tabort(XactionTable[i].xid);
|
2004-07-27 01:04:35 +00:00
|
|
|
printf("WARNING: Tdeinit() is aborting transaction %d\n", XactionTable[i].xid);
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
assert( numActiveXactions == 0 );
|
2004-10-17 02:17:00 +00:00
|
|
|
ThashDeinit();
|
2004-06-24 21:10:31 +00:00
|
|
|
bufDeinit();
|
|
|
|
closeLogWriter();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Trevive(int xid, long lsn) {
|
|
|
|
int index = xid % MAX_TRANSACTIONS;
|
2004-07-23 20:21:44 +00:00
|
|
|
pthread_mutex_lock(&transactional_2_mutex);
|
2004-10-02 07:29:34 +00:00
|
|
|
|
|
|
|
DEBUG("Reviving xid %d at lsn %ld\n", xid, lsn);
|
|
|
|
|
2004-06-24 21:10:31 +00:00
|
|
|
if(XactionTable[index].xid != INVALID_XTABLE_XID) {
|
|
|
|
if(xid != XactionTable[index].xid) {
|
|
|
|
printf("Clashing Tprepare()'ed XID's encountered on recovery!!\n");
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
assert(XactionTable[index].xid == xid);
|
|
|
|
assert(XactionTable[index].prevLSN == lsn);
|
|
|
|
} else {
|
|
|
|
XactionTable[index].xid = xid;
|
|
|
|
XactionTable[index].prevLSN = lsn;
|
2004-07-23 20:21:44 +00:00
|
|
|
|
2004-06-24 21:10:31 +00:00
|
|
|
numActiveXactions++;
|
2004-07-23 20:21:44 +00:00
|
|
|
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
2004-07-23 20:21:44 +00:00
|
|
|
pthread_mutex_unlock(&transactional_2_mutex);
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TsetXIDCount(int xid) {
|
2004-07-20 03:40:57 +00:00
|
|
|
pthread_mutex_lock(&transactional_2_mutex);
|
2004-06-24 21:10:31 +00:00
|
|
|
xidCount = xid;
|
2004-07-20 03:40:57 +00:00
|
|
|
pthread_mutex_unlock(&transactional_2_mutex);
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|