Commit f140ba9f authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:2983], add session variable tokudb_checkpoint_lock, remove code that runs...

[t:2983], add session variable tokudb_checkpoint_lock, remove code that runs when checkpoint_lock and checkpoint_unlock are executed, we can now remove checkpoint_lock and checkpoint_unlock grammar changes

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@24824 c7de825b-a66e-492c-adef-691d508d4ae1
parent 52bd7437
...@@ -106,6 +106,36 @@ static MYSQL_THDVAR_BOOL(prelock_empty, ...@@ -106,6 +106,36 @@ static MYSQL_THDVAR_BOOL(prelock_empty,
TRUE TRUE
); );
void tokudb_checkpoint_lock(THD * thd);
void tokudb_checkpoint_unlock(THD * thd);
static
void
tokudb_checkpoint_lock_update(
THD* thd,
struct st_mysql_sys_var* var,
void* var_ptr,
const void* save)
{
printf("Hello update!\n");
my_bool* val = (my_bool *) var_ptr;
*val= *(my_bool *) save ? TRUE : FALSE;
if (*val) {
tokudb_checkpoint_lock(thd);
}
else {
tokudb_checkpoint_unlock(thd);
}
}
static MYSQL_THDVAR_BOOL(checkpoint_lock,
0,
"Tokudb Checkpoint Lock",
NULL,
tokudb_checkpoint_lock_update,
FALSE
);
static void tokudb_print_error(const DB_ENV * db_env, const char *db_errpfx, const char *buffer); static void tokudb_print_error(const DB_ENV * db_env, const char *db_errpfx, const char *buffer);
static void tokudb_cleanup_log_files(void); static void tokudb_cleanup_log_files(void);
...@@ -1120,59 +1150,56 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) { ...@@ -1120,59 +1150,56 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) {
} }
int tokudb_checkpoint_lock(THD * thd, stat_print_fn * stat_print) { void tokudb_checkpoint_lock(THD * thd) {
int error; int error;
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) {
error = create_tokudb_trx_data_instance(&trx); error = create_tokudb_trx_data_instance(&trx);
if (error) { goto cleanup; } //
// can only fail due to memory allocation, so ok to assert
//
assert(!error);
thd_data_set(thd, tokudb_hton->slot, trx); thd_data_set(thd, tokudb_hton->slot, trx);
} }
if (trx->checkpoint_lock_taken) { if (trx->checkpoint_lock_taken) {
STATPRINT("checkpoint lock", "Lock already taken");
error = 0;
goto cleanup; goto cleanup;
} }
//
// This can only fail if environment is not created, which is not possible
// in handlerton
//
error = db_env->checkpointing_postpone(db_env); error = db_env->checkpointing_postpone(db_env);
if (error) { goto cleanup; } assert(!error);
trx->checkpoint_lock_taken = true; trx->checkpoint_lock_taken = true;
STATPRINT("checkpoint lock", "Lock successfully taken");
error = 0;
cleanup: cleanup:
if (error) { my_errno = error; } return;
return error;
} }
int tokudb_checkpoint_unlock(THD * thd, stat_print_fn * stat_print) { void tokudb_checkpoint_unlock(THD * thd) {
int error; int error;
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) {
error = 0; error = 0;
STATPRINT("checkpoint unlock", "Lock never taken");
goto cleanup; goto cleanup;
} }
if (!trx->checkpoint_lock_taken) { if (!trx->checkpoint_lock_taken) {
error = 0; error = 0;
STATPRINT("checkpoint unlock", "Lock never taken");
goto cleanup; goto cleanup;
} }
// //
// at this point, we know the checkpoint lock has been taken // at this point, we know the checkpoint lock has been taken
// //
error = db_env->checkpointing_resume(db_env); error = db_env->checkpointing_resume(db_env);
if (error) {goto cleanup;} assert(!error);
trx->checkpoint_lock_taken = false; trx->checkpoint_lock_taken = false;
STATPRINT("checkpoint unlock", "Successfully unlocked");
cleanup: cleanup:
if (error) { my_errno = error; } return;
return error;
} }
...@@ -1183,14 +1210,6 @@ bool tokudb_show_status(handlerton * hton, THD * thd, stat_print_fn * stat_print ...@@ -1183,14 +1210,6 @@ bool tokudb_show_status(handlerton * hton, THD * thd, stat_print_fn * stat_print
case HA_ENGINE_STATUS: case HA_ENGINE_STATUS:
return tokudb_show_engine_status(thd, stat_print); return tokudb_show_engine_status(thd, stat_print);
break; break;
#if TOKU_INCLUDE_CHECKPOINT_LOCK
case HA_ENGINE_CHECKPOINT_LOCK:
return tokudb_checkpoint_lock(thd, stat_print);
break;
case HA_ENGINE_CHECKPOINT_UNLOCK:
return tokudb_checkpoint_unlock(thd, stat_print);
break;
#endif
default: default:
break; break;
} }
...@@ -1323,6 +1342,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = { ...@@ -1323,6 +1342,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = {
MYSQL_SYSVAR(init_flags), MYSQL_SYSVAR(init_flags),
MYSQL_SYSVAR(checkpointing_period), MYSQL_SYSVAR(checkpointing_period),
MYSQL_SYSVAR(prelock_empty), MYSQL_SYSVAR(prelock_empty),
MYSQL_SYSVAR(checkpoint_lock),
MYSQL_SYSVAR(write_status_frequency), MYSQL_SYSVAR(write_status_frequency),
MYSQL_SYSVAR(read_status_frequency), MYSQL_SYSVAR(read_status_frequency),
MYSQL_SYSVAR(fs_reserve_percent), MYSQL_SYSVAR(fs_reserve_percent),
......
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