Skip to content

Commit b09b316

Browse files
author
Jan Lindström
authored
Merge pull request #248 from sensssz/10.2-vats
MDEV-11039 - Add new scheduling algorithm for reducing tail latencies (for 10.2)
2 parents a1f0a33 + f6da2b4 commit b09b316

File tree

6 files changed

+468
-37
lines changed

6 files changed

+468
-37
lines changed

mysql-test/suite/sys_vars/r/sysvars_innodb.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,20 @@ NUMERIC_BLOCK_SIZE NULL
14471447
ENUM_VALUE_LIST OFF,ON
14481448
READ_ONLY YES
14491449
COMMAND_LINE_ARGUMENT NONE
1450+
VARIABLE_NAME INNODB_LOCK_SCHEDULE_ALGORITHM
1451+
SESSION_VALUE NULL
1452+
GLOBAL_VALUE fcfs
1453+
GLOBAL_VALUE_ORIGIN COMPILE-TIME
1454+
DEFAULT_VALUE fcfs
1455+
VARIABLE_SCOPE GLOBAL
1456+
VARIABLE_TYPE ENUM
1457+
VARIABLE_COMMENT 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.
1458+
NUMERIC_MIN_VALUE NULL
1459+
NUMERIC_MAX_VALUE NULL
1460+
NUMERIC_BLOCK_SIZE NULL
1461+
ENUM_VALUE_LIST fcfs,vats
1462+
READ_ONLY NO
1463+
COMMAND_LINE_ARGUMENT REQUIRED
14501464
VARIABLE_NAME INNODB_LOCK_WAIT_TIMEOUT
14511465
SESSION_VALUE 50
14521466
GLOBAL_VALUE 50

storage/innobase/handler/ha_innodb.cc

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,22 @@ static TYPELIB innodb_default_row_format_typelib = {
379379
NULL
380380
};
381381

382+
/** Possible values of the parameter innodb_lock_schedule_algorithm */
383+
static const char* innodb_lock_schedule_algorithm_names[] = {
384+
"fcfs",
385+
"vats",
386+
NullS
387+
};
388+
389+
/** Used to define an enumerate type of the system variable
390+
innodb_lock_schedule_algorithm. */
391+
static TYPELIB innodb_lock_schedule_algorithm_typelib = {
392+
array_elements(innodb_lock_schedule_algorithm_names) - 1,
393+
"innodb_lock_schedule_algorithm_typelib",
394+
innodb_lock_schedule_algorithm_names,
395+
NULL
396+
};
397+
382398
/* The following counter is used to convey information to InnoDB
383399
about server activity: in case of normal DML ops it is not
384400
sensible to call srv_active_wake_master_thread after each
@@ -1671,7 +1687,7 @@ thd_is_replication_slave_thread(
16711687
/*============================*/
16721688
THD* thd) /*!< in: thread handle */
16731689
{
1674-
return((ibool) thd_slave_thread(thd));
1690+
return thd && ((ibool) thd_slave_thread(thd));
16751691
}
16761692

16771693
/******************************************************************//**
@@ -22783,6 +22799,18 @@ static MYSQL_SYSVAR_ULONG(doublewrite_batch_size, srv_doublewrite_batch_size,
2278322799
NULL, NULL, 120, 1, 127, 0);
2278422800
#endif /* defined UNIV_DEBUG || defined UNIV_PERF_DEBUG */
2278522801

22802+
static MYSQL_SYSVAR_ENUM(lock_schedule_algorithm, innodb_lock_schedule_algorithm,
22803+
PLUGIN_VAR_RQCMDARG,
22804+
"The algorithm Innodb uses for deciding which locks to grant next when"
22805+
" a lock is released. Possible values are"
22806+
" FCFS"
22807+
" grant the locks in First-Come-First-Served order;"
22808+
" VATS"
22809+
" use the Variance-Aware-Transaction-Scheduling algorithm, which"
22810+
" uses an Eldest-Transaction-First heuristic.",
22811+
NULL, NULL, INNODB_LOCK_SCHEDULE_ALGORITHM_FCFS,
22812+
&innodb_lock_schedule_algorithm_typelib);
22813+
2278622814
static MYSQL_SYSVAR_ULONG(buffer_pool_instances, srv_buf_pool_instances,
2278722815
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
2278822816
"Number of buffer pool instances, set to higher value on high-end machines to increase scalability",
@@ -23656,6 +23684,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
2365623684
MYSQL_SYSVAR(ft_sort_pll_degree),
2365723685
MYSQL_SYSVAR(large_prefix),
2365823686
MYSQL_SYSVAR(force_load_corrupted),
23687+
MYSQL_SYSVAR(lock_schedule_algorithm),
2365923688
MYSQL_SYSVAR(locks_unsafe_for_binlog),
2366023689
MYSQL_SYSVAR(lock_wait_timeout),
2366123690
MYSQL_SYSVAR(page_size),

storage/innobase/include/lock0lock.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ Created 5/7/1996 Heikki Tuuri
4040
#include "gis0rtree.h"
4141
#include "lock0prdt.h"
4242

43+
/** Alternatives for innodb_lock_schedule_algorithm, which can be changed by
44+
setting innodb_lock_schedule_algorithm. */
45+
enum innodb_lock_schedule_algorithm_t {
46+
/*!< First Come First Served */
47+
INNODB_LOCK_SCHEDULE_ALGORITHM_FCFS,
48+
/*!< Variance-Aware-Transaction-Scheduling */
49+
INNODB_LOCK_SCHEDULE_ALGORITHM_VATS
50+
};
51+
52+
extern ulong innodb_lock_schedule_algorithm;
53+
4354
// Forward declaration
4455
class ReadView;
4556

storage/innobase/include/trx0trx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,8 @@ struct trx_t {
10961096

10971097
time_t start_time; /*!< time the state last time became
10981098
TRX_STATE_ACTIVE */
1099+
clock_t start_time_micro; /*!< start time of the transaction
1100+
in microseconds. */
10991101
lsn_t commit_lsn; /*!< lsn at the time of the commit */
11001102
table_id_t table_id; /*!< Table to drop iff dict_operation
11011103
== TRX_DICT_OP_TABLE, or 0. */

0 commit comments

Comments
 (0)