* Increments the abort count for each object
**/
void ABORTCOUNT(objheader_t * x) {
- x->abortCount++;
if (x->abortCount > MAXABORTS && (x->riskyflag != 1)) {
//makes riskflag sticky
pthread_mutex_lock(&lockedobjstore);
#define freearrays if (c_numelements>=200) { \
free(oidrdlocked); \
free(oidrdversion); \
+ free(oidrdage); \
} \
if (t_numelements>=200) { \
free(oidwrlocked); \
#define freearrays if (c_numelements>=200) { \
free(oidrdlocked); \
free(oidrdversion); \
+ free(oidrdage); \
free(oidwrlocked); \
}
#endif
if (c_numelements<200) { \
oidrdlocked=rdlocked; \
oidrdversion=rdversion; \
+ oidrdage=rdage; \
} else { \
int size=c_numelements*sizeof(void*); \
oidrdlocked=malloc(size); \
oidrdversion=malloc(size); \
+ oidrdage=malloc(size); \
}
#else
#define allocarrays if (c_numelements<200) { \
oidrdlocked=rdlocked; \
oidrdversion=rdversion; \
+ oidrdage=rdage; \
oidwrlocked=wrlocked; \
} else { \
int size=c_numelements*sizeof(void*); \
oidrdlocked=malloc(size); \
oidrdversion=malloc(size); \
oidwrlocked=malloc(size); \
+ oidrdage=malloc(size); \
}
#endif
int numoidwrlocked=0;
void * rdlocked[200];
int rdversion[200];
+ int rdage[200];
void * wrlocked[200];
int softabort=0;
int i;
oidwrlocked[numoidwrlocked++] = header;
transAbortProcess(oidwrlocked, numoidwrlocked);
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ header->abortCount++;
ObjSeqId = headeraddr->accessCount;
(typesCausingAbort[TYPE(header)])++;
getTotalAbortCount(i+1, size, (void *)(curr->next), numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
transAbortProcess(oidwrlocked, numoidwrlocked);
#ifdef STMSTATS
ObjSeqId = headeraddr->accessCount;
- //ABORTCOUNT(header);
+ header->abortCount++;
(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
transAbortProcess(oidwrlocked, numoidwrtotal);
#ifdef STMSTATS
ObjSeqId = headeraddr->accessCount;
- //ABORTCOUNT(header);
+ header->abortCount++;
(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
transAbortProcess(oidwrlocked, numoidwrlocked);
#endif
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ ObjSeqId = oidrdage[i];
+ header->abortCount++;
(typesCausingAbort[TYPE(header)])++;
- getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion);
+ getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
if (version!=header->version) {
transAbortProcess(oidwrlocked, numoidwrtotal);
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ ObjSeqId = oidrdage[i];
+ header->abortCount++;
(typesCausingAbort[TYPE(header)])++;
- getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion);
+ getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
transAbortProcess(oidwrlocked, numoidwrlocked);
#endif
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ ObjSeqId = oidrdage[i];
+ header->abortCount++;
(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion))
+ if(getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId))
softabort=0;
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion))
- softabort=0;
+ //if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion))
+ // softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion))
- softabort=0;
+ //if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion))
+ //softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
int numoidwrlocked=0;
void * rdlocked[200];
int rdversion[200];
+ int rdage[200];
void * wrlocked[200];
int softabort=0;
int i;
void ** oidrdlocked;
int * oidrdversion;
+ int * oidrdage;
void ** oidwrlocked;
allocarrays;
+ int ObjSeqId;
chashlistnode_t *curr = c_list;
/* Inner loop to traverse the linked list of the cache lookupTable */
oidwrlocked[numoidwrlocked++] = header;
transAbortProcess(oidwrlocked, numoidwrlocked);
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ header->abortCount++;
+ ObjSeqId = headeraddr->accessCount;
(typesCausingAbort[TYPE(header)])++;
- getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion);
+ getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
}
transAbortProcess(oidwrlocked, numoidwrlocked);
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ header->abortCount++;
+ ObjSeqId = headeraddr->accessCount;
(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion))
+ if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId))
softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
//have to abort to avoid deadlock
transAbortProcess(oidwrlocked, numoidwrtotal);
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ header->abortCount++;
+ ObjSeqId = headeraddr->accessCount;
(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion))
+ if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId))
softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
transAbortProcess(oidwrlocked, numoidwrlocked);
#endif
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ ObjSeqId = oidrdage[i];
+ header->abortCount++;
(typesCausingAbort[TYPE(header)])++;
- getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion);
+ getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
if (version!=header->version) {
transAbortProcess(oidwrlocked, numoidwrtotal);
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ ObjSeqId = oidrdage[i];
+ header->abortCount++;
(typesCausingAbort[TYPE(header)])++;
- getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion);
+ getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
transAbortProcess(oidwrlocked, numoidwrlocked);
#endif
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ ObjSeqId = oidrdage[i];
+ header->abortCount++;
(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion))
+ if(getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId))
softabort=0;
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion))
- softabort=0;
+ //if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion))
+ // softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion))
- softabort=0;
+ // if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion))
+ //softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
* : numoidrdlocked : number of objects read that are locked
* : oidrdlocked : array of objects read and currently locked
* : oidrdversion : array of versions of object read
+ * : oidrdage : array of ages of objects read ina transaction cache
+ * : ObjSeqId : sequence Id/age to start the comparision with
* =========================================================================================
**/
int getTotalAbortCount(int start, int stop, void *startptr, int numoidrdlocked,
/* versions do not match */
if(version != header->version) {
#ifdef STMSTATS
+ header->abortCount++;
if(ObjSeqId > headeraddr->accessCount) {
ObjSeqId = headeraddr->accessCount;
ObjToBeLocked = header;
}
- //ABORTCOUNT(header);
(typesCausingAbort[TYPE(header)])++;
#endif
hardabort=1;
unsigned int version = oidrdversion[i];
if(version != header->version) { /* versions do not match */
#ifdef STMSTATS
+ header->abortCount++;
if(ObjSeqId > OidAge) {
ObjSeqId = OidAge;
ObjToBeLocked = header;
}
- //ABORTCOUNT(header);
(typesCausingAbort[TYPE(header)])++;
#endif
hardabort=1;
* : numoidrdlocked : number of objects read that are locked
* : oidrdlocked : array of objects read and currently locked
* : oidrdversion : array of versions of object read
+ * : oidrdage : array of ages of objects read ina transaction cache
+ * : ObjSeqId : sequence Id/age to start the comparision with
* =========================================================================================
**/
-int getTotalAbortCount2(void *startptr, int numoidrdlocked, void *oidrdlocked, int *oidrdversion) {
+int getTotalAbortCount2(void *startptr, int numoidrdlocked, void *oidrdlocked,
+ int *oidrdversion, int *oidrdage, int ObjSeqId) {
int hardabort=0;
chashlistnode_t *curr = (chashlistnode_t *) startptr;
+ objheader_t *ObjToBeLocked=NULL;
+
/* Inner loop to traverse the linked list of the cache lookupTable */
while(curr != NULL) {
objheader_t *headeraddr=&((objheader_t *) curr->val)[-1];
/* versions do not match */
if(version != header->version) {
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ header->abortCount++;
+ if(ObjSeqId > headeraddr->accessCount) {
+ ObjSeqId = headeraddr->accessCount;
+ ObjToBeLocked = header;
+ }
(typesCausingAbort[TYPE(header)])++;
#endif
hardabort=1;
for(i=0; i<numoidrdlocked; i++) {
objheader_t *header = ((void **)oidrdlocked)[i];
unsigned int version = oidrdversion[i];
+ int OidAge = oidrdage[i];
if(version != header->version) { /* versions do not match */
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ header->abortCount++;
+ if(ObjSeqId > OidAge) {
+ ObjSeqId = OidAge;
+ ObjToBeLocked = header;
+ }
(typesCausingAbort[TYPE(header)])++;
#endif
hardabort=1;
}
}
+ if(ObjToBeLocked!=NULL)
+ ABORTCOUNT(ObjToBeLocked);
+
return hardabort;
}
* params: int start, int stop are indexes to readLocked array
* void *oidrdlocked = readLocked array
* int *oidrdversion = version array
+ * : oidrdage : array of ages of objects read ina transaction cache
+ * : ObjSeqId : sequence Id/age to start the comparision with
**/
-int getReadAbortCount(int start, int stop, void *oidrdlocked, int *oidrdversion) {
+int getReadAbortCount(int start, int stop, void *oidrdlocked, int *oidrdversion, int *oidrdage, int ObjSeqId) {
int i;
int hardabort=0;
+ objheader_t *ObjToBeLocked=NULL;
+
/* Go through oids read that are locked */
for(i = start; i < stop; i++) {
objheader_t *header = ((void **)oidrdlocked)[i];
unsigned int version = oidrdversion[i];
+ int OidAge = oidrdage[i];
if(version != header->version) { /* versions do not match */
#ifdef STMSTATS
- //ABORTCOUNT(header);
+ header->abortCount++;
+ if(ObjSeqId > OidAge) {
+ ObjSeqId = OidAge;
+ ObjToBeLocked = header;
+ }
(typesCausingAbort[TYPE(header)])++;
#endif
hardabort=1;
}
}
+
+ if(ObjToBeLocked != NULL)
+ ABORTCOUNT(ObjToBeLocked);
+
return hardabort;
}