Commit dfe48725 authored by Rich Prohaska's avatar Rich Prohaska

#180 avoid thd_proc_info pointing to invalid info (like when a function sets...

#180 avoid thd_proc_info pointing to invalid info (like when a function sets proc info with a local variable and then returns)
parent b7e362e4
......@@ -3319,10 +3319,10 @@ int ha_tokudb::end_bulk_insert(bool abort) {
if (loader) {
if (!abort_loader && !thd->killed) {
DBUG_EXECUTE_IF("tokudb_end_bulk_insert_sleep", {
const char *old_proc_info= thd->proc_info;
thd->proc_info= "DBUG sleep";
const char *old_proc_info = tokudb_thd_get_proc_info(thd);
thd_proc_info(thd, "DBUG sleep");
my_sleep(20000000);
thd->proc_info= old_proc_info;
thd_proc_info(thd, old_proc_info);
});
error = loader->close(loader);
loader = NULL;
......@@ -3399,6 +3399,7 @@ int ha_tokudb::is_index_unique(bool* is_unique, DB_TXN* txn, DB* db, KEY* key_in
uint64_t cnt = 0;
char status_msg[MAX_ALIAS_NAME + 200]; //buffer of 200 should be a good upper bound.
THD* thd = ha_thd();
const char *old_proc_info = tokudb_thd_get_proc_info(thd);
memset(&key1, 0, sizeof(key1));
memset(&key2, 0, sizeof(key2));
memset(&val, 0, sizeof(val));
......@@ -3535,6 +3536,7 @@ int ha_tokudb::is_index_unique(bool* is_unique, DB_TXN* txn, DB* db, KEY* key_in
error = 0;
cleanup:
thd_proc_info(thd, old_proc_info);
if (tmp_cursor1) {
tmp_cursor1->c_close(tmp_cursor1);
tmp_cursor1 = NULL;
......@@ -7601,6 +7603,7 @@ int ha_tokudb::tokudb_add_index(
//
// status message to be shown in "show process list"
//
const char *old_proc_info = tokudb_thd_get_proc_info(thd);
char status_msg[MAX_ALIAS_NAME + 200]; //buffer of 200 should be a good upper bound.
ulonglong num_processed = 0; //variable that stores number of elements inserted thus far
thd_proc_info(thd, "Adding indexes");
......@@ -7921,6 +7924,7 @@ cleanup:
another transaction has accessed the table. \
To add indexes, make sure no transactions touch the table.", share->table_name);
}
thd_proc_info(thd, old_proc_info);
TOKUDB_HANDLER_DBUG_RETURN(error ? error : loader_error);
}
......
......@@ -263,7 +263,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("%s", share->table_name);
const char *old_proc_info = thd->proc_info;
const char *old_proc_info = tokudb_thd_get_proc_info(thd);
thd_proc_info(thd, "tokudb::check");
int result = HA_ADMIN_OK;
......
......@@ -489,4 +489,8 @@ static inline void tokudb_pthread_cond_broadcast(pthread_cond_t *cond) {
// mysql 5.6.15 removed the test macro, so we define our own
#define tokudb_test(e) ((e) ? 1 : 0)
static const char *tokudb_thd_get_proc_info(THD *thd) {
return thd->proc_info;
}
#endif // _TOKUDB_PORTABILITY_H
......@@ -1025,8 +1025,8 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) {
static void tokudb_checkpoint_lock(THD * thd) {
int error;
const char *old_proc_info;
tokudb_trx_data* trx = NULL;
char status_msg[200]; //buffer of 200 should be a good upper bound.
trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
if (!trx) {
error = create_tokudb_trx_data_instance(&trx);
......@@ -1044,10 +1044,11 @@ static void tokudb_checkpoint_lock(THD * thd) {
// This can only fail if environment is not created, which is not possible
// in handlerton
//
sprintf(status_msg, "Trying to grab checkpointing lock.");
thd_proc_info(thd, status_msg);
old_proc_info = tokudb_thd_get_proc_info(thd);
thd_proc_info(thd, "Trying to grab checkpointing lock.");
error = db_env->checkpointing_postpone(db_env);
assert(!error);
thd_proc_info(thd, old_proc_info);
trx->checkpoint_lock_taken = true;
cleanup:
......@@ -1056,7 +1057,7 @@ cleanup:
static void tokudb_checkpoint_unlock(THD * thd) {
int error;
char status_msg[200]; //buffer of 200 should be a good upper bound.
const char *old_proc_info;
tokudb_trx_data* trx = NULL;
trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
if (!trx) {
......@@ -1070,10 +1071,11 @@ static void tokudb_checkpoint_unlock(THD * thd) {
//
// at this point, we know the checkpoint lock has been taken
//
sprintf(status_msg, "Trying to release checkpointing lock.");
thd_proc_info(thd, status_msg);
old_proc_info = tokudb_thd_get_proc_info(thd);
thd_proc_info(thd, "Trying to release checkpointing lock.");
error = db_env->checkpointing_resume(db_env);
assert(!error);
thd_proc_info(thd, old_proc_info);
trx->checkpoint_lock_taken = false;
......
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