Skip to content

New version of the VATS algorithm (Largest Dependency Set First) #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mysql-test/suite/perfschema/r/show_sanity.result
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ order by show_mode, source, variable_name;
SHOW_MODE SOURCE VARIABLE_NAME
5.6 I_S.SESSION_VARIABLES GTID_EXECUTED
5.6 I_S.SESSION_VARIABLES INNODB_DEADLOCK_DETECT
5.6 I_S.SESSION_VARIABLES INNODB_LOCK_SCHEDULE_ALGORITHM
5.6 I_S.SESSION_VARIABLES INNODB_STATS_INCLUDE_DELETE_MARKED
5.6 I_S.SESSION_VARIABLES LOG_STATEMENTS_UNSAFE_FOR_BINLOG
5.6 I_S.SESSION_VARIABLES TLS_VERSION
Expand All @@ -434,6 +435,7 @@ order by show_mode, source, variable_name;
SHOW_MODE SOURCE VARIABLE_NAME
5.6 I_S.SESSION_VARIABLES GTID_EXECUTED
5.6 I_S.SESSION_VARIABLES INNODB_DEADLOCK_DETECT
5.6 I_S.SESSION_VARIABLES INNODB_LOCK_SCHEDULE_ALGORITHM
5.6 I_S.SESSION_VARIABLES INNODB_STATS_INCLUDE_DELETE_MARKED
5.6 I_S.SESSION_VARIABLES LOG_STATEMENTS_UNSAFE_FOR_BINLOG
5.6 I_S.SESSION_VARIABLES TLS_VERSION
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SELECT @@global.innodb_lock_schedule_algorithm;
@@global.innodb_lock_schedule_algorithm
fcfs
SET GLOBAL innodb_lock_schedule_algorithm = 'FCFS';
SELECT @@global.innodb_lock_schedule_algorithm;
@@global.innodb_lock_schedule_algorithm
fcfs
SET GLOBAL innodb_lock_schedule_algorithm = 'VATS';
SELECT @@global.innodb_lock_schedule_algorithm;
@@global.innodb_lock_schedule_algorithm
vats
SET GLOBAL innodb_lock_schedule_algorithm = 'FCFS';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- source include/have_innodb.inc
# This is a debug variable for now
-- source include/have_debug.inc

SELECT @@global.innodb_lock_schedule_algorithm;

SET GLOBAL innodb_lock_schedule_algorithm = 'FCFS';

SELECT @@global.innodb_lock_schedule_algorithm;

SET GLOBAL innodb_lock_schedule_algorithm = 'VATS';

SELECT @@global.innodb_lock_schedule_algorithm;

# Reset state
SET GLOBAL innodb_lock_schedule_algorithm = 'FCFS';
33 changes: 31 additions & 2 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,22 @@ static TYPELIB innodb_default_row_format_typelib = {
NULL
};

/** Possible values of the parameter innodb_lock_schedule_algorithm */
static const char* innodb_lock_schedule_algorithm_names[] = {
"fcfs",
"vats",
NullS
};

/** Used to define an enumerate type of the system variable
innodb_lock_schedule_algorithm. */
static TYPELIB innodb_lock_schedule_algorithm_typelib = {
array_elements(innodb_lock_schedule_algorithm_names) - 1,
"innodb_lock_schedule_algorithm_typelib",
innodb_lock_schedule_algorithm_names,
NULL
};

/* The following counter is used to convey information to InnoDB
about server activity: in case of normal DML ops it is not
sensible to call srv_active_wake_master_thread after each
Expand Down Expand Up @@ -1364,7 +1380,7 @@ thd_is_replication_slave_thread(
/*============================*/
THD* thd) /*!< in: thread handle */
{
return((ibool) thd_slave_thread(thd));
return(thd && (ibool) thd_slave_thread(thd));
}

/******************************************************************//**
Expand Down Expand Up @@ -19528,6 +19544,18 @@ static MYSQL_SYSVAR_ULONG(doublewrite_batch_size, srv_doublewrite_batch_size,
NULL, NULL, 120, 1, 127, 0);
#endif /* defined UNIV_DEBUG || defined UNIV_PERF_DEBUG */

static MYSQL_SYSVAR_ENUM(lock_schedule_algorithm, innodb_lock_schedule_algorithm,
PLUGIN_VAR_RQCMDARG,
"The algorithm Innodb uses for deciding which locks to grant next when"
" a lock is released. Possible values are"
" FCFS"
" grant the locks in First-Come-First-Served order;"
" VATS"
" use the Variance-Aware-Transaction-Scheduling algorithm, which"
" uses an Eldest-Transaction-First heuristic.",
NULL, NULL, INNODB_LOCK_SCHEDULE_ALGORITHM_FCFS,
&innodb_lock_schedule_algorithm_typelib);

static MYSQL_SYSVAR_ULONG(buffer_pool_instances, srv_buf_pool_instances,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Number of buffer pool instances, set to higher value on high-end machines to increase scalability",
Expand Down Expand Up @@ -20131,7 +20159,8 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(ft_num_word_optimize),
MYSQL_SYSVAR(ft_sort_pll_degree),
MYSQL_SYSVAR(large_prefix),
MYSQL_SYSVAR(force_load_corrupted),
MYSQL_SYSVAR(force_load_corrupted),
MYSQL_SYSVAR(lock_schedule_algorithm),
MYSQL_SYSVAR(locks_unsafe_for_binlog),
MYSQL_SYSVAR(lock_wait_timeout),
MYSQL_SYSVAR(deadlock_detect),
Expand Down
11 changes: 11 additions & 0 deletions storage/innobase/include/lock0lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ class ReadView;

extern my_bool innobase_deadlock_detect;

/** Alternatives for innodb_lock_schedule_algorithm, which can be changed by
setting innodb_lock_schedule_algorithm. */
enum innodb_lock_schedule_algorithm_t {
/*!< First Come First Served */
INNODB_LOCK_SCHEDULE_ALGORITHM_FCFS,
/*!< Variance-Aware-Transaction-Scheduling */
INNODB_LOCK_SCHEDULE_ALGORITHM_VATS
};

extern ulong innodb_lock_schedule_algorithm;

/*********************************************************************//**
Gets the size of a lock struct.
@return size in bytes */
Expand Down
3 changes: 3 additions & 0 deletions storage/innobase/include/trx0trx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,9 @@ struct trx_t {

time_t start_time; /*!< time the state last time became
TRX_STATE_ACTIVE */
long dep_size;
bool size_updated;
long seq;
lsn_t commit_lsn; /*!< lsn at the time of the commit */
table_id_t table_id; /*!< Table to drop iff dict_operation
== TRX_DICT_OP_TABLE, or 0. */
Expand Down
Loading