Commit db006a9a authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-21452: Remove os_event_t, MUTEX_EVENT, TTASEventMutex, sync_array

We will default to MUTEXTYPE=sys (using OSTrackMutex) for those
ib_mutex_t that have not been replaced yet.

The view INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS is removed.

The parameter innodb_sync_array_size is removed.

FIXME: innodb_fatal_semaphore_wait_threshold will no longer be enforced.
We should enforce it for lock_sys.mutex and dict_sys.mutex somehow!

innodb_sync_debug=ON might still cover ib_mutex_t.
parent 38fd7b7d
......@@ -50,8 +50,6 @@ create sql security invoker view i_sys_foreign_cols as select * from information
create sql security definer view d_sys_foreign_cols as select * from information_schema.innodb_sys_foreign_cols;
create sql security invoker view i_sys_indexes as select * from information_schema.innodb_sys_indexes;
create sql security definer view d_sys_indexes as select * from information_schema.innodb_sys_indexes;
create sql security invoker view i_sys_semaphore_waits as select * from information_schema.innodb_sys_semaphore_waits;
create sql security definer view d_sys_semaphore_waits as select * from information_schema.innodb_sys_semaphore_waits;
create sql security invoker view i_sys_tables as select * from information_schema.innodb_sys_tables;
create sql security definer view d_sys_tables as select * from information_schema.innodb_sys_tables;
create sql security invoker view i_sys_tablespaces as select * from information_schema.innodb_sys_tablespaces;
......@@ -222,13 +220,6 @@ ERROR 42000: Access denied; you need (at least one of) the PROCESS privilege(s)
select count(*) > -1 from d_sys_indexes;
count(*) > -1
1
select count(*) > -1 from information_schema.innodb_sys_semaphore_waits;
ERROR 42000: Access denied; you need (at least one of) the PROCESS privilege(s) for this operation
select count(*) > -1 from i_sys_semaphore_waits;
ERROR 42000: Access denied; you need (at least one of) the PROCESS privilege(s) for this operation
select count(*) > -1 from d_sys_semaphore_waits;
count(*) > -1
1
select count(*) > -1 from information_schema.innodb_sys_tables;
ERROR 42000: Access denied; you need (at least one of) the PROCESS privilege(s) for this operation
select count(*) > -1 from i_sys_tables;
......
......@@ -363,7 +363,3 @@ select * from information_schema.innodb_tablespaces_encryption;
SPACE NAME ENCRYPTION_SCHEME KEYSERVER_REQUESTS MIN_KEY_VERSION CURRENT_KEY_VERSION KEY_ROTATION_PAGE_NUMBER KEY_ROTATION_MAX_PAGE_NUMBER CURRENT_KEY_ID ROTATING_OR_FLUSHING
Warnings:
Warning 1012 InnoDB: SELECTing from INFORMATION_SCHEMA.innodb_tablespaces_encryption but the InnoDB storage engine is not installed
select * from information_schema.innodb_sys_semaphore_waits;
THREAD_ID OBJECT_NAME FILE LINE WAIT_TIME WAIT_OBJECT WAIT_TYPE HOLDER_THREAD_ID HOLDER_FILE HOLDER_LINE CREATED_FILE CREATED_LINE WRITER_THREAD RESERVATION_MODE READERS WAITERS_FLAG LOCK_WORD LAST_WRITER_FILE LAST_WRITER_LINE OS_WAIT_COUNT
Warnings:
Warning 1012 InnoDB: SELECTing from INFORMATION_SCHEMA.innodb_sys_semaphore_waits but the InnoDB storage engine is not installed
connect con1,localhost,root,,;
connect con2,localhost,root,,;
drop table if exists t1;
connection con1;
create table t1 (id integer, x integer) engine = InnoDB;
insert into t1 values(0, 0);
SET @saved_dbug = @@SESSION.debug_dbug;
set DEBUG_DBUG='+d,fatal-semaphore-timeout';
set autocommit=0;
# Sending query on con1,
# the session will hold lock table mutex and sleep
SELECT * from t1 where id = 0 FOR UPDATE;
connection con2;
set autocommit=0;
# Sending query on con2,
# the session will be blocked on the lock table mutex and
# thus be put into sync arry
SELECT * from t1 where id = 0 FOR UPDATE;
connection default;
# Waitting for mysqld to crash
# Mysqld crash was detected
# Waitting for reconnect after mysqld restarts
# Reconnected after mysqld was successfully restarted
# Cleaning up before exit
SET debug_dbug = @saved_dbug;
drop table if exists t1;
# Clean exit
......@@ -26,5 +26,4 @@
--enable-plugin-innodb-sys-foreign-cols
--enable-plugin-innodb-sys-tablespaces
--enable-plugin-innodb-sys-virtual
--enable-plugin-innodb-sys-semaphore-waits
--enable-plugin-innodb-tablespaces-encryption
......@@ -79,9 +79,6 @@ create sql security definer view d_sys_foreign_cols as select * from information
create sql security invoker view i_sys_indexes as select * from information_schema.innodb_sys_indexes;
create sql security definer view d_sys_indexes as select * from information_schema.innodb_sys_indexes;
create sql security invoker view i_sys_semaphore_waits as select * from information_schema.innodb_sys_semaphore_waits;
create sql security definer view d_sys_semaphore_waits as select * from information_schema.innodb_sys_semaphore_waits;
create sql security invoker view i_sys_tables as select * from information_schema.innodb_sys_tables;
create sql security definer view d_sys_tables as select * from information_schema.innodb_sys_tables;
......@@ -236,12 +233,6 @@ select count(*) > -1 from information_schema.innodb_sys_indexes;
select count(*) > -1 from i_sys_indexes;
select count(*) > -1 from d_sys_indexes;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
select count(*) > -1 from information_schema.innodb_sys_semaphore_waits;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
select count(*) > -1 from i_sys_semaphore_waits;
select count(*) > -1 from d_sys_semaphore_waits;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
select count(*) > -1 from information_schema.innodb_sys_tables;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
......
......@@ -59,4 +59,3 @@
--loose-innodb_sys_datafiles
--loose-innodb_changed_pages
--loose-innodb_tablespaces_encryption
--loose-innodb_sys_semaphore_waits
......@@ -27,4 +27,3 @@ select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
select * from information_schema.innodb_sys_tablespaces;
select * from information_schema.innodb_tablespaces_encryption;
select * from information_schema.innodb_sys_semaphore_waits;
--innodb-fatal-semaphore-wait-threshold=1
--innodb-sys-semaphore-waits=1
--source include/have_innodb.inc
--source include/not_windows.inc
--source include/not_valgrind.inc
--source include/not_embedded.inc
# DEBUG_SYNC must be compiled in.
--source include/have_debug_sync.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
--disable_warnings
drop table if exists t1;
--enable_warnings
connection con1;
eval create table t1 (id integer, x integer) engine = InnoDB;
insert into t1 values(0, 0);
# Enable the debug injection.
SET @saved_dbug = @@SESSION.debug_dbug;
set DEBUG_DBUG='+d,fatal-semaphore-timeout';
set autocommit=0;
# The following query will hang for an hour since the debug injection
# code will sleep an hour after holding the lock table mutex
--echo # Sending query on con1,
--echo # the session will hold lock table mutex and sleep
--send
SELECT * from t1 where id = 0 FOR UPDATE;
# To make sure con1 holding the lock table mutex and sleeping
--sleep 2
connection con2;
set autocommit=0;
# The following query will be blocked on the lock table mutex held by
# con1 so it will be put into sync array.
--echo # Sending query on con2,
--echo # the session will be blocked on the lock table mutex and
--echo # thus be put into sync arry
--send
SELECT * from t1 where id = 0 FOR UPDATE;
# Waitting for mysqld to abort due to fatal semaphore timeout.
# Please note that, in the master.opt file, the fatal timeout
# was set to 1 second, but in mysqld debug mode, this timeout
# value will be timed 10 because UNIV_DEBUG_VALGRIND is set
# (see sync_array_print_long_waits_low() in storage/innobase/sync/sync0arr.cc)
# so the actual timeout will be 1 * 10 = 10 seconds. Besides,
# mysqld will abort after detecting this fatal timeout 10 times in
# a loop with interval of 1 second (see srv_error_monitor_thread
# thread in torage/innobase/srv/srv0srv.cc), so mysqld will abort
# in 1 * 10 + 1 * 10 = 20 seconds after con2 being blocked on
# the lock table mutex.
#
# P.S. the default fatal sempahore timeout is 600 seconds,
# so mysqld will abort after 600 * 10 + 1 * 10 = 6010 seconds
# in debug mode and 600 + 1 * 10 = 610 seconds in release mode.
connection default;
--disable_result_log
--disable_query_log
# Since this test generates lot of errors in log, suppress checking errors
call mtr.add_suppression(".*");
# The crash is expected
exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
--echo # Waitting for mysqld to crash
# It will take 20 seconds to detect the long semaphore and mysqld to abort.
# This test will be treated as pass as long as mysqld crash/restart is dectected
# in 80 seconds.
let $counter= 80;
let $mysql_errno= 0;
while (!$mysql_errno)
{
--error 0,ER_SERVER_SHUTDOWN,ER_CONNECTION_KILLED,2002,2006,2013
show status;
--error 0,ER_SERVER_SHUTDOWN,ER_CONNECTION_KILLED,2002,2006,2013
select * from information_schema.innodb_sys_semaphore_waits;
dec $counter;
if (!$counter)
{
# This will fail this test.
--die Server failed to dissapear
}
--sleep 1
}
--echo # Mysqld crash was detected
--echo # Waitting for reconnect after mysqld restarts
enable_reconnect;
connection default;
--exec echo "restart:--log-error=$error_log" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
# Call script that will poll the server waiting for it to be back online again
source include/wait_until_connected_again.inc;
--echo # Reconnected after mysqld was successfully restarted
--echo # Cleaning up before exit
--disable_warnings
SET debug_dbug = @saved_dbug;
drop table if exists t1;
--enable_warnings
--echo # Clean exit
SHOW CREATE TABLE INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS;
Table Create Table
INNODB_SYS_SEMAPHORE_WAITS CREATE TEMPORARY TABLE `INNODB_SYS_SEMAPHORE_WAITS` (
`THREAD_ID` bigint(21) unsigned NOT NULL DEFAULT 0,
`OBJECT_NAME` varchar(4000) DEFAULT NULL,
`FILE` varchar(4000) DEFAULT NULL,
`LINE` int(11) unsigned NOT NULL DEFAULT 0,
`WAIT_TIME` bigint(21) unsigned NOT NULL DEFAULT 0,
`WAIT_OBJECT` bigint(21) unsigned NOT NULL DEFAULT 0,
`WAIT_TYPE` varchar(16) DEFAULT NULL,
`HOLDER_THREAD_ID` bigint(21) unsigned NOT NULL DEFAULT 0,
`HOLDER_FILE` varchar(4000) DEFAULT NULL,
`HOLDER_LINE` int(11) unsigned NOT NULL DEFAULT 0,
`CREATED_FILE` varchar(4000) DEFAULT NULL,
`CREATED_LINE` int(11) unsigned NOT NULL DEFAULT 0,
`WRITER_THREAD` bigint(21) unsigned NOT NULL DEFAULT 0,
`RESERVATION_MODE` varchar(16) DEFAULT NULL,
`READERS` int(11) unsigned NOT NULL DEFAULT 0,
`WAITERS_FLAG` bigint(21) unsigned NOT NULL DEFAULT 0,
`LOCK_WORD` bigint(21) unsigned NOT NULL DEFAULT 0,
`LAST_WRITER_FILE` varchar(4000) DEFAULT NULL,
`LAST_WRITER_LINE` int(11) unsigned NOT NULL DEFAULT 0,
`OS_WAIT_COUNT` int(11) unsigned NOT NULL DEFAULT 0
) ENGINE=MEMORY DEFAULT CHARSET=utf8
--source include/have_innodb.inc
SHOW CREATE TABLE INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS;
Valid values are between 0 and 1024
SELECT @@global.innodb_sync_array_size between 0 and 1024;
@@global.innodb_sync_array_size between 0 and 1024
1
SELECT @@global.innodb_sync_array_size;
@@global.innodb_sync_array_size
1
SELECT @@session.innodb_sync_array_size;
ERROR HY000: Variable 'innodb_sync_array_size' is a GLOBAL variable
SHOW GLOBAL variables LIKE 'innodb_sync_array_size';
Variable_name Value
innodb_sync_array_size 1
SHOW SESSION variables LIKE 'innodb_sync_array_size';
Variable_name Value
innodb_sync_array_size 1
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_sync_array_size';
VARIABLE_NAME VARIABLE_VALUE
INNODB_SYNC_ARRAY_SIZE 1
SELECT * FROM information_schema.session_variables
WHERE variable_name='innodb_sync_array_size';
VARIABLE_NAME VARIABLE_VALUE
INNODB_SYNC_ARRAY_SIZE 1
SET GLOBAL innodb_sync_array_size=10;
ERROR HY000: Variable 'innodb_sync_array_size' is a read only variable
SET SESSION innodb_sync_array_size=10;
ERROR HY000: Variable 'innodb_sync_array_size' is a read only variable
SELECT @@global.innodb_sync_array_size;
@@global.innodb_sync_array_size
1
......@@ -1665,18 +1665,6 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_SYNC_ARRAY_SIZE
SESSION_VALUE NULL
DEFAULT_VALUE 1
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Size of the mutex/lock wait array.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 1024
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_SYNC_DEBUG
SESSION_VALUE NULL
DEFAULT_VALUE OFF
......
# 2010-01-27 - Added
--source include/have_innodb.inc
# Exists as global only
#
--echo Valid values are between 0 and 1024
SELECT @@global.innodb_sync_array_size between 0 and 1024;
SELECT @@global.innodb_sync_array_size;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT @@session.innodb_sync_array_size;
SHOW GLOBAL variables LIKE 'innodb_sync_array_size';
SHOW SESSION variables LIKE 'innodb_sync_array_size';
--disable_warnings
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_sync_array_size';
SELECT * FROM information_schema.session_variables
WHERE variable_name='innodb_sync_array_size';
--enable_warnings
#
# Show that it's read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL innodb_sync_array_size=10;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET SESSION innodb_sync_array_size=10;
SELECT @@global.innodb_sync_array_size;
......@@ -469,7 +469,6 @@ innodb.innodb_stats : MDEV-10682 - wrong result
innodb.innodb_stats_drop_locked : Modified in 10.5.7
innodb.innodb_stats_persistent : MDEV-21567 - Wrong result in execution plan
innodb.innodb_stats_persistent_debug : MDEV-14801 - Operation failed
innodb.innodb_sys_semaphore_waits : MDEV-10331 - Semaphore wait
innodb.innodb_trx_weight : Configuration deleted in 10.5.7
innodb.innodb_zip_innochecksum2 : MDEV-13882 - Warning: difficult to find free blocks
innodb.instant_alter_bugs : Modified in 10.5.7
......
......@@ -5049,6 +5049,7 @@ static int init_server_components()
MARIADB_REMOVED_OPTION("innodb-replication-delay"),
MARIADB_REMOVED_OPTION("innodb-scrub-log"),
MARIADB_REMOVED_OPTION("innodb-scrub-log-speed"),
MARIADB_REMOVED_OPTION("innodb-sync-array-size"),
MARIADB_REMOVED_OPTION("innodb-thread-concurrency"),
MARIADB_REMOVED_OPTION("innodb-thread-sleep-delay"),
MARIADB_REMOVED_OPTION("innodb-undo-logs"),
......
......@@ -123,6 +123,7 @@ static const char *removed_variables[] =
"innodb_stats_sample_pages",
"innodb_stats_update_need_lock",
"innodb_support_xa",
"innodb_sync_array_size",
"innodb_thread_concurrency",
"innodb_thread_concurrency_timer_based",
"innodb_thread_sleep_delay",
......
......@@ -187,7 +187,6 @@ SET(INNOBASE_SOURCES
include/mtr0mtr.h
include/mtr0mtr.ic
include/mtr0types.h
include/os0event.h
include/os0file.h
include/os0file.ic
include/os0thread.h
......@@ -239,8 +238,6 @@ SET(INNOBASE_SOURCES
include/srv0mon.ic
include/srv0srv.h
include/srv0start.h
include/sync0arr.h
include/sync0arr.ic
include/sync0debug.h
include/sync0policy.h
include/sux_lock.h
......@@ -294,7 +291,6 @@ SET(INNOBASE_SOURCES
mem/mem0mem.cc
mtr/mtr0mtr.cc
os/os0file.cc
os/os0event.cc
os/os0thread.cc
page/page0cur.cc
page/page0page.cc
......@@ -328,7 +324,6 @@ SET(INNOBASE_SOURCES
srv/srv0srv.cc
srv/srv0start.cc
sync/srw_lock.cc
sync/sync0arr.cc
sync/sync0debug.cc
sync/sync0sync.cc
trx/trx0i_s.cc
......
......@@ -18444,14 +18444,6 @@ static MYSQL_SYSVAR_UINT(purge_threads, srv_n_purge_threads,
"Number of tasks for purging transaction history",
NULL, NULL, 4, 1, innodb_purge_threads_MAX, 0);
static MYSQL_SYSVAR_ULONG(sync_array_size, srv_sync_array_size,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
"Size of the mutex/lock wait array.",
NULL, NULL,
1, /* Default setting */
1, /* Minimum value */
1024, 0); /* Maximum value */
static MYSQL_SYSVAR_UINT(fast_shutdown, srv_fast_shutdown,
PLUGIN_VAR_OPCMDARG,
"Speeds up the shutdown process of the InnoDB storage engine. Possible"
......@@ -19471,7 +19463,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(undo_log_truncate),
MYSQL_SYSVAR(undo_directory),
MYSQL_SYSVAR(undo_tablespaces),
MYSQL_SYSVAR(sync_array_size),
MYSQL_SYSVAR(compression_failure_threshold_pct),
MYSQL_SYSVAR(compression_pad_pct_max),
MYSQL_SYSVAR(default_row_format),
......@@ -19554,7 +19545,6 @@ i_s_innodb_sys_foreign,
i_s_innodb_sys_foreign_cols,
i_s_innodb_sys_tablespaces,
i_s_innodb_sys_virtual,
i_s_innodb_sys_semaphore_waits,
i_s_innodb_tablespaces_encryption
maria_declare_plugin_end;
......
......@@ -22,7 +22,6 @@ this program; if not, write to the Free Software Foundation, Inc.,
InnoDB INFORMATION SCHEMA tables interface to MySQL.
Created July 18, 2007 Vasil Dimov
Modified Dec 29, 2014 Jan Lindström (Added sys_semaphore_waits)
*******************************************************/
#include "univ.i"
......@@ -54,7 +53,6 @@ Modified Dec 29, 2014 Jan Lindström (Added sys_semaphore_waits)
#include "fts0priv.h"
#include "btr0btr.h"
#include "page0zip.h"
#include "sync0arr.h"
#include "fil0fil.h"
#include "fil0crypt.h"
#include "dict0crea.h"
......@@ -171,20 +169,6 @@ time_t MYSQL_TYPE_DATETIME
---------------------------------
*/
/** Implemented on sync0arr.cc */
/*******************************************************************//**
Function to populate INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS table.
Loop through each item on sync array, and extract the column
information and fill the INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS table.
@return 0 on success */
UNIV_INTERN
int
sync_arr_fill_sys_semphore_waits_table(
/*===================================*/
THD* thd, /*!< in: thread */
TABLE_LIST* tables, /*!< in/out: tables to fill */
Item* ); /*!< in: condition (not used) */
/*******************************************************************//**
Common function to fill any of the dynamic tables:
INFORMATION_SCHEMA.innodb_trx
......@@ -245,6 +229,7 @@ field_store_time_t(
/*******************************************************************//**
Auxiliary function to store char* value in MYSQL_TYPE_STRING field.
@return 0 on success */
static
int
field_store_string(
/*===============*/
......@@ -6879,143 +6864,3 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_tablespaces_encryption =
STRUCT_FLD(version_info, INNODB_VERSION_STR),
STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE)
};
namespace Show {
/* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS */
static ST_FIELD_INFO innodb_sys_semaphore_waits_fields_info[] =
{
// SYS_SEMAPHORE_WAITS_THREAD_ID 0
Column("THREAD_ID", ULonglong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_OBJECT_NAME 1
Column("OBJECT_NAME", Varchar(OS_FILE_MAX_PATH), NULLABLE),
// SYS_SEMAPHORE_WAITS_FILE 2
Column("FILE", Varchar(OS_FILE_MAX_PATH), NULLABLE),
// SYS_SEMAPHORE_WAITS_LINE 3
Column("LINE", ULong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_WAIT_TIME 4
Column("WAIT_TIME", ULonglong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_WAIT_OBJECT 5
Column("WAIT_OBJECT", ULonglong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_WAIT_TYPE 6
Column("WAIT_TYPE", Varchar(16), NULLABLE),
// SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID 7
Column("HOLDER_THREAD_ID", ULonglong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_HOLDER_FILE 8
Column("HOLDER_FILE", Varchar(OS_FILE_MAX_PATH), NULLABLE),
// SYS_SEMAPHORE_WAITS_HOLDER_LINE 9
Column("HOLDER_LINE", ULong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_CREATED_FILE 10
Column("CREATED_FILE", Varchar(OS_FILE_MAX_PATH), NULLABLE),
// SYS_SEMAPHORE_WAITS_CREATED_LINE 11
Column("CREATED_LINE", ULong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_WRITER_THREAD 12
Column("WRITER_THREAD", ULonglong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_RESERVATION_MODE 13
Column("RESERVATION_MODE", Varchar(16), NULLABLE),
// SYS_SEMAPHORE_WAITS_READERS 14
Column("READERS", ULong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_WAITERS_FLAG 15
Column("WAITERS_FLAG", ULonglong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_LOCK_WORD 16
Column("LOCK_WORD", ULonglong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_LAST_WRITER_FILE 17
Column("LAST_WRITER_FILE", Varchar(OS_FILE_MAX_PATH), NULLABLE),
// SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE 18
Column("LAST_WRITER_LINE", ULong(), NOT_NULL),
// SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT 19
Column("OS_WAIT_COUNT", ULong(), NOT_NULL),
CEnd()
};
} // namespace Show
/*******************************************************************//**
Bind the dynamic table INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS
@return 0 on success */
static
int
innodb_sys_semaphore_waits_init(
/*============================*/
void* p) /*!< in/out: table schema object */
{
ST_SCHEMA_TABLE* schema;
DBUG_ENTER("innodb_sys_semaphore_waits_init");
schema = (ST_SCHEMA_TABLE*) p;
schema->fields_info = Show::innodb_sys_semaphore_waits_fields_info;
schema->fill_table = sync_arr_fill_sys_semphore_waits_table;
DBUG_RETURN(0);
}
UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_semaphore_waits =
{
/* the plugin type (a MYSQL_XXX_PLUGIN value) */
/* int */
STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
/* pointer to type-specific plugin descriptor */
/* void* */
STRUCT_FLD(info, &i_s_info),
/* plugin name */
/* const char* */
STRUCT_FLD(name, "INNODB_SYS_SEMAPHORE_WAITS"),
/* plugin author (for SHOW PLUGINS) */
/* const char* */
STRUCT_FLD(author, maria_plugin_author),
/* general descriptive text (for SHOW PLUGINS) */
/* const char* */
STRUCT_FLD(descr, "InnoDB SYS_SEMAPHORE_WAITS"),
/* the plugin license (PLUGIN_LICENSE_XXX) */
/* int */
STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
/* the function to invoke when plugin is loaded */
/* int (*)(void*); */
STRUCT_FLD(init, innodb_sys_semaphore_waits_init),
/* the function to invoke when plugin is unloaded */
/* int (*)(void*); */
STRUCT_FLD(deinit, i_s_common_deinit),
/* plugin version (for SHOW PLUGINS) */
/* unsigned int */
STRUCT_FLD(version, INNODB_VERSION_SHORT),
/* struct st_mysql_show_var* */
STRUCT_FLD(status_vars, NULL),
/* struct st_mysql_sys_var** */
STRUCT_FLD(system_vars, NULL),
/* Maria extension */
STRUCT_FLD(version_info, INNODB_VERSION_STR),
STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE),
};
......@@ -61,7 +61,6 @@ extern struct st_maria_plugin i_s_innodb_sys_foreign_cols;
extern struct st_maria_plugin i_s_innodb_sys_tablespaces;
extern struct st_maria_plugin i_s_innodb_sys_virtual;
extern struct st_maria_plugin i_s_innodb_tablespaces_encryption;
extern struct st_maria_plugin i_s_innodb_sys_semaphore_waits;
/** The latest successfully looked up innodb_fts_aux_table */
extern table_id_t innodb_ft_aux_table_id;
......@@ -99,47 +98,4 @@ do { \
#define STRUCT_FLD(name, value) value
#endif
/* Don't use a static const variable here, as some C++ compilers (notably
HPUX aCC: HP ANSI C++ B3910B A.03.65) can't handle it. */
#define END_OF_ST_FIELD_INFO \
{STRUCT_FLD(field_name, NULL), \
STRUCT_FLD(field_length, 0), \
STRUCT_FLD(field_type, MYSQL_TYPE_NULL), \
STRUCT_FLD(value, 0), \
STRUCT_FLD(field_flags, 0), \
STRUCT_FLD(old_name, ""), \
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}
/** Fields on INFORMATION_SCHEMA.SYS_SEMAMPHORE_WAITS table */
#define SYS_SEMAPHORE_WAITS_THREAD_ID 0
#define SYS_SEMAPHORE_WAITS_OBJECT_NAME 1
#define SYS_SEMAPHORE_WAITS_FILE 2
#define SYS_SEMAPHORE_WAITS_LINE 3
#define SYS_SEMAPHORE_WAITS_WAIT_TIME 4
#define SYS_SEMAPHORE_WAITS_WAIT_OBJECT 5
#define SYS_SEMAPHORE_WAITS_WAIT_TYPE 6
#define SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID 7
#define SYS_SEMAPHORE_WAITS_HOLDER_FILE 8
#define SYS_SEMAPHORE_WAITS_HOLDER_LINE 9
#define SYS_SEMAPHORE_WAITS_CREATED_FILE 10
#define SYS_SEMAPHORE_WAITS_CREATED_LINE 11
#define SYS_SEMAPHORE_WAITS_WRITER_THREAD 12
#define SYS_SEMAPHORE_WAITS_RESERVATION_MODE 13
#define SYS_SEMAPHORE_WAITS_READERS 14
#define SYS_SEMAPHORE_WAITS_WAITERS_FLAG 15
#define SYS_SEMAPHORE_WAITS_LOCK_WORD 16
#define SYS_SEMAPHORE_WAITS_LAST_WRITER_FILE 17
#define SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE 18
#define SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT 19
/*******************************************************************//**
Auxiliary function to store char* value in MYSQL_TYPE_STRING field.
@return 0 on success */
int
field_store_string(
/*===============*/
Field* field, /*!< in/out: target field for storage */
const char* str); /*!< in: NUL-terminated utf-8 string,
or NULL */
#endif /* i_s_h */
......@@ -30,8 +30,6 @@ Created 2013-03-26 Sunny Bains.
#define ib0mutex_h
#include "my_cpu.h"
#include "os0event.h"
#include "sync0arr.h"
/** OS mutex for tracking lock/unlock for debugging */
template <template <typename> class Policy>
......@@ -363,167 +361,6 @@ struct TTASMutex {
std::atomic<uint32_t> m_lock_word;
};
template <template <typename> class Policy>
struct TTASEventMutex {
typedef Policy<TTASEventMutex> MutexPolicy;
TTASEventMutex()
UNIV_NOTHROW
:
m_lock_word(MUTEX_STATE_UNLOCKED),
m_event()
{
/* Check that lock_word is aligned. */
ut_ad(!((ulint) &m_lock_word % sizeof(ulint)));
}
~TTASEventMutex()
UNIV_NOTHROW
{
ut_ad(state() == MUTEX_STATE_UNLOCKED);
}
/** Called when the mutex is "created". Note: Not from the constructor
but when the mutex is initialised.
@param[in] id Mutex ID */
void init(latch_id_t id, const char*, uint32_t) UNIV_NOTHROW
{
ut_a(m_event == 0);
ut_ad(state() == MUTEX_STATE_UNLOCKED);
m_event = os_event_create(sync_latch_get_name(id));
}
/** This is the real desctructor. This mutex can be created in BSS and
its desctructor will be called on exit(). We can't call
os_event_destroy() at that stage. */
void destroy()
UNIV_NOTHROW
{
ut_ad(state() == MUTEX_STATE_UNLOCKED);
/* We have to free the event before InnoDB shuts down. */
os_event_destroy(m_event);
m_event = 0;
}
/** Try and lock the mutex. Note: POSIX returns 0 on success.
@return true on success */
bool try_lock()
UNIV_NOTHROW
{
uint32_t oldval = MUTEX_STATE_UNLOCKED;
return m_lock_word.compare_exchange_strong(
oldval,
MUTEX_STATE_LOCKED,
std::memory_order_acquire,
std::memory_order_relaxed);
}
/** Release the mutex. */
void exit()
UNIV_NOTHROW
{
if (m_lock_word.exchange(MUTEX_STATE_UNLOCKED,
std::memory_order_release)
== MUTEX_STATE_WAITERS) {
os_event_set(m_event);
sync_array_object_signalled();
}
}
/** Acquire the mutex.
@param[in] max_spins max number of spins
@param[in] max_delay max delay per spin
@param[in] filename from where called
@param[in] line within filename */
void enter(
uint32_t max_spins,
uint32_t max_delay,
const char* filename,
uint32_t line)
UNIV_NOTHROW
{
uint32_t n_spins = 0;
uint32_t n_waits = 0;
const uint32_t step = max_spins;
while (!try_lock()) {
if (n_spins++ == max_spins) {
max_spins += step;
n_waits++;
os_thread_yield();
sync_cell_t* cell;
sync_array_t *sync_arr = sync_array_get_and_reserve_cell(
this,
filename, line, &cell);
uint32_t oldval = MUTEX_STATE_LOCKED;
m_lock_word.compare_exchange_strong(
oldval,
MUTEX_STATE_WAITERS,
std::memory_order_relaxed,
std::memory_order_relaxed);
if (oldval == MUTEX_STATE_UNLOCKED) {
sync_array_free_cell(sync_arr, cell);
} else {
sync_array_wait_event(sync_arr, cell);
}
} else {
ut_delay(max_delay);
}
}
m_policy.add(n_spins, n_waits);
}
/** @return the lock state. */
int32 state() const
UNIV_NOTHROW
{
return m_lock_word.load(std::memory_order_relaxed);
}
/** The event that the mutex will wait in sync0arr.cc
@return even instance */
os_event_t event()
UNIV_NOTHROW
{
return(m_event);
}
/** @return non-const version of the policy */
MutexPolicy& policy()
UNIV_NOTHROW
{
return(m_policy);
}
/** @return const version of the policy */
const MutexPolicy& policy() const
UNIV_NOTHROW
{
return(m_policy);
}
private:
/** Disable copying */
TTASEventMutex(const TTASEventMutex&);
TTASEventMutex& operator=(const TTASEventMutex&);
/** mutex state */
std::atomic<uint32_t> m_lock_word;
/** Used by sync0arr.cc for the wait queue */
os_event_t m_event;
/** Policy data */
MutexPolicy m_policy;
};
/** Mutex interface for all policy mutexes. This class handles the interfacing
with the Performance Schema instrumentation. */
template <typename MutexImpl>
......
/*****************************************************************************
Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
*****************************************************************************/
/**************************************************//**
@file include/os0event.h
The interface to the operating system condition variables
Created 2012-09-23 Sunny Bains (split from os0sync.h)
*******************************************************/
#ifndef os0event_h
#define os0event_h
#include "univ.i"
// Forward declaration.
struct os_event;
typedef struct os_event* os_event_t;
/** Denotes an infinite delay for os_event_wait_time() */
#define OS_SYNC_INFINITE_TIME ULINT_UNDEFINED
/** Return value of os_event_wait_time() when the time is exceeded */
#define OS_SYNC_TIME_EXCEEDED 1
/**
Creates an event semaphore, i.e., a semaphore which may just have two states:
signaled and nonsignaled. The created event is manual reset: it must be reset
explicitly by calling os_event_reset().
@return the event handle */
os_event_t os_event_create(const char*);
/**
Sets an event semaphore to the signaled state: lets waiting threads
proceed. */
void
os_event_set(
/*=========*/
os_event_t event); /*!< in/out: event to set */
/**
Check if the event is set.
@return true if set */
bool
os_event_is_set(
/*============*/
const os_event_t event); /*!< in: event to set */
/**
Resets an event semaphore to the nonsignaled state. Waiting threads will
stop to wait for the event.
The return value should be passed to os_even_wait_low() if it is desired
that this thread should not wait in case of an intervening call to
os_event_set() between this os_event_reset() and the
os_event_wait_low() call. See comments for os_event_wait_low(). */
int64_t
os_event_reset(
/*===========*/
os_event_t event); /*!< in/out: event to reset */
/**
Frees an event object. */
void
os_event_destroy(
/*=============*/
os_event_t& event); /*!< in/own: event to free */
/**
Waits for an event object until it is in the signaled state.
Typically, if the event has been signalled after the os_event_reset()
we'll return immediately because event->is_set == TRUE.
There are, however, situations (e.g.: sync_array code) where we may
lose this information. For example:
thread A calls os_event_reset()
thread B calls os_event_set() [event->is_set == TRUE]
thread C calls os_event_reset() [event->is_set == FALSE]
thread A calls os_event_wait() [infinite wait!]
thread C calls os_event_wait() [infinite wait!]
Where such a scenario is possible, to avoid infinite wait, the
value returned by os_event_reset() should be passed in as
reset_sig_count. */
void
os_event_wait_low(
/*==============*/
os_event_t event, /*!< in/out: event to wait */
int64_t reset_sig_count);/*!< in: zero or the value
returned by previous call of
os_event_reset(). */
/** Blocking infinite wait on an event, until signealled.
@param e - event to wait on. */
#define os_event_wait(e) os_event_wait_low((e), 0)
/**
Waits for an event object until it is in the signaled state or
a timeout is exceeded. In Unix the timeout is always infinite.
@return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */
ulint
os_event_wait_time_low(
/*===================*/
os_event_t event, /*!< in/out: event to wait */
ulint time_in_usec, /*!< in: timeout in
microseconds, or
OS_SYNC_INFINITE_TIME */
int64_t reset_sig_count); /*!< in: zero or the value
returned by previous call of
os_event_reset(). */
/** Blocking timed wait on an event.
@param e - event to wait on.
@param t - timeout in microseconds */
#define os_event_wait_time(e, t) os_event_wait_time_low((e), (t), 0)
#endif /* !os0event_h */
......@@ -45,6 +45,7 @@ Created 10/10/1995 Heikki Tuuri
#include "que0types.h"
#include "trx0types.h"
#include "fil0fil.h"
#include "ut0counter.h"
#include "mysql/psi/mysql_stage.h"
#include "mysql/psi/psi.h"
......@@ -184,7 +185,7 @@ struct srv_stats_t
};
/** We are prepared for a situation that we have this many threads waiting for
a semaphore inside InnoDB. srv_start() sets the value. */
a transactional lock inside InnoDB. srv_start() sets the value. */
extern ulint srv_max_n_threads;
extern const char* srv_main_thread_op_info;
......
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
*****************************************************************************/
/**************************************************//**
@file include/sync0arr.h
The wait array used in synchronization primitives
Created 9/5/1995 Heikki Tuuri
*******************************************************/
#ifndef sync0arr_h
#define sync0arr_h
#include "univ.i"
/** Synchronization wait array cell */
struct sync_cell_t;
/** Synchronization wait array */
struct sync_array_t;
/******************************************************************//**
Get an instance of the sync wait array and reserve a wait array cell
in the instance for waiting for an object. The event of the cell is
reset to nonsignalled state.
If reserving cell of the instance fails, try to get another new
instance until we can reserve an empty cell of it.
@return the sync array found, never NULL. */
UNIV_INLINE
sync_array_t*
sync_array_get_and_reserve_cell(
void* object, /*!< in: pointer to the object to wait for */
const char* file, /*!< in: file where requested */
unsigned line, /*!< in: line where requested */
sync_cell_t** cell); /*!< out: the cell reserved, never NULL */
/******************************************************************//**
Reserves a wait array cell for waiting for an object.
The event of the cell is reset to nonsignalled state. */
sync_cell_t*
sync_array_reserve_cell(
sync_array_t* arr, /*!< in: wait array */
void* object, /*!< in: pointer to the object to wait for */
const char* file, /*!< in: file where requested */
unsigned line); /*!< in: line where requested */
/******************************************************************//**
This function should be called when a thread starts to wait on
a wait array cell. In the debug version this function checks
if the wait for a semaphore will result in a deadlock, in which
case prints info and asserts. */
void
sync_array_wait_event(
sync_array_t* arr, /*!< in: wait array */
sync_cell_t*& cell); /*!< in: the reserved cell */
/******************************************************************//**
Frees the cell. NOTE! sync_array_wait_event frees the cell
automatically! */
void
sync_array_free_cell(
sync_array_t* arr, /*!< in: wait array */
sync_cell_t*& cell); /*!< in: the reserved cell */
/** count of how many times an object has been signalled */
extern ulint sg_count;
#define sync_array_object_signalled() ++sg_count
/**********************************************************************//**
Prints warnings of long semaphore waits to stderr.
@return TRUE if fatal semaphore wait threshold was exceeded */
ibool
sync_array_print_long_waits(
os_thread_id_t* waiter, /*!< out: longest waiting thread */
const void** sema); /*!< out: longest-waited-for semaphore */
/**********************************************************************//**
Prints info of the wait array. */
void
sync_array_print(
FILE* file); /*!< in: file where to print */
/** Create the primary system wait arrays */
void sync_array_init();
/** Destroy the sync array wait sub-system. */
void sync_array_close();
/**********************************************************************//**
Get an instance of the sync wait array. */
UNIV_INLINE
sync_array_t*
sync_array_get();
/**********************************************************************//**
Prints info of the wait array without using any mutexes/semaphores. */
UNIV_INTERN
void
sync_array_print_innodb(void);
/*****************************************************************//**
Gets the nth cell in array.
@return cell */
UNIV_INTERN
sync_cell_t*
sync_array_get_nth_cell(
/*====================*/
sync_array_t* arr, /*!< in: sync array */
ulint n); /*!< in: index */
#include "sync0arr.ic"
#endif /* sync0arr_h */
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
*****************************************************************************/
/**************************************************//**
@file include/sync0arr.ic
The wait array for synchronization primitives
Inline code
Created 9/5/1995 Heikki Tuuri
*******************************************************/
extern ulint sync_array_size;
extern sync_array_t** sync_wait_array;
#include "ut0counter.h"
/**********************************************************************//**
Get an instance of the sync wait array.
@return an instance of the sync wait array. */
UNIV_INLINE
sync_array_t*
sync_array_get()
/*============*/
{
if (sync_array_size <= 1) {
return(sync_wait_array[0]);
}
return(sync_wait_array[get_rnd_value() % sync_array_size]);
}
/******************************************************************//**
Get an instance of the sync wait array and reserve a wait array cell
in the instance for waiting for an object. The event of the cell is
reset to nonsignalled state.
If reserving cell of the instance fails, try to get another new
instance until we can reserve an empty cell of it.
@return the sync array reserved, never NULL. */
UNIV_INLINE
sync_array_t*
sync_array_get_and_reserve_cell(
void* object, /*!< in: pointer to the object to wait for */
const char* file, /*!< in: file where requested */
unsigned line, /*!< in: line where requested */
sync_cell_t** cell) /*!< out: the cell reserved, never NULL */
{
sync_array_t* sync_arr = NULL;
*cell = NULL;
for (ulint i = 0; i < sync_array_size && *cell == NULL; ++i) {
/* Although the sync_array is get in a random way currently,
we still try at most sync_array_size times, in case any
of the sync_array we get is full */
sync_arr = sync_array_get();
*cell = sync_array_reserve_cell(sync_arr, object, file, line);
}
/* This won't be true every time, for the loop above may execute
more than srv_sync_array_size times to reserve a cell.
But an assertion here makes the code more solid. */
ut_a(*cell != NULL);
return(sync_arr);
}
......@@ -178,8 +178,6 @@ LatchDebug internals in sync0debug.cc */
enum latch_level_t {
SYNC_UNKNOWN = 0,
SYNC_MUTEX = 1,
RW_LOCK_SX,
RW_LOCK_X_WAIT,
RW_LOCK_S,
......
......@@ -41,7 +41,6 @@ UT_MUTEX_TYPE(TTASFutexMutex, GenericPolicy, FutexMutex);
UT_MUTEX_TYPE(TTASMutex, GenericPolicy, SpinMutex);
UT_MUTEX_TYPE(OSTrackMutex, GenericPolicy, SysMutex);
UT_MUTEX_TYPE(TTASEventMutex, GenericPolicy, SyncArrayMutex);
#ifdef MUTEX_FUTEX
/** The default mutex type. */
......@@ -50,9 +49,6 @@ typedef FutexMutex ib_mutex_t;
#elif defined(MUTEX_SYS)
typedef SysMutex ib_mutex_t;
#define MUTEX_TYPE "Uses system mutexes"
#elif defined(MUTEX_EVENT)
typedef SyncArrayMutex ib_mutex_t;
#define MUTEX_TYPE "Uses event mutexes"
#else
#error "ib_mutex_t type is unknown"
#endif /* MUTEX_FUTEX */
......
......@@ -868,7 +868,6 @@ constexpr const char* const auto_event_names[] =
"lexyy",
"lock0lock",
"mem0mem",
"os0event",
"os0file",
"pars0lex",
"rem0rec",
......@@ -879,7 +878,6 @@ constexpr const char* const auto_event_names[] =
"row0mysql",
"row0sel",
"srv0start",
"sync0arr",
"sync0debug",
"sync0start",
"sync0types",
......
......@@ -137,11 +137,9 @@ IF(HAVE_C99_INITIALIZERS)
ADD_DEFINITIONS(-DHAVE_C99_INITIALIZERS)
ENDIF()
SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex")
SET(MUTEXTYPE "sys" CACHE STRING "Mutex type: sys or futex")
IF(MUTEXTYPE MATCHES "event")
ADD_DEFINITIONS(-DMUTEX_EVENT)
ELSEIF(MUTEXTYPE MATCHES "futex" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
IF(MUTEXTYPE MATCHES "futex" AND DEFINED HAVE_IB_LINUX_FUTEX)
ADD_DEFINITIONS(-DMUTEX_FUTEX)
ELSE()
ADD_DEFINITIONS(-DMUTEX_SYS)
......
This diff is collapsed.
......@@ -838,11 +838,11 @@ srv_printf_innodb_monitor(
"-----------------\n", file);
srv_print_master_thread_info(file);
/* This section is intentionally left blank, for tools like "innotop" */
fputs("----------\n"
"SEMAPHORES\n"
"----------\n", file);
sync_array_print(file);
/* End of intentionally blank section */
/* Conceptually, srv_innodb_monitor_mutex has a very high latching
order level in sync0sync.h, while dict_foreign_err_mutex has a very
......@@ -1347,21 +1347,11 @@ static void srv_monitor()
srv_refresh_innodb_monitor_stats(current_time);
}
/*********************************************************************//**
A task which prints warnings about semaphore waits which have lasted
too long. These can be used to track bugs which cause hangs.
*/
/** Periodic task which prints the info output by various InnoDB monitors.*/
void srv_monitor_task(void*)
{
/* number of successive fatal timeouts observed */
static ulint fatal_cnt;
static lsn_t old_lsn = recv_sys.recovered_lsn;
/* longest waiting thread for a semaphore */
os_thread_id_t waiter;
static os_thread_id_t old_waiter = os_thread_get_curr_id();
/* the semaphore that is being waited for */
const void* sema = NULL;
static const void* old_sema = NULL;
ut_ad(!srv_read_only_mode);
......@@ -1383,31 +1373,6 @@ void srv_monitor_task(void*)
eviction policy. */
buf_LRU_stat_update();
if (sync_array_print_long_waits(&waiter, &sema)
&& sema == old_sema && os_thread_eq(waiter, old_waiter)) {
#if defined(WITH_WSREP) && defined(WITH_INNODB_DISALLOW_WRITES)
if (UNIV_UNLIKELY(innodb_disallow_writes)) {
fprintf(stderr,
"WSREP: avoiding InnoDB self crash due to "
"long semaphore wait of > %lu seconds\n"
"Server is processing SST donor operation, "
"fatal_cnt now: " ULINTPF,
srv_fatal_semaphore_wait_threshold, fatal_cnt);
return;
}
#endif /* WITH_WSREP */
if (fatal_cnt++) {
ib::fatal() << "Semaphore wait has lasted > "
<< srv_fatal_semaphore_wait_threshold
<< " seconds. We intentionally crash the"
" server because it appears to be hung.";
}
} else {
fatal_cnt = 0;
old_waiter = waiter;
old_sema = sema;
}
srv_monitor();
}
......
......@@ -100,7 +100,7 @@ Created 2/16/1996 Heikki Tuuri
#include "ut0crc32.h"
/** We are prepared for a situation that we have this many threads waiting for
a semaphore inside InnoDB. srv_start() sets the value. */
a transactional lock inside InnoDB. srv_start() sets the value. */
ulint srv_max_n_threads;
/** Log sequence number at shutdown */
......@@ -1109,27 +1109,11 @@ dberr_t srv_start(bool create_new_db)
mysql_stage_register("innodb", srv_stages,
static_cast<int>(UT_ARR_SIZE(srv_stages)));
/* Set the maximum number of threads which can wait for a semaphore
inside InnoDB: this is the 'sync wait array' size */
srv_max_n_threads = 1 /* io_ibuf_thread */
+ 1 /* io_log_thread */
+ 1 /* srv_print_monitor_task */
+ 1 /* srv_purge_coordinator_thread */
+ 1 /* buf_dump_thread */
+ 1 /* dict_stats_thread */
+ 1 /* fts_optimize_thread */
+ 1 /* trx_rollback_all_recovered */
+ 128 /* added as margin, for use of
InnoDB Memcached etc. */
+ 1/* buf_flush_page_cleaner */
+ max_connections
+ srv_n_read_io_threads
+ srv_n_write_io_threads
+ srv_n_purge_threads
/* FTS Parallel Sort */
+ fts_sort_pll_degree * FTS_NUM_AUX_INDEX
* max_connections;
srv_max_n_threads =
1 /* dict_stats_thread */
+ 1 /* fts_optimize_thread */
+ 128 /* safety margin */
+ max_connections;
srv_boot();
......
This diff is collapsed.
......@@ -388,7 +388,6 @@ LatchDebug::LatchDebug()
m_mutex.init();
LEVEL_MAP_INSERT(SYNC_UNKNOWN);
LEVEL_MAP_INSERT(SYNC_MUTEX);
LEVEL_MAP_INSERT(RW_LOCK_SX);
LEVEL_MAP_INSERT(RW_LOCK_X_WAIT);
LEVEL_MAP_INSERT(RW_LOCK_S);
......@@ -668,7 +667,6 @@ LatchDebug::check_order(
basic_check(latches, level, SYNC_DICT);
break;
case SYNC_MUTEX:
case SYNC_UNKNOWN:
case RW_LOCK_X:
case RW_LOCK_X_WAIT:
......@@ -1030,8 +1028,6 @@ sync_check_init()
sync_latch_meta_init();
sync_array_init();
ut_d(sync_check_enable());
}
......@@ -1040,8 +1036,5 @@ void
sync_check_close()
{
ut_d(LatchDebug::shutdown());
sync_array_close();
sync_latch_meta_destroy();
}
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