Commit 60d54906 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#4869 increase test coverage of txn.c, remove spin locks refs[t:4869]

git-svn-id: file:///svn/toku/tokudb@43421 c7de825b-a66e-492c-adef-691d508d4ae1
parent 82cbe0ac
...@@ -188,13 +188,11 @@ toku_txn_create_txn ( ...@@ -188,13 +188,11 @@ toku_txn_create_txn (
verify_snapshot_system(logger); verify_snapshot_system(logger);
} }
assert(logger->rollback_cachefile); assert(logger->rollback_cachefile);
TOKUTXN MALLOC(result); TOKUTXN XMALLOC(result);
if (result == 0)
return errno;
result->starttime = time(NULL); // getting timestamp in seconds is a cheap call result->starttime = time(NULL); // getting timestamp in seconds is a cheap call
int r; int r;
r = toku_omt_create(&result->open_brt_headers); r = toku_omt_create(&result->open_brt_headers);
if (r!=0) goto died; assert_zero(r);
result->logger = logger; result->logger = logger;
result->parent = parent_tokutxn; result->parent = parent_tokutxn;
...@@ -237,11 +235,6 @@ toku_txn_create_txn ( ...@@ -237,11 +235,6 @@ toku_txn_create_txn (
verify_snapshot_system(logger); verify_snapshot_system(logger);
} }
return 0; return 0;
died:
// TODO memory leak
toku_logger_panic(logger, r);
return r;
} }
int int
...@@ -252,7 +245,7 @@ toku_txn_start_txn(TOKUTXN txn) { ...@@ -252,7 +245,7 @@ toku_txn_start_txn(TOKUTXN txn) {
if (txn->txnid64 == TXNID_NONE) { if (txn->txnid64 == TXNID_NONE) {
LSN first_lsn; LSN first_lsn;
r = toku_log_xbegin(logger, &first_lsn, 0, parent ? parent->txnid64 : 0); r = toku_log_xbegin(logger, &first_lsn, 0, parent ? parent->txnid64 : 0);
if (r!=0) goto died; assert_zero(r);
txn->txnid64 = first_lsn.lsn; txn->txnid64 = first_lsn.lsn;
} }
XIDS parent_xids; XIDS parent_xids;
...@@ -260,8 +253,8 @@ toku_txn_start_txn(TOKUTXN txn) { ...@@ -260,8 +253,8 @@ toku_txn_start_txn(TOKUTXN txn) {
parent_xids = xids_get_root_xids(); parent_xids = xids_get_root_xids();
else else
parent_xids = parent->xids; parent_xids = parent->xids;
if ((r = xids_create_child(parent_xids, &txn->xids, txn->txnid64))) r = xids_create_child(parent_xids, &txn->xids, txn->txnid64);
goto died; assert_zero(r);
if (toku_omt_size(logger->live_txns) == 0) { if (toku_omt_size(logger->live_txns) == 0) {
assert(logger->oldest_living_xid == TXNID_NONE_LIVING); assert(logger->oldest_living_xid == TXNID_NONE_LIVING);
...@@ -275,7 +268,7 @@ toku_txn_start_txn(TOKUTXN txn) { ...@@ -275,7 +268,7 @@ toku_txn_start_txn(TOKUTXN txn) {
//Add txn to list (omt) of live transactions //Add txn to list (omt) of live transactions
//We know it is the newest one. //We know it is the newest one.
r = toku_omt_insert_at(logger->live_txns, txn, toku_omt_size(logger->live_txns)); r = toku_omt_insert_at(logger->live_txns, txn, toku_omt_size(logger->live_txns));
if (r!=0) goto died; assert_zero(r);
// //
// maintain the data structures necessary for MVCC: // maintain the data structures necessary for MVCC:
...@@ -296,7 +289,7 @@ toku_txn_start_txn(TOKUTXN txn) { ...@@ -296,7 +289,7 @@ toku_txn_start_txn(TOKUTXN txn) {
if (parent == NULL) { if (parent == NULL) {
//Add txn to list (omt) of live root txns //Add txn to list (omt) of live root txns
r = toku_omt_insert_at(logger->live_root_txns, (OMTVALUE) txn->txnid64, toku_omt_size(logger->live_root_txns)); //We know it is the newest one. r = toku_omt_insert_at(logger->live_root_txns, (OMTVALUE) txn->txnid64, toku_omt_size(logger->live_root_txns)); //We know it is the newest one.
if (r!=0) goto died; assert_zero(r);
txn->ancestor_txnid64 = txn->txnid64; txn->ancestor_txnid64 = txn->txnid64;
} }
else { else {
...@@ -329,11 +322,6 @@ toku_txn_start_txn(TOKUTXN txn) { ...@@ -329,11 +322,6 @@ toku_txn_start_txn(TOKUTXN txn) {
} }
r = toku_pthread_mutex_unlock(&logger->txn_list_lock); assert_zero(r); r = toku_pthread_mutex_unlock(&logger->txn_list_lock); assert_zero(r);
return 0; return 0;
died:
// TODO memory leak
toku_logger_panic(logger, r);
return r;
} }
//Used on recovery to recover a transaction. //Used on recovery to recover a transaction.
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#define _TOKU_PTHREAD_H #define _TOKU_PTHREAD_H
#include <pthread.h> #include <pthread.h>
#include "toku_spinlock.h"
#include <time.h> #include <time.h>
#include <stdint.h> #include <stdint.h>
#include "toku_assert.h" #include "toku_assert.h"
......
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ident "Copyright (c) 2012 Tokutek Inc. All rights reserved."
#ident "$Id$"
#ifndef __TOKU_SPINLOCK_H__
#define __TOKU_SPINLOCK_H__
#include <config.h>
#include "toku_assert.h"
#ifdef HAVE_LIBKERN_OSATOMIC_H
#include <libkern/OSAtomic.h>
typedef OSSpinLock toku_spinlock_t;
static inline void
toku_spin_init(toku_spinlock_t *lock __attribute__((unused)),
int pshared __attribute__((unused))) {
}
static inline void
toku_spin_destroy(toku_spinlock_t *lock __attribute__((unused))) {
}
static inline void
toku_spin_lock(toku_spinlock_t *lock) {
OSSpinLockLock(lock);
}
static inline void
toku_spin_unlock(toku_spinlock_t *lock) {
OSSpinLockUnlock(lock);
}
#else
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
typedef pthread_spinlock_t toku_spinlock_t;
static inline void
toku_spin_init(toku_spinlock_t *lock, int pshared) {
int r = pthread_spin_init(lock, pshared);
assert_zero(r);
}
static inline void
toku_spin_destroy(toku_spinlock_t *lock) {
int r = pthread_spin_destroy(lock);
assert_zero(r);
}
static inline void
toku_spin_lock(toku_spinlock_t *lock) {
int r = pthread_spin_lock(lock);
assert_zero(r);
}
static inline void
toku_spin_unlock(toku_spinlock_t *lock) {
int r = pthread_spin_unlock(lock);
assert_zero(r);
}
#endif
#endif
#endif /* __TOKU_SPINLOCK_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment