Commit 3ec9648f authored by Rich Prohaska's avatar Rich Prohaska

Tokutek/mysql56#54 fix to tokudb::external_lock for the alter table assert...

Tokutek/mysql56#54 fix to tokudb::external_lock for the alter table assert bug, plus a rewrite of the tokudb debug tracing
parent 1d1516bf
This diff is collapsed.
...@@ -228,7 +228,7 @@ extern ulong tokudb_debug; ...@@ -228,7 +228,7 @@ extern ulong tokudb_debug;
#define TOKUDB_DEBUG_ANALYZE (1<<15) #define TOKUDB_DEBUG_ANALYZE (1<<15)
#define TOKUDB_TRACE(f, ...) \ #define TOKUDB_TRACE(f, ...) \
fprintf(stderr, "%u %s:%u " f "\n", my_tid(), __FILE__, __LINE__, ##__VA_ARGS__); fprintf(stderr, "%u %s:%u %s " f "\n", my_tid(), __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
static inline unsigned int my_tid() { static inline unsigned int my_tid() {
return (unsigned int)toku_os_gettid(); return (unsigned int)toku_os_gettid();
...@@ -237,7 +237,7 @@ static inline unsigned int my_tid() { ...@@ -237,7 +237,7 @@ static inline unsigned int my_tid() {
#define TOKUDB_DBUG_ENTER(f, ...) \ #define TOKUDB_DBUG_ENTER(f, ...) \
{ \ { \
if (tokudb_debug & TOKUDB_DEBUG_ENTER) { \ if (tokudb_debug & TOKUDB_DEBUG_ENTER) { \
TOKUDB_TRACE("%s " f, __FUNCTION__, ##__VA_ARGS__); \ TOKUDB_TRACE(f, ##__VA_ARGS__); \
} \ } \
} \ } \
DBUG_ENTER(__FUNCTION__); DBUG_ENTER(__FUNCTION__);
...@@ -246,15 +246,18 @@ static inline unsigned int my_tid() { ...@@ -246,15 +246,18 @@ static inline unsigned int my_tid() {
{ \ { \
int rr = (r); \ int rr = (r); \
if ((tokudb_debug & TOKUDB_DEBUG_RETURN) || (rr != 0 && (tokudb_debug & TOKUDB_DEBUG_ERROR))) { \ if ((tokudb_debug & TOKUDB_DEBUG_RETURN) || (rr != 0 && (tokudb_debug & TOKUDB_DEBUG_ERROR))) { \
TOKUDB_TRACE("%s return %d", __FUNCTION__, rr); \ TOKUDB_TRACE("return %d", rr); \
} \ } \
DBUG_RETURN(rr); \ DBUG_RETURN(rr); \
} }
#define TOKUDB_HANDLER_TRACE(f, ...) \
fprintf(stderr, "%u %p %s:%u ha_tokudb::%s " f "\n", my_tid(), this, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
#define TOKUDB_HANDLER_DBUG_ENTER(f, ...) \ #define TOKUDB_HANDLER_DBUG_ENTER(f, ...) \
{ \ { \
if (tokudb_debug & TOKUDB_DEBUG_ENTER) { \ if (tokudb_debug & TOKUDB_DEBUG_ENTER) { \
fprintf(stderr, "%u %p %s:%u ha_tokudb::%s " f "\n", my_tid(), this, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ TOKUDB_HANDLER_TRACE(f, ##__VA_ARGS__); \
} \ } \
} \ } \
DBUG_ENTER(__FUNCTION__); DBUG_ENTER(__FUNCTION__);
...@@ -263,14 +266,14 @@ static inline unsigned int my_tid() { ...@@ -263,14 +266,14 @@ static inline unsigned int my_tid() {
{ \ { \
int rr = (r); \ int rr = (r); \
if ((tokudb_debug & TOKUDB_DEBUG_RETURN) || (rr != 0 && (tokudb_debug & TOKUDB_DEBUG_ERROR))) { \ if ((tokudb_debug & TOKUDB_DEBUG_RETURN) || (rr != 0 && (tokudb_debug & TOKUDB_DEBUG_ERROR))) { \
fprintf(stderr, "%u %p %s:%u ha_tokudb::%s return %d" "\n", my_tid(), this, __FILE__, __LINE__, __FUNCTION__, rr); \ TOKUDB_HANDLER_TRACE("return %d", rr); \
} \ } \
DBUG_RETURN(rr); \ DBUG_RETURN(rr); \
} }
#define TOKUDB_DBUG_DUMP(s, p, len) \ #define TOKUDB_DBUG_DUMP(s, p, len) \
{ \ { \
TOKUDB_TRACE("%s:%s", __FUNCTION__, s); \ TOKUDB_TRACE("%s", s); \
uint i; \ uint i; \
for (i=0; i<len; i++) { \ for (i=0; i<len; i++) { \
fprintf(stderr, "%2.2x", ((uchar*)p)[i]); \ fprintf(stderr, "%2.2x", ((uchar*)p)[i]); \
......
...@@ -381,7 +381,7 @@ static int tokudb_init_func(void *p) { ...@@ -381,7 +381,7 @@ static int tokudb_init_func(void *p) {
r = db_env->set_flags(db_env, tokudb_env_flags, 1); r = db_env->set_flags(db_env, tokudb_env_flags, 1);
if (r) { // QQQ if (r) { // QQQ
if (tokudb_debug & TOKUDB_DEBUG_INIT) if (tokudb_debug & TOKUDB_DEBUG_INIT)
TOKUDB_TRACE("%s:WARNING: flags=%x r=%d", __FUNCTION__, tokudb_env_flags, r); TOKUDB_TRACE("WARNING: flags=%x r=%d", tokudb_env_flags, r);
// goto error; // goto error;
} }
...@@ -452,17 +452,17 @@ static int tokudb_init_func(void *p) { ...@@ -452,17 +452,17 @@ static int tokudb_init_func(void *p) {
uint32_t gbytes, bytes; int parts; uint32_t gbytes, bytes; int parts;
r = db_env->get_cachesize(db_env, &gbytes, &bytes, &parts); r = db_env->get_cachesize(db_env, &gbytes, &bytes, &parts);
if (r == 0) if (tokudb_debug & TOKUDB_DEBUG_INIT)
if (tokudb_debug & TOKUDB_DEBUG_INIT) TOKUDB_TRACE("tokudb_cache_size=%lld r=%d", ((unsigned long long) gbytes << 30) + bytes, r);
TOKUDB_TRACE("%s:tokudb_cache_size=%lld", __FUNCTION__, ((unsigned long long) gbytes << 30) + bytes);
if (db_env->set_redzone) { if (db_env->set_redzone) {
r = db_env->set_redzone(db_env, tokudb_fs_reserve_percent); r = db_env->set_redzone(db_env, tokudb_fs_reserve_percent);
if (r && (tokudb_debug & TOKUDB_DEBUG_INIT)) if (tokudb_debug & TOKUDB_DEBUG_INIT)
TOKUDB_TRACE("%s:%d r=%d", __FUNCTION__, __LINE__, r); TOKUDB_TRACE("set_redzone r=%d", r);
} }
if (tokudb_debug & TOKUDB_DEBUG_INIT) TOKUDB_TRACE("%s:env open:flags=%x", __FUNCTION__, tokudb_init_flags); if (tokudb_debug & TOKUDB_DEBUG_INIT)
TOKUDB_TRACE("env open:flags=%x", tokudb_init_flags);
r = db_env->set_generate_row_callback_for_put(db_env,generate_row_for_put); r = db_env->set_generate_row_callback_for_put(db_env,generate_row_for_put);
assert(r == 0); assert(r == 0);
...@@ -476,7 +476,8 @@ static int tokudb_init_func(void *p) { ...@@ -476,7 +476,8 @@ static int tokudb_init_func(void *p) {
r = db_env->open(db_env, tokudb_home, tokudb_init_flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); r = db_env->open(db_env, tokudb_home, tokudb_init_flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
if (tokudb_debug & TOKUDB_DEBUG_INIT) TOKUDB_TRACE("%s:env opened:return=%d", __FUNCTION__, r); if (tokudb_debug & TOKUDB_DEBUG_INIT)
TOKUDB_TRACE("env opened:return=%d", r);
if (r) { if (r) {
DBUG_PRINT("info", ("env->open %d", r)); DBUG_PRINT("info", ("env->open %d", r));
...@@ -570,6 +571,9 @@ static int tokudb_close_connection(handlerton * hton, THD * thd) { ...@@ -570,6 +571,9 @@ static int tokudb_close_connection(handlerton * hton, THD * thd) {
int error = 0; int error = 0;
tokudb_trx_data* trx = NULL; tokudb_trx_data* trx = NULL;
trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot); trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("trx %p", trx);
}
if (trx && trx->checkpoint_lock_taken) { if (trx && trx->checkpoint_lock_taken) {
error = db_env->checkpointing_resume(db_env); error = db_env->checkpointing_resume(db_env);
} }
...@@ -662,7 +666,7 @@ static int tokudb_commit(handlerton * hton, THD * thd, bool all) { ...@@ -662,7 +666,7 @@ static int tokudb_commit(handlerton * hton, THD * thd, bool all) {
DB_TXN *this_txn = *txn; DB_TXN *this_txn = *txn;
if (this_txn) { if (this_txn) {
if (tokudb_debug & TOKUDB_DEBUG_TXN) { if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("commit %u %p", all, this_txn); TOKUDB_TRACE("commit trx %u trx %p txn %p", all, trx, this_txn);
} }
// test hook to induce a crash on a debug build // test hook to induce a crash on a debug build
DBUG_EXECUTE_IF("tokudb_crash_commit_before", DBUG_SUICIDE();); DBUG_EXECUTE_IF("tokudb_crash_commit_before", DBUG_SUICIDE(););
...@@ -691,7 +695,7 @@ static int tokudb_rollback(handlerton * hton, THD * thd, bool all) { ...@@ -691,7 +695,7 @@ static int tokudb_rollback(handlerton * hton, THD * thd, bool all) {
DB_TXN *this_txn = *txn; DB_TXN *this_txn = *txn;
if (this_txn) { if (this_txn) {
if (tokudb_debug & TOKUDB_DEBUG_TXN) { if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("rollback %u %p", all, this_txn); TOKUDB_TRACE("rollback %u trx %p txn %p", all, trx, this_txn);
} }
tokudb_cleanup_handlers(trx, this_txn); tokudb_cleanup_handlers(trx, this_txn);
abort_txn_with_progress(this_txn, thd); abort_txn_with_progress(this_txn, thd);
...@@ -868,7 +872,7 @@ static int tokudb_discover(handlerton *hton, THD* thd, const char *db, const cha ...@@ -868,7 +872,7 @@ static int tokudb_discover(handlerton *hton, THD* thd, const char *db, const cha
static int tokudb_discover2(handlerton *hton, THD* thd, const char *db, const char *name, bool translate_name, static int tokudb_discover2(handlerton *hton, THD* thd, const char *db, const char *name, bool translate_name,
uchar **frmblob, size_t *frmlen) { uchar **frmblob, size_t *frmlen) {
TOKUDB_DBUG_ENTER(""); TOKUDB_DBUG_ENTER("%s %s", db, name);
int error; int error;
DB* status_db = NULL; DB* status_db = NULL;
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
...@@ -1119,7 +1123,7 @@ static void tokudb_cleanup_log_files(void) { ...@@ -1119,7 +1123,7 @@ static void tokudb_cleanup_log_files(void) {
for (np = names; *np; ++np) { for (np = names; *np; ++np) {
#if 1 #if 1
if (tokudb_debug) if (tokudb_debug)
TOKUDB_TRACE("%s:cleanup:%s", __FUNCTION__, *np); TOKUDB_TRACE("cleanup:%s", *np);
#else #else
my_delete(*np, MYF(MY_WME)); my_delete(*np, MYF(MY_WME));
#endif #endif
......
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