Skip to content
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
36 changes: 36 additions & 0 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,22 @@ static TYPELIB innodb_checksum_algorithm_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
};

/** Possible values for system variable "innodb_default_row_format". */
static const char* innodb_default_row_format_names[] = {
"redundant",
Expand Down Expand Up @@ -18492,6 +18508,24 @@ static MYSQL_SYSVAR_ENUM(checksum_algorithm, srv_checksum_algorithm,
NULL, NULL, SRV_CHECKSUM_ALGORITHM_CRC32,
&innodb_checksum_algorithm_typelib);

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"
" chooses between First-Come-First-Served and Eldest-Transaction-First.",
NULL, NULL, INNODB_LOCK_SCHEDULE_ALGORITHM_FCFS,
&innodb_lock_schedule_algorithm_typelib);


static MYSQL_SYSVAR_DOUBLE(vats_wait_lock_pct, innodb_vats_wait_lock_pct,
PLUGIN_VAR_RQCMDARG,
"Percentage of wait locks to trigger Eldest-Transaction-First.",
NULL, NULL, 0.0, 0, 99.999, 0);

static MYSQL_SYSVAR_BOOL(log_checksums, innodb_log_checksums,
PLUGIN_VAR_RQCMDARG,
"Whether to compute and require checksums for InnoDB redo log blocks",
Expand Down Expand Up @@ -19457,6 +19491,8 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(ft_sort_pll_degree),
MYSQL_SYSVAR(large_prefix),
MYSQL_SYSVAR(force_load_corrupted),
MYSQL_SYSVAR(lock_schedule_algorithm),
MYSQL_SYSVAR(vats_wait_lock_pct),
MYSQL_SYSVAR(locks_unsafe_for_binlog),
MYSQL_SYSVAR(lock_wait_timeout),
MYSQL_SYSVAR(page_size),
Expand Down
10 changes: 10 additions & 0 deletions storage/innobase/include/lock0lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ Created 5/7/1996 Heikki Tuuri
// Forward declaration
class ReadView;

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

extern ulong innodb_lock_schedule_algorithm;
extern double innodb_vats_wait_lock_pct;

/*********************************************************************//**
Gets the size of a lock struct.
@return size in bytes */
Expand Down
24 changes: 24 additions & 0 deletions storage/innobase/include/lock0priv.ic
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,30 @@ lock_rec_get_next_const(
return(lock_rec_get_next(heap_no, (lock_t*) lock));
}

/*********************************************************************//**
Gets the first explicit lock request on a record.
@return first lock, NULL if none exists */
UNIV_INLINE
lock_t*
lock_rec_get_first(
/*===============*/
hash_table_t* hash, /*!< in: hash chain the lock on */
ulint space_id, /*!< in: space id of the record */
ulint page_no, /*!< in: page number of the record */
ulint heap_no) /*!< in: heap number of the record */
{
ut_ad(lock_mutex_own());

for (lock_t* lock = lock_rec_get_first_on_page_addr(hash, space_id, page_no); lock;
lock = lock_rec_get_next_on_page(lock)) {
if (lock_rec_get_nth_bit(lock, heap_no)) {
return(lock);
}
}

return(NULL);
}

/*********************************************************************//**
Gets the first explicit lock request on a record.
@return first lock, NULL if none exists */
Expand Down
Loading