Commit 37762ee7 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Stubs exist for all the rollback operations. Addresses #253.

git-svn-id: file:///svn/tokudb@1584 c7de825b-a66e-492c-adef-691d508d4ae1
parent 48d957cd
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
...@@ -659,3 +660,36 @@ TXNID toku_txn_get_txnid (TOKUTXN txn) { ...@@ -659,3 +660,36 @@ TXNID toku_txn_get_txnid (TOKUTXN txn) {
LSN toku_txn_get_last_lsn (TOKUTXN txn) { LSN toku_txn_get_last_lsn (TOKUTXN txn) {
return txn->last_lsn; return txn->last_lsn;
} }
int toku_abort_logentry_commit (struct logtype_commit *le __attribute__((__unused__)), TOKUTXN txn) {
toku_logger_panic(txn->logger, EINVAL);
return EINVAL;
}
#define ABORTIT { le=le; txn=txn; abort(); }
int toku_abort_logentry_delete (struct logtype_delete *le, TOKUTXN txn) ABORTIT
int toku_abort_logentry_fcreate (struct logtype_fcreate *le, TOKUTXN txn) ABORTIT
int toku_abort_logentry_fheader (struct logtype_fheader *le, TOKUTXN txn) ABORTIT
int toku_abort_logentry_newbrtnode (struct logtype_newbrtnode *le, TOKUTXN txn) ABORTIT
int toku_abort_logentry_fopen (struct logtype_fopen *le, TOKUTXN txn) ABORTIT
int toku_abort_logentry_insertinleaf (struct logtype_insertinleaf *le, TOKUTXN txn) ABORTIT
int toku_abort_logentry_resizepma (struct logtype_resizepma *le, TOKUTXN txn) ABORTIT
int toku_abort_logentry_pmadistribute (struct logtype_pmadistribute *le, TOKUTXN txn) ABORTIT
int toku_logger_abort(TOKUTXN txn) {
// Must undo everything. Must undo it all in reverse order.
// Build the reverse list
struct log_entry *prev=0;
struct log_entry *item=txn->oldest_logentry;
while (item) {
item->tmp=prev;
prev=item;
item=item->next;
}
for (item=txn->newest_logentry; item; item=item->tmp) {
int r;
logtype_dispatch_assign(item, toku_abort_logentry_, r, txn);
if (r!=0) return r;
}
return 0;
}
...@@ -139,13 +139,19 @@ void generate_log_struct (void) { ...@@ -139,13 +139,19 @@ void generate_log_struct (void) {
DO_LOGTYPES(lt, fprintf(hf," struct logtype_%s %s;\n", lt->name, lt->name)); DO_LOGTYPES(lt, fprintf(hf," struct logtype_%s %s;\n", lt->name, lt->name));
fprintf(hf, " } u;\n"); fprintf(hf, " } u;\n");
fprintf(hf, " struct log_entry *next; /* for in-memory list of log entries */\n"); fprintf(hf, " struct log_entry *next; /* for in-memory list of log entries */\n");
fprintf(hf, " struct log_entry *tmp; /* This will be a back pointer, but it is only created if needed (e.g., when abort is called. */\n");
fprintf(hf, "};\n"); fprintf(hf, "};\n");
} }
void generate_dispatch (void) { void generate_dispatch (void) {
fprintf(hf, "#define logtype_dispatch(s, funprefix) ({ switch(s.cmd) {\\\n"); fprintf(hf, "#define logtype_dispatch(s, funprefix) ({ switch((s)->cmd) {\\\n");
DO_LOGTYPES(lt, fprintf(hf, " case LT_%s: funprefix ## %s (&s.u.%s); break;\\\n", lt->name, lt->name, lt->name)); DO_LOGTYPES(lt, fprintf(hf, " case LT_%s: funprefix ## %s (&(s)->u.%s); break;\\\n", lt->name, lt->name, lt->name));
fprintf(hf, " }})\n"); fprintf(hf, " }})\n");
fprintf(hf, "#define logtype_dispatch_assign(s, funprefix, var, args...) ({ switch((s)->cmd) {\\\n");
DO_LOGTYPES(lt, fprintf(hf, " case LT_%s: var = funprefix ## %s (&(s)->u.%s, ## args); break;\\\n", lt->name, lt->name, lt->name));
fprintf(hf, " }})\n");
} }
......
...@@ -254,7 +254,7 @@ int main (int argc, char *argv[]) { ...@@ -254,7 +254,7 @@ int main (int argc, char *argv[]) {
while ((r = toku_log_fread(f, &le))==0) { while ((r = toku_log_fread(f, &le))==0) {
//printf("%lld: Got cmd %c\n", le.u.commit.lsn.lsn, le.cmd); //printf("%lld: Got cmd %c\n", le.u.commit.lsn.lsn, le.cmd);
static int prevcount=-1; static int prevcount=-1;
logtype_dispatch(le, toku_recover_); logtype_dispatch(&le, toku_recover_);
if (0) { if (0) {
int thiscount = 0; int thiscount = 0;
int cfi; int cfi;
......
...@@ -369,10 +369,6 @@ static int toku_db_env_open(DB_ENV * env, const char *home, u_int32_t flags, int ...@@ -369,10 +369,6 @@ static int toku_db_env_open(DB_ENV * env, const char *home, u_int32_t flags, int
char* full_dir = NULL; char* full_dir = NULL;
if (env->i->lg_dir) full_dir = construct_full_name(env->i->dir, env->i->lg_dir); if (env->i->lg_dir) full_dir = construct_full_name(env->i->dir, env->i->lg_dir);
assert(env->i->logger); assert(env->i->logger);
if (r!=0) {
do_error(env, r, "Could not create logger\n");
goto died1;
}
r = toku_logger_open(full_dir ? full_dir : env->i->dir, env->i->logger); r = toku_logger_open(full_dir ? full_dir : env->i->dir, env->i->logger);
if (full_dir) toku_free(full_dir); if (full_dir) toku_free(full_dir);
if (r!=0) { if (r!=0) {
...@@ -694,8 +690,7 @@ static TXNID next_txn = 0; ...@@ -694,8 +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);
fprintf(stderr, "toku_txn_abort(%p)\n", txn); return toku_logger_abort(txn->mgrp->i->logger);
abort();
} }
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