Commit 5bc6c88d authored by Rich Prohaska's avatar Rich Prohaska

Merge branch 'master' into releases/tokudb-7.5

parents dc98e6eb 25c152b0
set default_storage_engine='tokudb';
drop table if exists t;
create table t (a int, b int, c int, primary key(a), key(b), key(c));
set tokudb_optimize_index_name='primary';
optimize table t;
Table Op Msg_type Msg_text
test.t optimize status OK
set tokudb_optimize_index_name='b';
optimize table t;
Table Op Msg_type Msg_text
test.t optimize status OK
set tokudb_optimize_index_name='c';
optimize table t;
Table Op Msg_type Msg_text
test.t optimize status OK
drop table t;
# test tokudb_optimize_index_name session variable
set default_storage_engine='tokudb';
source include/have_tokudb.inc;
disable_warnings;
drop table if exists t;
enable_warnings;
create table t (a int, b int, c int, primary key(a), key(b), key(c));
# optimize primary key
set tokudb_optimize_index_name='primary';
optimize table t;
# optimize key b
set tokudb_optimize_index_name='b';
optimize table t;
# optimize key c
set tokudb_optimize_index_name='c';
optimize table t;
drop table t;
......@@ -131,11 +131,20 @@ function parse_mysqlbuild() {
tokudb_version=${BASH_REMATCH[6]}
target_system=${BASH_REMATCH[7]}
target_arch=${BASH_REMATCH[8]}
# verify targets
if [ $target_system != $system ] ; then exitcode=1; fi
if [ $target_arch != $arch ] ; then exitcode=1; fi
# split the version string into major.minor.patch
if [[ $mysql_version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+.*) ]] ; then
mysql_version_major=${BASH_REMATCH[1]}
mysql_version_minor=${BASH_REMATCH[2]}
mysql_version_patch=${BASH_REMATCH[3]}
fi
local temp_tokudb_version=$tokudb_version
# decode enterprise
if [[ $temp_tokudb_version =~ (.*)-e$ ]] ; then
build_type=enterprise
......@@ -143,6 +152,7 @@ function parse_mysqlbuild() {
else
build_type=community
fi
# decode debug
if [[ $temp_tokudb_version =~ (.*)-debug$ ]] ; then
build_debug=1
......@@ -151,6 +161,7 @@ function parse_mysqlbuild() {
else
build_debug=0
fi
# set tag or HEAD
if [[ $temp_tokudb_version =~ ^([0-9]+)\\.([0-9]+)\\.([0-9]+) ]] ; then
git_tag=tokudb-$temp_tokudb_version
......@@ -160,6 +171,8 @@ function parse_mysqlbuild() {
if [ -z $mysql_tree ] ; then mysql_tree=$mysql_distro-$mysql_version; fi
if [ -z $jemalloc_tree ] ; then jemalloc_tree=$jemalloc_version; fi
fi
# set repository
mysql_repo=$mysql_distro
if [[ $mysql_version =~ ^([0-9]+\.[0-9]+) ]] ; then mysql_repo=$mysql_distro-${BASH_REMATCH[1]}; else exitcode=1; fi
else
......@@ -174,6 +187,15 @@ function parse_mysql() {
if [[ $mysql =~ ^(mysql|mariadb)-(.*)$ ]] ; then
mysql_distro=${BASH_REMATCH[1]}
mysql_version=${BASH_REMATCH[2]}
# split the version string into major.minor.patch
if [[ $mysql_version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+.*) ]] ; then
mysql_version_major=${BASH_REMATCH[1]}
mysql_version_minor=${BASH_REMATCH[2]}
mysql_version_patch=${BASH_REMATCH[3]}
fi
# set repository
mysql_repo=$mysql_distro
if [[ $mysql_version =~ ^([0-9]+\.[0-9]+) ]] ; then mysql_repo=$mysql_distro-${BASH_REMATCH[1]}; else exitcode=1; fi
exitcode=0
......
......@@ -103,10 +103,22 @@ fi
cd $mysql_distro-$mysql_version
if [ $? != 0 ] ; then exit 1; fi
# extract mysql version patch number only
if [[ $mysql_version_patch =~ ^([0-9]+) ]] ; then p=${BASH_REMATCH[1]}; else p=$mysql_version_patch; fi
# install the backup source
if [ ! -d toku_backup ] ; then
tokudb_backup=
if [ $mysql_version_major -eq 5 -a $mysql_version_minor -eq 5 -a $p -le 40 ] ; then
tokudb_backup=patch
github_download Tokutek/backup-$build_type $(git_tree $git_tag $backup_tree) backup-$build_type
cp -r backup-$build_type/backup toku_backup
elif [ $build_type = enterprise ] ; then
tokudb_backup=plugin
github_download Tokutek/tokudb-backup-plugin $(git_tree $git_tag $backup_tree) tokudb-backup-plugin
mv tokudb-backup-plugin plugin
github_download Tokutek/backup-enterprise $(git_tree $git_tag $backup_tree) backup-enterprise
mv backup-enterprise/backup plugin/tokudb-backup-plugin
rm -rf backup-enterprise
fi
if [ ! -d tokudb-engine ] ; then
......@@ -153,6 +165,7 @@ function generate_cmake_cmd () {
echo -n CC=$cc CXX=$cxx cmake \
-D BUILD_CONFIG=mysql_release \
-D MYSQL_MAINTAINER_MODE=OFF \
-D CMAKE_BUILD_TYPE=$cmake_build_type \
-D CMAKE_TOKUDB_REVISION=$ft_revision \
-D TOKUDB_VERSION=tokudb-${tokudb_version} \
......
......@@ -55,7 +55,7 @@ function github_clone() {
git_tag=
mysql=mysql-5.5
mysql_tree=mysql-5.5.35
mysql_tree=mysql-5.5.41
jemalloc=jemalloc
jemalloc_tree=3.6.0
tokudbengine=tokudb-engine
......@@ -148,13 +148,15 @@ fi
pushd $build_dir
if [ $? != 0 ] ; then exit 1; fi
extra_cmake_options="-DCMAKE_LINK_DEPENDS_NO_SHARED=ON"
extra_cmake_options+=" -DBUILD_TESTING=OFF"
extra_cmake_options+=" -DMYSQL_MAINTAINER_MODE=OFF"
if (( $cmake_valgrind )) ; then
extra_cmake_options+=" -DUSE_VALGRIND=ON"
fi
if (( $cmake_debug_paranoid )) ; then
extra_cmake_options+=" -DTOKU_DEBUG_PARANOID=ON"
fi
CC=$cc CXX=$cxx cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$install_dir -DBUILD_TESTING=OFF $extra_cmake_options ../$mysql_tree
CC=$cc CXX=$cxx cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$install_dir $extra_cmake_options ../$mysql_tree
if [ $? != 0 ] ; then exit 1; fi
make -j4 install
if [ $? != 0 ] ; then exit 1; fi
......
......@@ -7258,7 +7258,7 @@ double ha_tokudb::index_only_read_time(uint keynr, double records) {
// HA_POS_ERROR - Something is wrong with the index tree
//
ha_rows ha_tokudb::records_in_range(uint keynr, key_range* start_key, key_range* end_key) {
TOKUDB_HANDLER_DBUG_ENTER("");
TOKUDB_HANDLER_DBUG_ENTER("%d %p %p", keynr, start_key, end_key);
DBT *pleft_key, *pright_key;
DBT left_key, right_key;
ha_rows ret_val = HA_TOKUDB_RANGE_COUNT;
......@@ -7314,6 +7314,9 @@ ha_rows ha_tokudb::records_in_range(uint keynr, key_range* start_key, key_range*
ret_val = (ha_rows) (rows <= 1 ? 1 : rows);
cleanup:
if (tokudb_debug & TOKUDB_DEBUG_RETURN) {
TOKUDB_HANDLER_TRACE("%" PRIu64 " %" PRIu64, (uint64_t) ret_val, rows);
}
DBUG_RETURN(ret_val);
}
......
......@@ -89,6 +89,8 @@ PATENT RIGHTS GRANT:
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include "toku_time.h"
struct analyze_progress_extra {
THD *thd;
TOKUDB_SHARE *share;
......@@ -186,9 +188,12 @@ typedef struct hot_optimize_context {
uint progress_stage;
uint current_table;
uint num_tables;
float progress_limit;
uint64_t progress_last_time;
uint64_t throttle;
} *HOT_OPTIMIZE_CONTEXT;
static int hot_poll_fun(void *extra, float progress) {
static int hot_optimize_progress_fun(void *extra, float progress) {
HOT_OPTIMIZE_CONTEXT context = (HOT_OPTIMIZE_CONTEXT)extra;
if (thd_killed(context->thd)) {
sprintf(context->write_status_msg, "The process has been killed, aborting hot optimize.");
......@@ -207,14 +212,27 @@ static int hot_poll_fun(void *extra, float progress) {
// the percentage we report here is for the current stage/db
thd_progress_report(context->thd, (unsigned long long) percentage, 100);
#endif
return 0;
// throttle the optimize table
if (context->throttle) {
uint64_t time_now = toku_current_time_microsec();
uint64_t dt = time_now - context->progress_last_time;
uint64_t throttle_time = 1000000ULL / context->throttle;
if (throttle_time > dt) {
usleep(throttle_time - dt);
}
context->progress_last_time = toku_current_time_microsec();
}
// return 1 if progress has reach the progress limit
return progress >= context->progress_limit;
}
// flatten all DB's in this table, to do so, peform hot optimize on each db
int ha_tokudb::do_optimize(THD *thd) {
TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name);
int error = 0;
const char *orig_proc_info = tokudb_thd_get_proc_info(thd);
int error;
uint curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key);
#ifdef HA_TOKUDB_HAS_THD_PROGRESS
......@@ -225,11 +243,21 @@ int ha_tokudb::do_optimize(THD *thd) {
// for each DB, run optimize and hot_optimize
for (uint i = 0; i < curr_num_DBs; i++) {
// only optimize the index if it matches the optimize_index_name session variable
const char *optimize_index_name = THDVAR(thd, optimize_index_name);
if (optimize_index_name) {
const char *this_index_name = i >= table_share->keys ? "primary" : table_share->key_info[i].name;
if (strcasecmp(optimize_index_name, this_index_name) != 0) {
continue;
}
}
DB* db = share->key_file[i];
error = db->optimize(db);
if (error) {
goto cleanup;
}
struct hot_optimize_context hc;
memset(&hc, 0, sizeof hc);
hc.thd = thd;
......@@ -237,8 +265,11 @@ int ha_tokudb::do_optimize(THD *thd) {
hc.ha = this;
hc.current_table = i;
hc.num_tables = curr_num_DBs;
hc.progress_limit = THDVAR(thd, optimize_index_fraction);
hc.progress_last_time = toku_current_time_microsec();
hc.throttle = THDVAR(thd, optimize_throttle);
uint64_t loops_run;
error = db->hot_optimize(db, NULL, NULL, hot_poll_fun, &hc, &loops_run);
error = db->hot_optimize(db, NULL, NULL, hot_optimize_progress_fun, &hc, &loops_run);
if (error) {
goto cleanup;
}
......
......@@ -161,6 +161,9 @@ PATENT RIGHTS GRANT:
#define TOKU_INCLUDE_UPSERT 1
#if defined(MARIADB_BASE_VERSION)
#define TOKU_INCLUDE_EXTENDED_KEYS 1
#define TOKU_INCLUDE_LOCK_TIMEOUT_QUERY_STRING 1
#else
#define TOKU_INCLUDE_LOCK_TIMEOUT_QUERY_STRING 1
#endif
#define TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL 0
......
......@@ -1390,8 +1390,6 @@ static MYSQL_SYSVAR_STR(data_dir, tokudb_data_dir, PLUGIN_VAR_READONLY, "TokuDB
static MYSQL_SYSVAR_STR(version, tokudb_version, PLUGIN_VAR_READONLY, "TokuDB Version", NULL, NULL, NULL);
static MYSQL_SYSVAR_UINT(init_flags, tokudb_init_flags, PLUGIN_VAR_READONLY, "Sets TokuDB DB_ENV->open flags", NULL, NULL, tokudb_init_flags, 0, ~0U, 0);
static MYSQL_SYSVAR_UINT(write_status_frequency, tokudb_write_status_frequency, 0, "TokuDB frequency that show processlist updates status of writes", NULL, NULL, 1000, 0, ~0U, 0);
static MYSQL_SYSVAR_UINT(read_status_frequency, tokudb_read_status_frequency, 0, "TokuDB frequency that show processlist updates status of reads", NULL, NULL, 10000, 0, ~0U, 0);
static MYSQL_SYSVAR_INT(fs_reserve_percent, tokudb_fs_reserve_percent, PLUGIN_VAR_READONLY, "TokuDB file system space reserve (percent free required)", NULL, NULL, 5, 0, 100, 0);
......@@ -1428,7 +1426,6 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = {
MYSQL_SYSVAR(create_index_online),
MYSQL_SYSVAR(disable_prefetching),
MYSQL_SYSVAR(version),
MYSQL_SYSVAR(init_flags),
MYSQL_SYSVAR(checkpointing_period),
MYSQL_SYSVAR(prelock_empty),
MYSQL_SYSVAR(checkpoint_lock),
......@@ -1469,6 +1466,9 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = {
MYSQL_SYSVAR(rpl_unique_checks_delay),
MYSQL_SYSVAR(rpl_lookup_rows),
MYSQL_SYSVAR(rpl_lookup_rows_delay),
MYSQL_SYSVAR(optimize_index_name),
MYSQL_SYSVAR(optimize_index_fraction),
MYSQL_SYSVAR(optimize_throttle),
NULL
};
......@@ -1961,6 +1961,33 @@ static int tokudb_fractal_tree_block_map_done(void *p) {
return 0;
}
#if TOKU_INCLUDE_LOCK_TIMEOUT_QUERY_STRING
struct tokudb_search_txn_extra {
bool match_found;
uint64_t match_txn_id;
uint64_t match_client_id;
};
static int tokudb_search_txn_callback(uint64_t txn_id, uint64_t client_id, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) {
struct tokudb_search_txn_extra *e = reinterpret_cast<struct tokudb_search_txn_extra *>(extra);
if (e->match_txn_id == txn_id) {
e->match_found = true;
e->match_client_id = client_id;
return 1;
}
return 0;
}
static bool tokudb_txn_id_to_client_id(THD *thd, uint64_t blocking_txnid, uint64_t *blocking_client_id) {
struct tokudb_search_txn_extra e = { false, blocking_txnid, 0};
(void) db_env->iterate_live_transactions(db_env, tokudb_search_txn_callback, &e);
if (e.match_found) {
*blocking_client_id = e.match_client_id;
}
return e.match_found;
}
#endif
static void tokudb_pretty_key(const DB *db, const DBT *key, const char *default_key, String *out) {
if (key->data == NULL) {
out->append(default_key);
......@@ -2010,8 +2037,9 @@ static void tokudb_lock_timeout_callback(DB *db, uint64_t requesting_txnid, cons
// generate a JSON document with the lock timeout info
String log_str;
log_str.append("{");
uint64_t mysql_thread_id = thd->thread_id;
log_str.append("\"mysql_thread_id\":");
log_str.append_ulonglong(thd->thread_id);
log_str.append_ulonglong(mysql_thread_id);
log_str.append(", \"dbname\":");
log_str.append("\""); log_str.append(tokudb_get_index_name(db)); log_str.append("\"");
log_str.append(", \"requesting_txnid\":");
......@@ -2051,7 +2079,18 @@ static void tokudb_lock_timeout_callback(DB *db, uint64_t requesting_txnid, cons
}
// dump to stderr
if (lock_timeout_debug & 2) {
sql_print_error("%s: %s", tokudb_hton_name, log_str.c_ptr());
sql_print_error("%s: lock timeout %s", tokudb_hton_name, log_str.c_ptr());
LEX_STRING *qs = thd_query_string(thd);
sql_print_error("%s: requesting_thread_id:%" PRIu64 " q:%.*s", tokudb_hton_name, mysql_thread_id, (int) qs->length, qs->str);
#if TOKU_INCLUDE_LOCK_TIMEOUT_QUERY_STRING
uint64_t blocking_thread_id = 0;
if (tokudb_txn_id_to_client_id(thd, blocking_txnid, &blocking_thread_id)) {
String blocking_qs;
if (get_thread_query_string(blocking_thread_id, blocking_qs) == 0) {
sql_print_error("%s: blocking_thread_id:%" PRIu64 " q:%.*s", tokudb_hton_name, blocking_thread_id, blocking_qs.length(), blocking_qs.c_ptr());
}
}
#endif
}
}
}
......
......@@ -545,6 +545,12 @@ static MYSQL_THDVAR_BOOL(rpl_lookup_rows, PLUGIN_VAR_THDLOCAL, "lookup a row on
static MYSQL_THDVAR_ULONGLONG(rpl_lookup_rows_delay, PLUGIN_VAR_THDLOCAL, "time in milliseconds to add to lookups on replication slave",
NULL, NULL, 0 /*default*/, 0 /*min*/, ~0ULL /*max*/, 1 /*blocksize*/);
static MYSQL_THDVAR_STR(optimize_index_name, PLUGIN_VAR_THDLOCAL + PLUGIN_VAR_MEMALLOC, "optimize index name (default all indexes)", NULL /*check*/, NULL /*update*/, NULL /*default*/);
static MYSQL_THDVAR_DOUBLE(optimize_index_fraction, 0, "optimize index fraction (default 1.0 all)", NULL /*check*/, NULL /*update*/, 1.0 /*def*/, 0 /*min*/, 1.0 /*max*/, 1);
static MYSQL_THDVAR_ULONGLONG(optimize_throttle, 0, "optimize throttle (default no throttle)", NULL /*check*/, NULL /*update*/, 0 /*def*/, 0 /*min*/, ~0ULL /*max*/, 1);
extern HASH tokudb_open_tables;
extern pthread_mutex_t tokudb_mutex;
extern uint32_t tokudb_write_status_frequency;
......
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