summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Prohaska <prohaska@tokutek.com>2014-02-07 12:58:10 -0500
committerRich Prohaska <prohaska@tokutek.com>2014-02-07 12:58:10 -0500
commitdfe4872524afa663d4e3b4928c9e70ec9f3e830d (patch)
tree94a1784b21e8906e40bb57e8051afe18f1340ad1
parentb7e362e48c46a2f31a49688bf7200ec5eb139ce0 (diff)
downloadmariadb-git-dfe4872524afa663d4e3b4928c9e70ec9f3e830d.tar.gz
#180 avoid thd_proc_info pointing to invalid info (like when a function sets proc info with a local variable and then returns)tokudb-7.1.5-rc.1
-rw-r--r--storage/tokudb/ha_tokudb.cc10
-rw-r--r--storage/tokudb/ha_tokudb_admin.cc2
-rw-r--r--storage/tokudb/hatoku_defines.h4
-rw-r--r--storage/tokudb/hatoku_hton.cc14
4 files changed, 20 insertions, 10 deletions
diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc
index d6f8d96c5ae..7c69ea5b0f7 100644
--- a/storage/tokudb/ha_tokudb.cc
+++ b/storage/tokudb/ha_tokudb.cc
@@ -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);
}
diff --git a/storage/tokudb/ha_tokudb_admin.cc b/storage/tokudb/ha_tokudb_admin.cc
index 47e13f93500..94f817fe66f 100644
--- a/storage/tokudb/ha_tokudb_admin.cc
+++ b/storage/tokudb/ha_tokudb_admin.cc
@@ -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;
diff --git a/storage/tokudb/hatoku_defines.h b/storage/tokudb/hatoku_defines.h
index 8471af1051a..65b9e960a6b 100644
--- a/storage/tokudb/hatoku_defines.h
+++ b/storage/tokudb/hatoku_defines.h
@@ -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
diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc
index 9a85e20bbd1..601b52bb65c 100644
--- a/storage/tokudb/hatoku_hton.cc
+++ b/storage/tokudb/hatoku_hton.cc
@@ -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;