diff options
author | Rich Prohaska <prohaska@tokutek.com> | 2014-01-29 14:03:00 -0500 |
---|---|---|
committer | Rich Prohaska <prohaska@tokutek.com> | 2014-01-29 14:03:00 -0500 |
commit | 2ea52a40caa945fc91acb74b44b35e5183a22a9c (patch) | |
tree | c4590b4e007305189370e6e17ae466edac8f5d4e /storage | |
parent | 5dd3f2160d21771c7372fcd5d5def5e72c873f58 (diff) | |
download | mariadb-git-2ea52a40caa945fc91acb74b44b35e5183a22a9c.tar.gz |
#172 map ydb errors to handler errors in prelocking functions
Diffstat (limited to 'storage')
-rw-r--r-- | storage/tokudb/ha_tokudb.cc | 32 | ||||
-rw-r--r-- | storage/tokudb/ha_tokudb.h | 3 | ||||
-rw-r--r-- | storage/tokudb/ha_tokudb_admin.cc | 19 |
3 files changed, 31 insertions, 23 deletions
diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc index 276a776ead1..e93120c4dff 100644 --- a/storage/tokudb/ha_tokudb.cc +++ b/storage/tokudb/ha_tokudb.cc @@ -4368,6 +4368,7 @@ void ha_tokudb::column_bitmaps_signal() { // error otherwise // int ha_tokudb::prepare_index_scan() { + TOKUDB_HANDLER_DBUG_ENTER(""); int error = 0; HANDLE_INVALID_CURSOR(); error = prelock_range(NULL, NULL); @@ -4376,7 +4377,7 @@ int ha_tokudb::prepare_index_scan() { range_lock_grabbed = true; error = 0; cleanup: - return error; + TOKUDB_HANDLER_DBUG_RETURN(error); } @@ -4388,6 +4389,7 @@ cleanup: // error otherwise // int ha_tokudb::prepare_index_key_scan(const uchar * key, uint key_len) { + TOKUDB_HANDLER_DBUG_ENTER(""); int error = 0; DBT start_key, end_key; THD* thd = ha_thd(); @@ -4416,9 +4418,7 @@ int ha_tokudb::prepare_index_key_scan(const uchar * key, uint key_len) { error = 0; cleanup: if (error) { - if (error == DB_LOCK_NOTGRANTED) { - error = HA_ERR_LOCK_WAIT_TIMEOUT; - } + error = map_to_handler_error(error); last_cursor_error = error; // // cursor should be initialized here, but in case it is not, @@ -4431,7 +4431,7 @@ cleanup: remove_from_trx_handler_list(); } } - return error; + TOKUDB_HANDLER_DBUG_RETURN(error); } void ha_tokudb::invalidate_bulk_fetch() { @@ -4502,6 +4502,7 @@ int ha_tokudb::index_init(uint keynr, bool sorted) { my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0)); } table->status = STATUS_NOT_FOUND; + error = map_to_handler_error(error); last_cursor_error = error; cursor = NULL; // Safety goto exit; @@ -4561,9 +4562,7 @@ int ha_tokudb::index_end() { int ha_tokudb::handle_cursor_error(int error, int err_to_return, uint keynr) { TOKUDB_HANDLER_DBUG_ENTER(""); if (error) { - if (error == DB_LOCK_NOTGRANTED) { - error = HA_ERR_LOCK_WAIT_TIMEOUT; - } + error = map_to_handler_error(error); last_cursor_error = error; table->status = STATUS_NOT_FOUND; if (error == DB_NOTFOUND) { @@ -5688,7 +5687,8 @@ int ha_tokudb::prelock_range( const key_range *start_key, const key_range *end_k true, (cursor_flags & DB_SERIALIZABLE) != 0 ? DB_NOTFOUND : 0 ); - if (error){ + if (error) { + error = map_to_handler_error(error); last_cursor_error = error; // // cursor should be initialized here, but in case it is not, we still check @@ -5721,11 +5721,12 @@ cleanup: // Forward scans use read_range_first()/read_range_next(). // int ha_tokudb::prepare_range_scan( const key_range *start_key, const key_range *end_key) { + TOKUDB_HANDLER_DBUG_ENTER(""); int error = prelock_range(start_key, end_key); if (!error) { range_lock_grabbed = true; } - return error; + TOKUDB_HANDLER_DBUG_RETURN(error); } int ha_tokudb::read_range_first( @@ -5734,13 +5735,14 @@ int ha_tokudb::read_range_first( bool eq_range, bool sorted) { + TOKUDB_HANDLER_DBUG_ENTER(""); int error = prelock_range(start_key, end_key); if (error) { goto cleanup; } range_lock_grabbed = true; error = handler::read_range_first(start_key, end_key, eq_range, sorted); cleanup: - return error; + TOKUDB_HANDLER_DBUG_RETURN(error); } int ha_tokudb::read_range_next() @@ -8002,7 +8004,7 @@ void ha_tokudb::restore_drop_indexes(TABLE *table_arg, uint *key_num, uint num_o } } -void ha_tokudb::print_error(int error, myf errflag) { +int ha_tokudb::map_to_handler_error(int error) { if (error == DB_LOCK_DEADLOCK) error = HA_ERR_LOCK_DEADLOCK; if (error == DB_LOCK_NOTGRANTED) @@ -8020,9 +8022,13 @@ void ha_tokudb::print_error(int error, myf errflag) { error = HA_ERR_UNSUPPORTED; } #endif - handler::print_error(error, errflag); + return error; } +void ha_tokudb::print_error(int error, myf errflag) { + error = map_to_handler_error(error); + handler::print_error(error, errflag); +} // // truncate's dictionary associated with keynr index using transaction txn diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h index 1a20f95d6b4..f66cea20c1d 100644 --- a/storage/tokudb/ha_tokudb.h +++ b/storage/tokudb/ha_tokudb.h @@ -797,6 +797,9 @@ private: LIST trx_handler_list; void add_to_trx_handler_list(); void remove_from_trx_handler_list(); + +private: + int map_to_handler_error(int error); }; #if defined(MARIADB_BASE_VERSION) diff --git a/storage/tokudb/ha_tokudb_admin.cc b/storage/tokudb/ha_tokudb_admin.cc index a5a6cdcf04f..47e13f93500 100644 --- a/storage/tokudb/ha_tokudb_admin.cc +++ b/storage/tokudb/ha_tokudb_admin.cc @@ -127,7 +127,7 @@ static int analyze_progress(void *v_extra, uint64_t rows) { } int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) { - TOKUDB_HANDLER_DBUG_ENTER(""); + TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name); uint64_t rec_per_key[table_share->key_parts]; int result = HA_ADMIN_OK; DB_TXN *txn = transaction; @@ -153,11 +153,10 @@ int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) { } else { // debug if (tokudb_debug & TOKUDB_DEBUG_ANALYZE) { - fprintf(stderr, "ha_tokudb::analyze %s.%s.%s ", - table_share->db.str, table_share->table_name.str, i == primary_key ? "primary" : table_share->key_info[i].name); + TOKUDB_HANDLER_TRACE("%s.%s.%s", + table_share->db.str, table_share->table_name.str, i == primary_key ? "primary" : table_share->key_info[i].name); for (uint j = 0; j < num_key_parts; j++) - fprintf(stderr, "%lu ", rec_per_key[next_key_part+j]); - fprintf(stderr, "\n"); + TOKUDB_HANDLER_TRACE("%lu", rec_per_key[next_key_part+j]); } } next_key_part += num_key_parts; @@ -192,7 +191,7 @@ static int hot_poll_fun(void *extra, float progress) { // flatten all DB's in this table, to do so, peform hot optimize on each db int ha_tokudb::optimize(THD * thd, HA_CHECK_OPT * check_opt) { - TOKUDB_HANDLER_DBUG_ENTER(""); + TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name); int error; uint curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); @@ -262,7 +261,7 @@ static void ha_tokudb_check_info(THD *thd, TABLE *table, const char *msg) { } int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) { - TOKUDB_HANDLER_DBUG_ENTER(""); + TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name); const char *old_proc_info = thd->proc_info; thd_proc_info(thd, "tokudb::check"); @@ -288,7 +287,7 @@ int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) { ha_tokudb_check_info(thd, table, write_status_msg); time_t now = time(0); char timebuf[32]; - fprintf(stderr, "%.24s ha_tokudb::check %s\n", ctime_r(&now, timebuf), write_status_msg); + TOKUDB_HANDLER_TRACE("%.24s %s", ctime_r(&now, timebuf), write_status_msg); } for (uint i = 0; i < num_DBs; i++) { DB *db = share->key_file[i]; @@ -299,7 +298,7 @@ int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) { ha_tokudb_check_info(thd, table, write_status_msg); time_t now = time(0); char timebuf[32]; - fprintf(stderr, "%.24s ha_tokudb::check %s\n", ctime_r(&now, timebuf), write_status_msg); + TOKUDB_HANDLER_TRACE("%.24s %s", ctime_r(&now, timebuf), write_status_msg); } struct check_context check_context = { thd }; r = db->verify_with_progress(db, ha_tokudb_check_progress, &check_context, (tokudb_debug & TOKUDB_DEBUG_CHECK) != 0, keep_going); @@ -309,7 +308,7 @@ int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) { ha_tokudb_check_info(thd, table, write_status_msg); time_t now = time(0); char timebuf[32]; - fprintf(stderr, "%.24s ha_tokudb::check %s\n", ctime_r(&now, timebuf), write_status_msg); + TOKUDB_HANDLER_TRACE("%.24s %s", ctime_r(&now, timebuf), write_status_msg); } if (result == HA_ADMIN_OK && r != 0) { result = HA_ADMIN_CORRUPT; |