Commit 46d4357e authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Write an abort test. Addresses #253.

git-svn-id: file:///svn/tokudb@1590 c7de825b-a66e-492c-adef-691d508d4ae1
parent 67b645b1
...@@ -133,5 +133,6 @@ static inline void toku_free_LOGGEDBRTHEADER(LOGGEDBRTHEADER val) { ...@@ -133,5 +133,6 @@ static inline void toku_free_LOGGEDBRTHEADER(LOGGEDBRTHEADER val) {
int toku_recover_init(void); int toku_recover_init(void);
void toku_recover_cleanup(void); void toku_recover_cleanup(void);
int toku_logger_abort(TOKUTXN);
#endif #endif
...@@ -97,7 +97,7 @@ int toku_rollback_commit (struct logtype_commit *le __attribute__((__unused__)), ...@@ -97,7 +97,7 @@ int toku_rollback_commit (struct logtype_commit *le __attribute__((__unused__)),
return 0; return 0;
} }
#define ABORTIT { le=le; txn=txn; abort(); } #define ABORTIT { le=le; txn=txn; fprintf(stderr, "%s:%d (%s) not ready to go\n", __FILE__, __LINE__, __func__); abort(); }
int toku_rollback_delete (struct logtype_delete *le, TOKUTXN txn) ABORTIT int toku_rollback_delete (struct logtype_delete *le, TOKUTXN txn) ABORTIT
void toku_recover_delete (struct logtype_delete *c) {c=c;fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); abort(); } void toku_recover_delete (struct logtype_delete *c) {c=c;fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); abort(); }
...@@ -215,6 +215,9 @@ void toku_recover_insertinleaf (struct logtype_insertinleaf *c) { ...@@ -215,6 +215,9 @@ void toku_recover_insertinleaf (struct logtype_insertinleaf *c) {
toku_free(c->data.data); toku_free(c->data.data);
} }
int toku_rollback_insertinleaf (struct logtype_insertinleaf *le, TOKUTXN txn) ABORTIT
// a newbrtnode should have been done before this // a newbrtnode should have been done before this
void toku_recover_resizepma (struct logtype_resizepma *c) { void toku_recover_resizepma (struct logtype_resizepma *c) {
struct cf_pair *pair; struct cf_pair *pair;
...@@ -267,6 +270,5 @@ int toku_rollback_fcreate (struct logtype_fcreate *le, TOKUTXN txn) ...@@ -267,6 +270,5 @@ int toku_rollback_fcreate (struct logtype_fcreate *le, TOKUTXN txn)
int toku_rollback_fheader (struct logtype_fheader *le, TOKUTXN txn) ABORTIT int toku_rollback_fheader (struct logtype_fheader *le, TOKUTXN txn) ABORTIT
int toku_rollback_newbrtnode (struct logtype_newbrtnode *le, TOKUTXN txn) ABORTIT int toku_rollback_newbrtnode (struct logtype_newbrtnode *le, TOKUTXN txn) ABORTIT
int toku_rollback_fopen (struct logtype_fopen *le, TOKUTXN txn) ABORTIT int toku_rollback_fopen (struct logtype_fopen *le, TOKUTXN txn) ABORTIT
int toku_rollback_insertinleaf (struct logtype_insertinleaf *le, TOKUTXN txn) ABORTIT
int toku_rollback_resizepma (struct logtype_resizepma *le, TOKUTXN txn) ABORTIT int toku_rollback_resizepma (struct logtype_resizepma *le, TOKUTXN txn) ABORTIT
int toku_rollback_pmadistribute (struct logtype_pmadistribute *le, TOKUTXN txn) ABORTIT int toku_rollback_pmadistribute (struct logtype_pmadistribute *le, TOKUTXN txn) ABORTIT
...@@ -37,7 +37,7 @@ clean: ...@@ -37,7 +37,7 @@ clean:
cd tests;make clean cd tests;make clean
ydb.o: ../include/db.h ../newbrt/cachetable.h ../newbrt/brt.h ../newbrt/log.c ydb.o: ../include/db.h ../newbrt/cachetable.h ../newbrt/brt.h ../newbrt/log.c
DBBINS = ydb.o ../newbrt/brt.o ../newbrt/brt-serialize.o ../newbrt/brt-verify.o ../newbrt/cachetable.o ../newbrt/hashtable.o ../newbrt/key.o ../newbrt/memory.o ../newbrt/mempool.o ../newbrt/pma.o ../newbrt/ybt.o ../newbrt/primes.o ../newbrt/log.o ../newbrt/fingerprint.o ../newbrt/log_code.o DBBINS = ydb.o ../newbrt/brt.o ../newbrt/brt-serialize.o ../newbrt/brt-verify.o ../newbrt/cachetable.o ../newbrt/hashtable.o ../newbrt/key.o ../newbrt/memory.o ../newbrt/mempool.o ../newbrt/pma.o ../newbrt/ybt.o ../newbrt/primes.o ../newbrt/log.o ../newbrt/fingerprint.o ../newbrt/log_code.o ../newbrt/roll.o
$(LIBNAME).$(LIBEXT): $(DBBINS) $(LIBNAME).$(LIBEXT): $(DBBINS)
cc $(CPPFLAGS) $(DBBINS) $(SHARED) -o $@ $(CFLAGS) -lz cc $(CPPFLAGS) $(DBBINS) $(SHARED) -o $@ $(CFLAGS) -lz
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
/* Simple test of logging. Can I start a TokuDB with logging enabled? */
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <db.h>
#include <string.h>
#include <stdio.h>
// DIR is defined in the Makefile
DB_ENV *env;
DB *db;
DB_TXN *tid;
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
int main (int argc, char *argv[]) {
int r;
system("rm -rf " DIR);
r=mkdir(DIR, 0777); assert(r==0);
r=db_env_create(&env, 0); assert(r==0);
r=env->open(env, DIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_PRIVATE|DB_CREATE, 0777); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
r=db->open(db, tid, "foo.db", 0, DB_BTREE, DB_CREATE, 0777); CKERR(r);
{
DBT key,data;
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
key.data="hello";
key.size=6;
data.data="there";
data.size=6;
r=db->put(db, tid, &key, &data, 0);
CKERR(r);
}
r=tid->abort(tid); assert(r==0);
r=db->close(db, 0); assert(r==0);
r=env->close(env, 0); assert(r==0);
return 0;
}
...@@ -690,7 +690,7 @@ static TXNID next_txn = 0; ...@@ -690,7 +690,7 @@ static TXNID next_txn = 0;
static int toku_txn_abort(DB_TXN * txn) { static int toku_txn_abort(DB_TXN * txn) {
HANDLE_PANICKED_ENV(txn->mgrp); HANDLE_PANICKED_ENV(txn->mgrp);
return -1; // wont compile yet return toku_logger_abort(txn->mgrp->i->logger); return toku_logger_abort(txn->i->tokutxn);
} }
static int toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags) { static int toku_txn_begin(DB_ENV * env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags) {
......
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