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