diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc index 775399716d3..1288d30b864 100644 --- a/storage/tokudb/ha_tokudb.cc +++ b/storage/tokudb/ha_tokudb.cc @@ -342,6 +342,22 @@ int poll_fun(void *extra, float progress) { return 0; } +struct hot_poll_fun_extra { + uint current_table; + uint num_tables; +}; + +int hot_poll_fun(void *extra, float progress) { + HOT_OPTIMIZE_CONTEXT context = (HOT_OPTIMIZE_CONTEXT)extra; + if (context->thd->killed) { + sprintf(context->write_status_msg, "The process has been killed, aborting hot optimize."); + return ER_ABORTING_CONNECTION; + } + sprintf(context->write_status_msg, "Optimization of index %u of %u about %.lf%% done", context->current_table, context->num_tables, progress*100); + thd_proc_info(context->thd, context->write_status_msg); + return 0; +} + void loader_ai_err_fun(DB *db, int i, int err, DBT *key, DBT *val, void *error_extra) { LOADER_CONTEXT context = (LOADER_CONTEXT)error_extra; @@ -7689,12 +7705,16 @@ int ha_tokudb::optimize(THD * thd, HA_CHECK_OPT * check_opt) { if (error) { goto cleanup; } - /* - error = db->hot_optimize(db); + struct hot_optimize_context hc; + memset(&hc, 0, sizeof hc); + hc.thd = thd; + hc.ha = this; + hc.current_table = i; + hc.num_tables = curr_num_DBs; + error = db->hot_optimize(db, hot_poll_fun, &hc); if (error) { goto cleanup; } - */ } error = 0; diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h index 1fc20e9dd6d..9fa681c9d4c 100644 --- a/storage/tokudb/ha_tokudb.h +++ b/storage/tokudb/ha_tokudb.h @@ -22,6 +22,14 @@ typedef struct loader_context { ha_tokudb* ha; } *LOADER_CONTEXT; +typedef struct hot_optimize_context { + THD *thd; + char write_status_msg[200]; + ha_tokudb *ha; + uint current_table; + uint num_tables; +} *HOT_OPTIMIZE_CONTEXT; + // // This object stores table information that is to be shared // among all ha_tokudb objects. diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc index b8de6bd22a2..00f7b87a4c8 100644 --- a/storage/tokudb/hatoku_hton.cc +++ b/storage/tokudb/hatoku_hton.cc @@ -1293,7 +1293,7 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) { SHOWVAL(cleaner_max_buffer_workdone); SHOWVAL(cleaner_min_buffer_workdone); SHOWVAL(cleaner_total_buffer_workdone); - SHOWVAL(cleaner_num_leaves_unmerged); + SHOWVAL(cleaner_num_dirtied_for_leaf_merge); SHOWVAL(flush_total); SHOWVAL(flush_in_memory); SHOWVAL(flush_needed_io); @@ -1319,6 +1319,10 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) { SHOWVAL(dirty_leaf); SHOWVAL(dirty_nonleaf); SHOWVAL(balance_leaf); + SHOWVAL(hot_num_started); + SHOWVAL(hot_num_completed); + SHOWVAL(hot_num_aborted); + SHOWVAL(hot_max_root_flush_count); SHOWVAL(msg_bytes_in); SHOWVAL(msg_bytes_out); SHOWVAL(msg_bytes_curr);