Commit 48a6883b authored by Rich Prohaska's avatar Rich Prohaska

#258 support deferred XA recovery with discard of prepared txns and dirty...

#258 support deferred XA recovery with discard of prepared txns and dirty shutdown of the FT environment
parent 1cd4af2b
...@@ -336,7 +336,7 @@ static int tokudb_init_func(void *p) { ...@@ -336,7 +336,7 @@ static int tokudb_init_func(void *p) {
#if TOKUDB_CHECK_JEMALLOC #if TOKUDB_CHECK_JEMALLOC
if (tokudb_check_jemalloc && dlsym(RTLD_DEFAULT, "mallctl") == NULL) { if (tokudb_check_jemalloc && dlsym(RTLD_DEFAULT, "mallctl") == NULL) {
sql_print_error("%s not initialized because jemalloc is not loaded", tokudb_hton_name); sql_print_error("%s is not initialized because jemalloc is not loaded", tokudb_hton_name);
goto error; goto error;
} }
#endif #endif
...@@ -597,8 +597,35 @@ int tokudb_end(handlerton * hton, ha_panic_function type) { ...@@ -597,8 +597,35 @@ int tokudb_end(handlerton * hton, ha_panic_function type) {
if (db_env) { if (db_env) {
if (tokudb_init_flags & DB_INIT_LOG) if (tokudb_init_flags & DB_INIT_LOG)
tokudb_cleanup_log_files(); tokudb_cleanup_log_files();
error = db_env->close(db_env, 0); // Error is logged #if TOKU_INCLUDE_XA
assert(error==0); long total_prepared = 0; // count the total number of prepared txn's that we discard
while (1) {
// get xid's
const long n_xid = 1;
TOKU_XA_XID xids[n_xid];
long n_prepared = 0;
error = db_env->txn_xa_recover(db_env, xids, n_xid, &n_prepared, total_prepared == 0 ? DB_FIRST : DB_NEXT);
assert(error == 0);
if (n_prepared == 0)
break;
// discard xid's
for (long i = 0; i < n_xid; i++) {
DB_TXN *txn = NULL;
error = db_env->get_txn_from_xid(db_env, &xids[i], &txn);
assert(error == 0);
error = txn->discard(txn, 0);
assert(error == 0);
}
total_prepared += n_prepared;
}
#endif
error = db_env->close(db_env, total_prepared > 0 ? TOKUFT_DIRTY_SHUTDOWN : 0);
#if TOKU_INCLUDE_XA
if (error != 0 && total_prepared > 0) {
sql_print_error("%s: %ld prepared txns still live, please shutdown, error %d", tokudb_hton_name, total_prepared, error);
} else
#endif
assert(error == 0);
db_env = NULL; db_env = NULL;
} }
...@@ -690,7 +717,7 @@ static void commit_txn_with_progress(DB_TXN* txn, uint32_t flags, THD* thd) { ...@@ -690,7 +717,7 @@ static void commit_txn_with_progress(DB_TXN* txn, uint32_t flags, THD* thd) {
info.thd = thd; info.thd = thd;
int r = txn->commit_with_progress(txn, flags, txn_progress_func, &info); int r = txn->commit_with_progress(txn, flags, txn_progress_func, &info);
if (r != 0) { if (r != 0) {
sql_print_error("tried committing transaction %p and got error code %d", txn, r); sql_print_error("%s: tried committing transaction %p and got error code %d", tokudb_hton_name, txn, r);
} }
assert(r == 0); assert(r == 0);
thd_proc_info(thd, orig_proc_info); thd_proc_info(thd, orig_proc_info);
...@@ -702,7 +729,7 @@ static void abort_txn_with_progress(DB_TXN* txn, THD* thd) { ...@@ -702,7 +729,7 @@ static void abort_txn_with_progress(DB_TXN* txn, THD* thd) {
info.thd = thd; info.thd = thd;
int r = txn->abort_with_progress(txn, txn_progress_func, &info); int r = txn->abort_with_progress(txn, txn_progress_func, &info);
if (r != 0) { if (r != 0) {
sql_print_error("tried aborting transaction %p and got error code %d", txn, r); sql_print_error("%s: tried aborting transaction %p and got error code %d", tokudb_hton_name, txn, r);
} }
assert(r == 0); assert(r == 0);
thd_proc_info(thd, orig_proc_info); thd_proc_info(thd, orig_proc_info);
...@@ -1955,7 +1982,7 @@ static void tokudb_lock_timeout_callback(DB *db, uint64_t requesting_txnid, cons ...@@ -1955,7 +1982,7 @@ static void tokudb_lock_timeout_callback(DB *db, uint64_t requesting_txnid, cons
} }
// dump to stderr // dump to stderr
if (lock_timeout_debug & 2) { if (lock_timeout_debug & 2) {
TOKUDB_TRACE("%s", log_str.c_ptr()); sql_print_error("%s: %s", tokudb_hton_name, log_str.c_ptr());
} }
} }
} }
......
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