Xid -1 leads to illegal memory accesses. Added checks for it; fixed
problematic unit test.
This commit is contained in:
parent
86a6c3ff77
commit
b3152261b4
3 changed files with 19 additions and 6 deletions
|
@ -74,7 +74,7 @@ void initNestedTopActions() {
|
|||
*/
|
||||
void * TbeginNestedTopAction(int xid, int op, const byte * dat, int datSize) {
|
||||
recordid rid = NULLRID;
|
||||
|
||||
assert(xid >= 0);
|
||||
rid.page = datSize;
|
||||
LogEntry * e = LogUpdate(&XactionTable[xid % MAX_TRANSACTIONS], NULL, rid, op, dat);
|
||||
DEBUG("Begin Nested Top Action e->LSN: %ld\n", e->LSN);
|
||||
|
@ -108,6 +108,8 @@ lsn_t TendNestedTopAction(int xid, void * handle) {
|
|||
if(handle) {
|
||||
pblHtInsert(nestedTopActions, &xid, sizeof(int), handle);
|
||||
}
|
||||
|
||||
assert(xid >= 0);
|
||||
// This action wasn't really undone -- This is a nested top action!
|
||||
lsn_t undoneLSN = XactionTable[xid % MAX_TRANSACTIONS].prevLSN;
|
||||
recordid undoneRID = NULLRID; // Not correct, but this field is unused anyway. ;)
|
||||
|
|
|
@ -103,6 +103,8 @@ void setupOperationsTable() {
|
|||
|
||||
|
||||
int Tinit() {
|
||||
setBufferManager(BUFFER_MANAGER_HASH);
|
||||
|
||||
pthread_mutex_init(&transactional_2_mutex, NULL);
|
||||
numActiveXactions = 0;
|
||||
|
||||
|
@ -111,6 +113,7 @@ int Tinit() {
|
|||
setupOperationsTable();
|
||||
dirtyPagesInit();
|
||||
|
||||
pageInit();
|
||||
bufInit();
|
||||
|
||||
LogInit(loggerType);
|
||||
|
@ -178,7 +181,7 @@ int Tbegin() {
|
|||
|
||||
static compensated_function void TupdateHelper(int xid, recordid rid, const void * dat, int op, Page * p) {
|
||||
LogEntry * e;
|
||||
|
||||
assert(xid >= 0);
|
||||
try {
|
||||
if(globalLockManager.writeLockPage) {
|
||||
globalLockManager.writeLockPage(xid, rid.page);
|
||||
|
@ -199,6 +202,7 @@ static compensated_function void TupdateHelper(int xid, recordid rid, const void
|
|||
|
||||
compensated_function void Tupdate(int xid, recordid rid, const void *dat, int op) {
|
||||
Page * p;
|
||||
assert(xid >= 0);
|
||||
#ifdef DEBUGGING
|
||||
pthread_mutex_lock(&transactional_2_mutex);
|
||||
assert(numActiveXactions <= MAX_TRANSACTIONS);
|
||||
|
@ -267,6 +271,7 @@ compensated_function void Tread(int xid, recordid rid, void * dat) {
|
|||
|
||||
int Tcommit(int xid) {
|
||||
lsn_t lsn;
|
||||
assert(xid >= 0);
|
||||
#ifdef DEBUGGING
|
||||
pthread_mutex_lock(&transactional_2_mutex);
|
||||
assert(numActiveXactions <= MAX_TRANSACTIONS);
|
||||
|
@ -290,7 +295,8 @@ int Tcommit(int xid) {
|
|||
|
||||
int Tabort(int xid) {
|
||||
lsn_t lsn;
|
||||
|
||||
assert(xid >= 0);
|
||||
|
||||
TransactionLog * t =&XactionTable[xid%MAX_TRANSACTIONS];
|
||||
|
||||
lsn = LogTransAbort(t /*&XactionTable[xid%MAX_TRANSACTIONS]*/);
|
||||
|
@ -323,12 +329,14 @@ int Tdeinit() {
|
|||
truncationDeinit();
|
||||
ThashDeinit();
|
||||
bufDeinit();
|
||||
pageDeinit();
|
||||
LogDeinit();
|
||||
dirtyPagesDeinit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Trevive(int xid, long lsn) {
|
||||
assert(xid >= 0);
|
||||
int index = xid % MAX_TRANSACTIONS;
|
||||
pthread_mutex_lock(&transactional_2_mutex);
|
||||
|
||||
|
@ -373,6 +381,7 @@ lsn_t transactions_minRecLSN() {
|
|||
}
|
||||
|
||||
int TisActiveTransaction(int xid) {
|
||||
if(xid > 0) { return 0; }
|
||||
pthread_mutex_lock(&transactional_2_mutex);
|
||||
int ret = xid != INVALID_XTABLE_XID && XactionTable[xid%MAX_TRANSACTIONS].xid == xid;
|
||||
pthread_mutex_unlock(&transactional_2_mutex);
|
||||
|
|
|
@ -71,10 +71,12 @@ START_TEST(operation_physical_do_undo) {
|
|||
LogEntry * setToTwo;
|
||||
|
||||
Tinit();
|
||||
int xid = -1;
|
||||
Page * p = loadPage(xid, TpageAlloc(xid));
|
||||
int xid = Tbegin();
|
||||
long long pnum = TpageAlloc(xid);
|
||||
Page * p = loadPage(xid, pnum);
|
||||
slottedPageInitialize(p);
|
||||
|
||||
|
||||
rid = slottedRawRalloc(p, sizeof(int));
|
||||
releasePage(p);
|
||||
|
||||
|
@ -105,7 +107,6 @@ START_TEST(operation_physical_do_undo) {
|
|||
fail_unless(buf == 2, NULL);
|
||||
|
||||
|
||||
|
||||
DEBUG("D\n");
|
||||
|
||||
p = loadPage(xid, rid.page);
|
||||
|
@ -165,6 +166,7 @@ START_TEST(operation_physical_do_undo) {
|
|||
LogWrite(allocCommonLogEntry(-1, -1, -1));
|
||||
|
||||
/** @todo need to re-think check_operations. The test is pretty broken. */
|
||||
Tcommit(xid);
|
||||
Tdeinit();
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue