diff --git a/mysql-test/suite/galera/r/MDEV-33133.result b/mysql-test/suite/galera/r/MDEV-33133.result new file mode 100644 index 00000000000..a326b5efc4d --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-33133.result @@ -0,0 +1,34 @@ +connection node_2; +connection node_1; +connect node_1a,127.0.0.1,root,,test,$NODE_MYPORT_1; +connection node_1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_rollback_mdl_release'; +connection node_2; +SET SESSION wsrep_trx_fragment_size = 1; +START TRANSACTION; +INSERT INTO t1 VALUES (1); +connection node_1a; +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +SET SESSION wsrep_retry_autocommit = 0; +SET DEBUG_SYNC = 'ha_write_row_start SIGNAL may_toi WAIT_FOR bf_abort'; +INSERT INTO t1 VALUES (2); +connection node_1; +SET DEBUG_SYNC = 'now WAIT_FOR may_toi'; +SET DEBUG_SYNC = 'after_wsrep_thd_abort WAIT_FOR sync.wsrep_rollback_mdl_release_reached'; +TRUNCATE TABLE t1; +connection node_1a; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_rollback_mdl_release'; +connection node_2; +INSERT INTO t1 VALUES (3); +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +connection node_1; +SET GLOBAL DEBUG_DBUG = ''; +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; +disconnect node_1a; +disconnect node_2; +disconnect node_1; diff --git a/mysql-test/suite/galera/t/MDEV-33133.test b/mysql-test/suite/galera/t/MDEV-33133.test new file mode 100644 index 00000000000..90d1f93f4cb --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-33133.test @@ -0,0 +1,80 @@ +# +# MDEV-33133: MDL conflict handling code should skip transactions +# BF-aborted before. +# +# It's possible that MDL conflict handling code is called more +# than once for a transaction when: +# - it holds more than one conflicting MDL lock +# - reschedule_waiters() is executed, +# which results in repeated attempts to BF-abort already aborted +# transaction. +# In such situations, it might be that BF-aborting logic sees +# a partially rolled back transaction and erroneously decides +# on future actions for such a transaction. +# +# The specific situation tested and fixed is when a SR transaction +# applied in the node gets BF-aborted by a started TOI operation. +# It's then caught with the server transaction already rolled back, +# but with no MDL locks yet released. This caused wrong state +# detection for such a transaction during repeated MDL conflict +# handling code execution. +# + +--source include/galera_cluster.inc +--source include/have_debug_sync.inc +--source include/have_debug.inc + +--connect node_1a,127.0.0.1,root,,test,$NODE_MYPORT_1 + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_rollback_mdl_release'; + +--connection node_2 +SET SESSION wsrep_trx_fragment_size = 1; +START TRANSACTION; +INSERT INTO t1 VALUES (1); + +--connection node_1a +# Sync wait for SR transaction to replicate and apply fragment. +SELECT COUNT(*) FROM t1; +SET SESSION wsrep_retry_autocommit = 0; +SET DEBUG_SYNC = 'ha_write_row_start SIGNAL may_toi WAIT_FOR bf_abort'; +--send + INSERT INTO t1 VALUES (2); + +--connection node_1 +SET DEBUG_SYNC = 'now WAIT_FOR may_toi'; +# BF-abort SR transaction and wait until it reaches the point +# prior to release MDL locks. +# Then abort local INSERT, which will go through rescedule_waiters() +# and see SR transaction holding MDL locks but already rolled back. +# In this case SR transaction should be skipped in MDL conflict +# handling code. +SET DEBUG_SYNC = 'after_wsrep_thd_abort WAIT_FOR sync.wsrep_rollback_mdl_release_reached'; +--send + TRUNCATE TABLE t1; + +--connection node_1a +# Local INSERT gets aborted. +--error ER_LOCK_DEADLOCK +--reap +# Let the aborted SR transaction continue and finally release MDL locks, +# which in turn allows TRUNCATE to complete. +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_rollback_mdl_release'; + +--connection node_2 +# SR transaction has been BF-aborted. +--error ER_LOCK_DEADLOCK +INSERT INTO t1 VALUES (3); + +--connection node_1 +# TRUNCATE completes. +--reap + +# Cleanup +SET GLOBAL DEBUG_DBUG = ''; +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; +--disconnect node_1a +--source include/galera_end.inc diff --git a/scripts/sys_schema/README.md b/scripts/sys_schema/README.md index 2f1dc74e055..910c58df280 100644 --- a/scripts/sys_schema/README.md +++ b/scripts/sys_schema/README.md @@ -1,8 +1,8 @@ -# The MySQL sys schema +# The MariaDB sys schema -A collection of views, functions and procedures to help MySQL administrators get insight in to MySQL Database usage. +A collection of views, functions and procedures to help MariaDB administrators get insight into MariaDB Database usage. -There are install files available for 5.6 and 5.7 respectively. To load these, you must position yourself within the directory that you downloaded to, as these top level files SOURCE individual files that are shared across versions in most cases (though not all). +There are install files available. To load these, you must position yourself within the directory that you downloaded to, as these top level files SOURCE individual files that are shared across versions in most cases (though not all). ## Overview of objects @@ -54,10 +54,10 @@ Summarizes statement activity, file IO and connections by host. When the host found is NULL, it is assumed to be a "background" thread. -##### Structures (5.7) +##### Structures ```SQL -mysql> desc host_summary; +mariadb> desc host_summary; +------------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+---------------+------+-----+---------+-------+ @@ -76,7 +76,7 @@ mysql> desc host_summary; +------------------------+---------------+------+-----+---------+-------+ 12 rows in set (0.15 sec) -mysql> desc x$host_summary; +mariadb> desc x$host_summary; +------------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+---------------+------+-----+---------+-------+ @@ -99,7 +99,7 @@ mysql> desc x$host_summary; ##### Example ```SQL - mysql> select * from host_summary; + mariadb> select * from host_summary; +------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+ | host | statements | statement_latency | statement_avg_latency | table_scans | file_ios | file_io_latency | current_connections | total_connections | unique_users | +------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+ @@ -118,7 +118,7 @@ When the host found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc host_summary_by_file_io; +mariadb> desc host_summary_by_file_io; +------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+---------------+------+-----+---------+-------+ @@ -128,7 +128,7 @@ mysql> desc host_summary_by_file_io; +------------+---------------+------+-----+---------+-------+ 3 rows in set (0.00 sec) -mysql> desc x$host_summary_by_file_io; +mariadb> desc x$host_summary_by_file_io; +------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+---------------+------+-----+---------+-------+ @@ -142,7 +142,7 @@ mysql> desc x$host_summary_by_file_io; ##### Example ```SQL - mysql> select * from host_summary_by_file_io; + mariadb> select * from host_summary_by_file_io; +------------+-------+------------+ | host | ios | io_latency | +------------+-------+------------+ @@ -162,7 +162,7 @@ When the host found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc host_summary_by_file_io_type; +mariadb> desc host_summary_by_file_io_type; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -174,7 +174,7 @@ mysql> desc host_summary_by_file_io_type; +---------------+---------------------+------+-----+---------+-------+ 5 rows in set (0.70 sec) -mysql> desc x$host_summary_by_file_io_type; +mariadb> desc x$host_summary_by_file_io_type; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -190,7 +190,7 @@ mysql> desc x$host_summary_by_file_io_type; ##### Example ```SQL - mysql> select * from host_summary_by_file_io_type; + mariadb> select * from host_summary_by_file_io_type; +------------+--------------------------------------+-------+---------------+-------------+ | host | event_name | total | total_latency | max_latency | +------------+--------------------------------------+-------+---------------+-------------+ @@ -225,7 +225,7 @@ When the host found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc host_summary_by_stages; +mariadb> desc host_summary_by_stages; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -237,7 +237,7 @@ mysql> desc host_summary_by_stages; +---------------+---------------------+------+-----+---------+-------+ 5 rows in set (0.06 sec) -mysql> desc x$host_summary_by_stages; +mariadb> desc x$host_summary_by_stages; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -253,7 +253,7 @@ mysql> desc x$host_summary_by_stages; ##### Example ```SQL - mysql> select * from host_summary_by_stages; + mariadb> select * from host_summary_by_stages; +------+--------------------------------+-------+---------------+-------------+ | host | event_name | total | total_latency | avg_latency | +------+--------------------------------+-------+---------------+-------------+ @@ -287,7 +287,7 @@ When the host found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc host_summary_by_statement_latency; +mariadb> desc host_summary_by_statement_latency; +---------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------+------+-----+---------+-------+ @@ -303,7 +303,7 @@ mysql> desc host_summary_by_statement_latency; +---------------+---------------+------+-----+---------+-------+ 9 rows in set (0.29 sec) -mysql> desc x$host_summary_by_statement_latency; +mariadb> desc x$host_summary_by_statement_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -323,7 +323,7 @@ mysql> desc x$host_summary_by_statement_latency; ##### Example ```SQL - mysql> select * from host_summary_by_statement_latency; + mariadb> select * from host_summary_by_statement_latency; +------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+ | host | total | total_latency | max_latency | lock_latency | rows_sent | rows_examined | rows_affected | full_scans | +------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+ @@ -342,7 +342,7 @@ When the host found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc host_summary_by_statement_type; +mariadb> desc host_summary_by_statement_type; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -359,7 +359,7 @@ mysql> desc host_summary_by_statement_type; +---------------+---------------------+------+-----+---------+-------+ 10 rows in set (0.30 sec) -mysql> desc x$host_summary_by_statement_type; +mariadb> desc x$host_summary_by_statement_type; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -380,7 +380,7 @@ mysql> desc x$host_summary_by_statement_type; ##### Example ```SQL - mysql> select * from host_summary_by_statement_type; + mariadb> select * from host_summary_by_statement_type; +------+----------------------+--------+---------------+-------------+--------------+-----------+---------------+---------------+------------+ | host | statement | total | total_latency | max_latency | lock_latency | rows_sent | rows_examined | rows_affected | full_scans | +------+----------------------+--------+---------------+-------------+--------------+-----------+---------------+---------------+------------+ @@ -402,7 +402,7 @@ Summarizes the output of the INFORMATION_SCHEMA.INNODB_BUFFER_PAGE table, aggreg ##### Structures ```SQL -mysql> desc innodb_buffer_stats_by_schema; +mariadb> desc innodb_buffer_stats_by_schema; +---------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------+------+-----+---------+-------+ @@ -416,7 +416,7 @@ mysql> desc innodb_buffer_stats_by_schema; +---------------+---------------+------+-----+---------+-------+ 7 rows in set (0.08 sec) -mysql> desc x$innodb_buffer_stats_by_schema; +mariadb> desc x$innodb_buffer_stats_by_schema; +---------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------+------+-----+---------+-------+ @@ -434,7 +434,7 @@ mysql> desc x$innodb_buffer_stats_by_schema; ##### Example ```SQL -mysql> select * from innodb_buffer_stats_by_schema; +mariadb> select * from innodb_buffer_stats_by_schema; +--------------------------+------------+------------+-------+--------------+-----------+-------------+ | object_schema | allocated | data | pages | pages_hashed | pages_old | rows_cached | +--------------------------+------------+------------+-------+--------------+-----------+-------------+ @@ -453,7 +453,7 @@ Summarizes the output of the INFORMATION_SCHEMA.INNODB_BUFFER_PAGE table, aggreg ##### Structures ```SQL -mysql> desc innodb_buffer_stats_by_table; +mariadb> desc innodb_buffer_stats_by_table; +---------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------+------+-----+---------+-------+ @@ -468,7 +468,7 @@ mysql> desc innodb_buffer_stats_by_table; +---------------+---------------+------+-----+---------+-------+ 8 rows in set (0.09 sec) -mysql> desc x$innodb_buffer_stats_by_table; +mariadb> desc x$innodb_buffer_stats_by_table; +---------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------+------+-----+---------+-------+ @@ -487,7 +487,7 @@ mysql> desc x$innodb_buffer_stats_by_table; ##### Example ```SQL -mysql> select * from innodb_buffer_stats_by_table; +mariadb> select * from innodb_buffer_stats_by_table; +--------------------------+------------------------------------+------------+-----------+-------+--------------+-----------+-------------+ | object_schema | object_name | allocated | data | pages | pages_hashed | pages_old | rows_cached | +--------------------------+------------------------------------+------------+-----------+-------+--------------+-----------+-------------+ @@ -531,7 +531,7 @@ The lock waits are ordered by the age of the lock descending. ##### Structures ```SQL -mysql> desc sys.innodb_lock_waits; +mariadb> desc sys.innodb_lock_waits; +------------------------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------------+---------------------+------+-----+---------------------+-------+ @@ -564,7 +564,7 @@ mysql> desc sys.innodb_lock_waits; +------------------------------+---------------------+------+-----+---------------------+-------+ 26 rows in set (0.01 sec) -mysql> desc sys.x$innodb_lock_waits; +mariadb> desc sys.x$innodb_lock_waits; +------------------------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------------+---------------------+------+-----+---------------------+-------+ @@ -601,7 +601,7 @@ mysql> desc sys.x$innodb_lock_waits; ##### Example ```SQL -mysql> SELECT * FROM innodb_lock_waits\G +mariadb> SELECT * FROM innodb_lock_waits\G *************************** 1. row *************************** wait_started: 2014-11-11 13:39:20 wait_age: 00:00:07 @@ -640,7 +640,7 @@ Shows the top IO consumers by thread, ordered by total latency. ##### Structures ```SQL -mysql> desc io_by_thread_by_latency; +mariadb> desc io_by_thread_by_latency; +----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------+-------+ @@ -655,7 +655,7 @@ mysql> desc io_by_thread_by_latency; +----------------+---------------------+------+-----+---------+-------+ 8 rows in set (0.14 sec) -mysql> desc x$io_by_thread_by_latency; +mariadb> desc x$io_by_thread_by_latency; +----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------+-------+ @@ -674,7 +674,7 @@ mysql> desc x$io_by_thread_by_latency; ##### Example ```SQL -mysql> select * from io_by_thread_by_latency; +mariadb> select * from io_by_thread_by_latency; +---------------------+-------+---------------+-------------+-------------+-------------+-----------+----------------+ | user | total | total_latency | min_latency | avg_latency | max_latency | thread_id | processlist_id | +---------------------+-------+---------------+-------------+-------------+-------------+-----------+----------------+ @@ -701,7 +701,7 @@ Shows the top global IO consumers by bytes usage by file. ##### Structures ```SQL -mysql> desc io_global_by_file_by_bytes; +mariadb> desc io_global_by_file_by_bytes; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -717,7 +717,7 @@ mysql> desc io_global_by_file_by_bytes; +---------------+---------------------+------+-----+---------+-------+ 9 rows in set (0.15 sec) -mysql> desc x$io_global_by_file_by_bytes; +mariadb> desc x$io_global_by_file_by_bytes; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -737,7 +737,7 @@ mysql> desc x$io_global_by_file_by_bytes; ##### Example ```SQL -mysql> SELECT * FROM io_global_by_file_by_bytes LIMIT 5; +mariadb> SELECT * FROM io_global_by_file_by_bytes LIMIT 5; +--------------------------------------------+------------+------------+-----------+-------------+---------------+-----------+------------+-----------+ | file | count_read | total_read | avg_read | count_write | total_written | avg_write | total | write_pct | +--------------------------------------------+------------+------------+-----------+-------------+---------------+-----------+------------+-----------+ @@ -758,7 +758,7 @@ Shows the top global IO consumers by latency by file. ##### Structures ```SQL -mysql> desc io_global_by_file_by_latency; +mariadb> desc io_global_by_file_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -774,7 +774,7 @@ mysql> desc io_global_by_file_by_latency; +---------------+---------------------+------+-----+---------+-------+ 9 rows in set (0.00 sec) -mysql> desc x$io_global_by_file_by_latency; +mariadb> desc x$io_global_by_file_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -794,7 +794,7 @@ mysql> desc x$io_global_by_file_by_latency; ##### Example ```SQL -mysql> select * from io_global_by_file_by_latency limit 5; +mariadb> select * from io_global_by_file_by_latency limit 5; +-----------------------------------------------------------+-------+---------------+------------+--------------+-------------+---------------+------------+--------------+ | file | total | total_latency | count_read | read_latency | count_write | write_latency | count_misc | misc_latency | +-----------------------------------------------------------+-------+---------------+------------+--------------+-------------+---------------+------------+--------------+ @@ -815,7 +815,7 @@ Shows the top global IO consumer classes by bytes usage. ##### Structures ```SQL -mysql> desc io_global_by_wait_by_bytes; +mariadb> desc io_global_by_wait_by_bytes; +-----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+---------------------+------+-----+---------+-------+ @@ -835,7 +835,7 @@ mysql> desc io_global_by_wait_by_bytes; +-----------------+---------------------+------+-----+---------+-------+ 13 rows in set (0.02 sec) -mysql> desc x$io_global_by_wait_by_bytes; +mariadb> desc x$io_global_by_wait_by_bytes; +-----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+---------------------+------+-----+---------+-------+ @@ -859,7 +859,7 @@ mysql> desc x$io_global_by_wait_by_bytes; ##### Example ```SQL -mysql> select * from io_global_by_wait_by_bytes; +mariadb> select * from io_global_by_wait_by_bytes; +--------------------+--------+---------------+-------------+-------------+-------------+------------+------------+-----------+-------------+---------------+-------------+-----------------+ | event_name | total | total_latency | min_latency | avg_latency | max_latency | count_read | total_read | avg_read | count_write | total_written | avg_written | total_requested | +--------------------+--------+---------------+-------------+-------------+-------------+------------+------------+-----------+-------------+---------------+-------------+-----------------+ @@ -891,7 +891,7 @@ Shows the top global IO consumers by latency. ##### Structures ```SQL -mysql> desc io_global_by_wait_by_latency; +mariadb> desc io_global_by_wait_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -912,7 +912,7 @@ mysql> desc io_global_by_wait_by_latency; +---------------+---------------------+------+-----+---------+-------+ 14 rows in set (0.19 sec) -mysql> desc x$io_global_by_wait_by_latency; +mariadb> desc x$io_global_by_wait_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -937,7 +937,7 @@ mysql> desc x$io_global_by_wait_by_latency; ##### Example ```SQL -mysql> SELECT * FROM io_global_by_wait_by_latency; +mariadb> SELECT * FROM io_global_by_wait_by_latency; +-------------------------+-------+---------------+-------------+-------------+--------------+---------------+--------------+------------+------------+-----------+-------------+---------------+-------------+ | event_name | total | total_latency | avg_latency | max_latency | read_latency | write_latency | misc_latency | count_read | total_read | avg_read | count_write | total_written | avg_written | +-------------------------+-------+---------------+-------------+-------------+--------------+---------------+--------------+------------+------------+-----------+-------------+---------------+-------------+ @@ -969,7 +969,7 @@ Shows the latest file IO, by file / thread. ##### Structures ```SQL -mysql> desc latest_file_io; +mariadb> desc latest_file_io; +-----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+-------+ @@ -981,7 +981,7 @@ mysql> desc latest_file_io; +-----------+--------------+------+-----+---------+-------+ 5 rows in set (0.10 sec) -mysql> desc x$latest_file_io; +mariadb> desc x$latest_file_io; +-----------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+---------------------+------+-----+---------+-------+ @@ -997,7 +997,7 @@ mysql> desc x$latest_file_io; ##### Example ```SQL -mysql> select * from latest_file_io limit 5; +mariadb> select * from latest_file_io limit 5; +----------------------+----------------------------------------+------------+-----------+-----------+ | thread | file | latency | operation | requested | +----------------------+----------------------------------------+------------+-----------+-----------+ @@ -1013,14 +1013,14 @@ mysql> select * from latest_file_io limit 5; ##### Description -Summarizes memory use by host using the 5.7 Performance Schema instrumentation. +Summarizes memory use by host using the Performance Schema instrumentation. When the host found is NULL, it is assumed to be a local "background" thread. ##### Structures ```SQL -mysql> desc memory_by_host_by_current_bytes; +mariadb> desc memory_by_host_by_current_bytes; +--------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------+---------------+------+-----+---------+-------+ @@ -1033,7 +1033,7 @@ mysql> desc memory_by_host_by_current_bytes; +--------------------+---------------+------+-----+---------+-------+ 6 rows in set (0.24 sec) -mysql> desc x$memory_by_host_by_current_bytes; +mariadb> desc x$memory_by_host_by_current_bytes; +--------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------+---------------+------+-----+---------+-------+ @@ -1050,7 +1050,7 @@ mysql> desc x$memory_by_host_by_current_bytes; ##### Example ```SQL -mysql> select * from memory_by_host_by_current_bytes WHERE host IS NOT NULL; +mariadb> select * from memory_by_host_by_current_bytes WHERE host IS NOT NULL; +------------+--------------------+-------------------+-------------------+-------------------+-----------------+ | host | current_count_used | current_allocated | current_avg_alloc | current_max_alloc | total_allocated | +------------+--------------------+-------------------+-------------------+-------------------+-----------------+ @@ -1063,14 +1063,14 @@ mysql> select * from memory_by_host_by_current_bytes WHERE host IS NOT NULL; ##### Description -Summarizes memory use by user using the 5.7 Performance Schema instrumentation. +Summarizes memory use by user using the Performance Schema instrumentation. The user columns shows either the background or foreground user name appropriately. ##### Structures ```SQL -mysql> desc memory_by_thread_by_current_bytes; +mariadb> desc memory_by_thread_by_current_bytes; +--------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------+---------------------+------+-----+---------+-------+ @@ -1084,7 +1084,7 @@ mysql> desc memory_by_thread_by_current_bytes; +--------------------+---------------------+------+-----+---------+-------+ 7 rows in set (0.49 sec) -mysql> desc x$memory_by_thread_by_current_bytes; +mariadb> desc x$memory_by_thread_by_current_bytes; +--------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------+---------------------+------+-----+---------+-------+ @@ -1102,7 +1102,7 @@ mysql> desc x$memory_by_thread_by_current_bytes; ##### Example ```SQL -mysql> select * from sys.memory_by_thread_by_current_bytes limit 5; +mariadb> select * from sys.memory_by_thread_by_current_bytes limit 5; +-----------+----------------+--------------------+-------------------+-------------------+-------------------+-----------------+ | thread_id | user | current_count_used | current_allocated | current_avg_alloc | current_max_alloc | total_allocated | +-----------+----------------+--------------------+-------------------+-------------------+-------------------+-----------------+ @@ -1118,14 +1118,14 @@ mysql> select * from sys.memory_by_thread_by_current_bytes limit 5; ##### Description -Summarizes memory use by user using the 5.7 Performance Schema instrumentation. +Summarizes memory use by user using the Performance Schema instrumentation. When the user found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc memory_by_user_by_current_bytes; +mariadb> desc memory_by_user_by_current_bytes; +--------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------+---------------+------+-----+---------+-------+ @@ -1138,7 +1138,7 @@ mysql> desc memory_by_user_by_current_bytes; +--------------------+---------------+------+-----+---------+-------+ 6 rows in set (0.06 sec) -mysql> desc x$memory_by_user_by_current_bytes; +mariadb> desc x$memory_by_user_by_current_bytes; +--------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------+---------------+------+-----+---------+-------+ @@ -1155,7 +1155,7 @@ mysql> desc x$memory_by_user_by_current_bytes; ##### Example ```SQL -mysql> select * from memory_by_user_by_current_bytes; +mariadb> select * from memory_by_user_by_current_bytes; +------+--------------------+-------------------+-------------------+-------------------+-----------------+ | user | current_count_used | current_allocated | current_avg_alloc | current_max_alloc | total_allocated | +------+--------------------+-------------------+-------------------+-------------------+-----------------+ @@ -1173,7 +1173,7 @@ Shows the current memory usage within the server globally broken down by allocat ##### Structures ```SQL -mysql> desc memory_global_by_current_bytes; +mariadb> desc memory_global_by_current_bytes; +-------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+--------------+------+-----+---------+-------+ @@ -1187,7 +1187,7 @@ mysql> desc memory_global_by_current_bytes; +-------------------+--------------+------+-----+---------+-------+ 7 rows in set (0.08 sec) -mysql> desc x$memory_global_by_current_bytes; +mariadb> desc x$memory_global_by_current_bytes; +-------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------+------+-----+---------+-------+ @@ -1205,7 +1205,7 @@ mysql> desc x$memory_global_by_current_bytes; ##### Example ```SQL -mysql> select * from memory_global_by_current_bytes; +mariadb> select * from memory_global_by_current_bytes; +----------------------------------------+---------------+---------------+-------------------+------------+------------+----------------+ | event_name | current_count | current_alloc | current_avg_alloc | high_count | high_alloc | high_avg_alloc | +----------------------------------------+---------------+---------------+-------------------+------------+------------+----------------+ @@ -1227,7 +1227,7 @@ Shows the total memory usage within the server globally. ##### Structures ```SQL -mysql> desc memory_global_total; +mariadb> desc memory_global_total; +-----------------+------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+------+------+-----+---------+-------+ @@ -1235,7 +1235,7 @@ mysql> desc memory_global_total; +-----------------+------+------+-----+---------+-------+ 1 row in set (0.07 sec) -mysql> desc x$memory_global_total; +mariadb> desc x$memory_global_total; +-----------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+---------------+------+-----+---------+-------+ @@ -1247,7 +1247,7 @@ mysql> desc x$memory_global_total; ##### Example ```SQL -mysql> select * from memory_global_total; +mariadb> select * from memory_global_total; +-----------------+ | total_allocated | +-----------------+ @@ -1261,12 +1261,12 @@ mysql> select * from memory_global_total; Creates a union of the following information: - * performance_schema.global_status (information_schema.GLOBAL_STATUS in MySQL 5.6) + * performance_schema.global_status * information_schema.INNODB_METRICS - * Performance Schema global memory usage information (only in MySQL 5.7) + * Performance Schema global memory usage information * Current time -In MySQL 5.7 it is required that performance_schema = ON, though there is no requirements to which +It is required that performance_schema = ON, though there is no requirements to which instruments and consumers that are enabled. See also the description of the Enabled column below. For view has the following columns: @@ -1280,7 +1280,7 @@ For view has the following columns: ##### Structures ```SQL -mysql> DESC metrics; +mariadb> DESC metrics; +----------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+-------+ @@ -1306,7 +1306,7 @@ mysq> DESC metrics_56; ##### Example ```SQL -mysql> SELECT * FROM metrics; +mariadb> SELECT * FROM metrics; +-----------------------------------------------+-------------------------...+--------------------------------------+---------+ | Variable_name | Variable_value ...| Type | Enabled | +-----------------------------------------------+-------------------------...+--------------------------------------+---------+ @@ -1348,10 +1348,10 @@ Performs less locking than the legacy sources, whilst giving extra information. The output includes both background threads and user connections by default. See also `session` / `x$session` for a view that contains only user session information. -##### Structures (5.7) +##### Structures ```SQL -mysql> desc processlist; +mariadb> desc processlist; +------------------------+------------------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+------------------------------------------+------+-----+---------+-------+ @@ -1386,7 +1386,7 @@ mysql> desc processlist; +------------------------+------------------------------------------+------+-----+---------+-------+ 28 rows in set (0.04 sec) -mysql> desc x$processlist; +mariadb> desc x$processlist; +------------------------+------------------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+------------------------------------------+------+-----+---------+-------+ @@ -1425,7 +1425,7 @@ mysql> desc x$processlist; ##### Example ```SQL -mysql> select * from sys.processlist where conn_id is not null and command != 'daemon' and conn_id != connection_id()\G +mariadb> select * from sys.processlist where conn_id is not null and command != 'daemon' and conn_id != connection_id()\G *************************** 1. row *************************** thd_id: 44524 conn_id: 44502 @@ -1466,7 +1466,7 @@ Used to check whether Performance Schema is not able to monitor all runtime data ##### Structure ```SQL -mysql> desc ps_check_lost_instrumentation; +mariadb> desc ps_check_lost_instrumentation; +----------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------+------+-----+---------+-------+ @@ -1479,7 +1479,7 @@ mysql> desc ps_check_lost_instrumentation; ##### Example ```SQL -mysql> select * from ps_check_lost_instrumentation; +mariadb> select * from ps_check_lost_instrumentation; +----------------------------------------+----------------+ | variable_name | variable_value | +----------------------------------------+----------------+ @@ -1497,7 +1497,7 @@ Present current auto_increment usage/capacity in all tables. ##### Structures ```SQL -mysql> desc schema_auto_increment_columns; +mariadb> desc schema_auto_increment_columns; +----------------------+------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------------+------------------------+------+-----+---------+-------+ @@ -1517,7 +1517,7 @@ mysql> desc schema_auto_increment_columns; ##### Example ```SQL -mysql> select * from schema_auto_increment_columns limit 5; +mariadb> select * from schema_auto_increment_columns limit 5; +-------------------+-------------------+-------------+-----------+-------------+-----------+-------------+---------------------+----------------+----------------------+ | table_schema | table_name | column_name | data_type | column_type | is_signed | is_unsigned | max_value | auto_increment | auto_increment_ratio | +-------------------+-------------------+-------------+-----------+-------------+-----------+-------------+---------------------+----------------+----------------------+ @@ -1540,7 +1540,7 @@ Ordered by the total wait time descending - top indexes are most contended. ##### Structures ```SQL -mysql> desc schema_index_statistics; +mariadb> desc schema_index_statistics; +----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------+-------+ @@ -1558,7 +1558,7 @@ mysql> desc schema_index_statistics; +----------------+---------------------+------+-----+---------+-------+ 11 rows in set (0.17 sec) -mysql> desc x$schema_index_statistics; +mariadb> desc x$schema_index_statistics; +----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------+-------+ @@ -1580,7 +1580,7 @@ mysql> desc x$schema_index_statistics; ##### Example ```SQL -mysql> select * from schema_index_statistics limit 5; +mariadb> select * from schema_index_statistics limit 5; +------------------+-------------+------------+---------------+----------------+---------------+----------------+--------------+----------------+--------------+----------------+ | table_schema | table_name | index_name | rows_selected | select_latency | rows_inserted | insert_latency | rows_updated | update_latency | rows_deleted | delete_latency | +------------------+-------------+------------+---------------+----------------+---------------+----------------+--------------+----------------+--------------+----------------+ @@ -1603,7 +1603,7 @@ Note: On instances with a large numbers of objects, this could take some time to ##### Structure ```SQL -mysql> desc schema_object_overview; +mariadb> desc schema_object_overview; +-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ @@ -1617,7 +1617,7 @@ mysql> desc schema_object_overview; ##### Example ```SQL -mysql> select * from schema_object_overview; +mariadb> select * from schema_object_overview; +--------------------+---------------+-------+ | db | object_type | count | +--------------------+---------------+-------+ @@ -1650,7 +1650,7 @@ Also includes the helper view (used by schema_table_statistics_with_buffer as we ##### Structures ```SQL -mysql> desc schema_table_statistics; +mariadb> desc schema_table_statistics; +-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ @@ -1676,7 +1676,7 @@ mysql> desc schema_table_statistics; +-------------------+---------------------+------+-----+---------+-------+ 19 rows in set (0.12 sec) -mysql> desc x$schema_table_statistics; +mariadb> desc x$schema_table_statistics; +-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ @@ -1702,7 +1702,7 @@ mysql> desc x$schema_table_statistics; +-------------------+---------------------+------+-----+---------+-------+ 19 rows in set (0.13 sec) -mysql> desc x$ps_schema_table_statistics_io; +mariadb> desc x$ps_schema_table_statistics_io; +---------------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------------------+---------------+------+-----+---------+-------+ @@ -1723,7 +1723,7 @@ mysql> desc x$ps_schema_table_statistics_io; ##### Example ```SQL -mysql> select * from schema_table_statistics\G +mariadb> select * from schema_table_statistics\G *************************** 1. row *************************** table_schema: sys table_name: sys_config @@ -1757,7 +1757,7 @@ Also includes the the helper view `x$schema_flattened_keys`. ##### Structures ```SQL -mysql> desc sys.schema_redundant_indexes; +mariadb> desc sys.schema_redundant_indexes; +----------------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------------------+--------------+------+-----+---------+-------+ @@ -1774,7 +1774,7 @@ mysql> desc sys.schema_redundant_indexes; +----------------------------+--------------+------+-----+---------+-------+ 10 rows in set (0.00 sec) -mysql> desc sys.x$schema_flattened_keys; +mariadb> desc sys.x$schema_flattened_keys; +----------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+-------------+------+-----+---------+-------+ @@ -1791,7 +1791,7 @@ mysql> desc sys.x$schema_flattened_keys; ##### Example ```SQL -mysql> select * from sys.schema_redundant_indexes\G +mariadb> select * from sys.schema_redundant_indexes\G *************************** 1. row *************************** table_schema: test table_name: rkey @@ -1805,7 +1805,7 @@ redundant_index_non_unique: 1 sql_drop_index: ALTER TABLE `test`.`rkey` DROP INDEX `j` 1 row in set (0.20 sec) -mysql> SHOW CREATE TABLE test.rkey\G +mariadb> SHOW CREATE TABLE test.rkey\G *************************** 1. row *************************** Table: rkey Create Table: CREATE TABLE `rkey` ( @@ -1828,7 +1828,7 @@ Shows sessions that are blocked waiting on table metadata locks, and who is bloc ##### Structures ```SQL -mysql> desc schema_table_lock_waits; +mariadb> desc schema_table_lock_waits; +------------------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------------+---------------------+------+-----+---------+-------+ @@ -1853,7 +1853,7 @@ mysql> desc schema_table_lock_waits; +------------------------------+---------------------+------+-----+---------+-------+ 18 rows in set (0.15 sec) -mysql> desc x$schema_table_lock_waits; +mariadb> desc x$schema_table_lock_waits; +------------------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------------+---------------------+------+-----+---------+-------+ @@ -1882,7 +1882,7 @@ mysql> desc x$schema_table_lock_waits; ##### Example ```SQL -mysql> select * from sys.schema_table_lock_waits\G +mariadb> select * from sys.schema_table_lock_waits\G *************************** 1. row *************************** object_schema: test object_name: t @@ -1919,7 +1919,7 @@ Uses the x$ps_schema_table_statistics_io helper view from schema_table_statistic ##### Structures ```SQL -mysql> desc schema_table_statistics_with_buffer; +mariadb> desc schema_table_statistics_with_buffer; +----------------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------------------+---------------------+------+-----+---------+-------+ @@ -1951,7 +1951,7 @@ mysql> desc schema_table_statistics_with_buffer; +----------------------------+---------------------+------+-----+---------+-------+ 25 rows in set (0.05 sec) -mysql> desc x$schema_table_statistics_with_buffer; +mariadb> desc x$schema_table_statistics_with_buffer; +----------------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------------------+---------------------+------+-----+---------+-------+ @@ -1987,7 +1987,7 @@ mysql> desc x$schema_table_statistics_with_buffer; ##### Example ```SQL -mysql> select * from schema_table_statistics_with_buffer limit 1\G +mariadb> select * from schema_table_statistics_with_buffer limit 1\G *************************** 1. row *************************** table_schema: mem table_name: mysqlserver @@ -2024,7 +2024,7 @@ Finds tables that are being accessed by full table scans ordering by the number ##### Structures ```SQL -mysql> desc schema_tables_with_full_table_scans; +mariadb> desc schema_tables_with_full_table_scans; +-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ @@ -2035,7 +2035,7 @@ mysql> desc schema_tables_with_full_table_scans; +-------------------+---------------------+------+-----+---------+-------+ 4 rows in set (0.02 sec) -mysql> desc x$schema_tables_with_full_table_scans; +mariadb> desc x$schema_tables_with_full_table_scans; +-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ @@ -2050,7 +2050,7 @@ mysql> desc x$schema_tables_with_full_table_scans; ##### Example ```SQL -mysql> select * from schema_tables_with_full_table_scans limit 5; +mariadb> select * from schema_tables_with_full_table_scans limit 5; +--------------------+--------------------------------+-------------------+-----------+ | object_schema | object_name | rows_full_scanned | latency | +--------------------+--------------------------------+-------------------+-----------+ @@ -2075,7 +2075,7 @@ PRIMARY (key) indexes are ignored. ##### Structure ```SQL -mysql> desc schema_unused_indexes; +mariadb> desc schema_unused_indexes; +---------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+-------+ @@ -2089,7 +2089,7 @@ mysql> desc schema_unused_indexes; ##### Example ```SQL -mysql> select * from schema_unused_indexes limit 5; +mariadb> select * from schema_unused_indexes limit 5; +--------------------+---------------------+--------------------+ | object_schema | object_name | index_name | +--------------------+---------------------+--------------------+ @@ -2111,10 +2111,10 @@ Performs less locking than the legacy sources, whilst giving extra information. The output of this view is restricted to threads from user sessions. See also processlist / x$processlist which contains both user and background threads. -##### Structures (5.7) +##### Structures ```SQL -mysql> desc session; +mariadb> desc session; +------------------------+------------------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+------------------------------------------+------+-----+---------+-------+ @@ -2149,7 +2149,7 @@ mysql> desc session; +------------------------+------------------------------------------+------+-----+---------+-------+ 28 rows in set (0.00 sec) -mysql> desc x$session; +mariadb> desc x$session; +------------------------+------------------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+------------------------------------------+------+-----+---------+-------+ @@ -2188,7 +2188,7 @@ mysql> desc x$session; ##### Example ```SQL -mysql> select * from sys.session\G +mariadb> select * from sys.session\G *************************** 1. row *************************** thd_id: 24 conn_id: 2 @@ -2229,7 +2229,7 @@ Shows SSL version, cipher and the count of re-used SSL sessions per connection ##### Structures ```SQL -mysql> desc sys.session_ssl_status; +mariadb> desc sys.session_ssl_status; +---------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------------+---------------------+------+-----+---------+-------+ @@ -2244,7 +2244,7 @@ mysql> desc sys.session_ssl_status; ##### Example ```SQL -mysql> select * from session_ssl_status; +mariadb> select * from session_ssl_status; +-----------+-------------+--------------------+---------------------+ | thread_id | ssl_version | ssl_cipher | ssl_sessions_reused | +-----------+-------------+--------------------+---------------------+ @@ -2259,12 +2259,12 @@ mysql> select * from session_ssl_status; ##### Description -Lists a normalized statement view with aggregated statistics, mimics the MySQL Enterprise Monitor Query Analysis view, ordered by the total execution time per normalized statement +Lists a normalized statement view with aggregated statistics, ordered by the total execution time per normalized statement ##### Structures ```SQL -mysql> desc statement_analysis; +mariadb> desc statement_analysis; +-------------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------------------+-------+ @@ -2294,7 +2294,7 @@ mysql> desc statement_analysis; +-------------------+---------------------+------+-----+---------------------+-------+ 23 rows in set (0.26 sec) -mysql> desc x$statement_analysis; +mariadb> desc x$statement_analysis; +-------------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------------------+-------+ @@ -2328,7 +2328,7 @@ mysql> desc x$statement_analysis; ##### Example ```SQL -mysql> select * from statement_analysis limit 1\G +mariadb> select * from statement_analysis limit 1\G *************************** 1. row *************************** query: SELECT * FROM `schema_object_o ... MA` , `information_schema` ... db: sys @@ -2364,7 +2364,7 @@ Lists all normalized statements that have raised errors or warnings. ##### Structures ```SQL -mysql> desc statements_with_errors_or_warnings; +mariadb> desc statements_with_errors_or_warnings; +-------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------------+------+-----+---------------------+-------+ @@ -2381,7 +2381,7 @@ mysql> desc statements_with_errors_or_warnings; +-------------+---------------------+------+-----+---------------------+-------+ 10 rows in set (0.55 sec) -mysql> desc x$statements_with_errors_or_warnings; +mariadb> desc x$statements_with_errors_or_warnings; +-------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------------+------+-----+---------------------+-------+ @@ -2402,7 +2402,7 @@ mysql> desc x$statements_with_errors_or_warnings; ##### Example ```SQL -mysql> select * from statements_with_errors_or_warnings LIMIT 1\G +mariadb> select * from statements_with_errors_or_warnings LIMIT 1\G *************************** 1. row *************************** query: CREATE OR REPLACE ALGORITHM = ... _delete` AS `rows_deleted` ... db: sys @@ -2427,7 +2427,7 @@ This view ignores SHOW statements, as these always cause a full table scan, and ##### Structures ```SQL -mysql> desc statements_with_full_table_scans; +mariadb> desc statements_with_full_table_scans; +--------------------------+------------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------------+------------------------+------+-----+---------------------+-------+ @@ -2448,7 +2448,7 @@ mysql> desc statements_with_full_table_scans; +--------------------------+------------------------+------+-----+---------------------+-------+ 14 rows in set (0.04 sec) -mysql> desc x$statements_with_full_table_scans; +mariadb> desc x$statements_with_full_table_scans; +--------------------------+------------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------------+------------------------+------+-----+---------------------+-------+ @@ -2473,7 +2473,7 @@ mysql> desc x$statements_with_full_table_scans; ##### Example ```SQL -mysql> select * from statements_with_full_table_scans limit 1\G +mariadb> select * from statements_with_full_table_scans limit 1\G *************************** 1. row *************************** query: SELECT * FROM `schema_tables_w ... ex_usage` . `COUNT_READ` DESC db: sys @@ -2505,7 +2505,7 @@ Also includes two helper views: ##### Structures ```SQL -mysql> desc statements_with_runtimes_in_95th_percentile; +mariadb> desc statements_with_runtimes_in_95th_percentile; +-------------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------------------+-------+ @@ -2528,7 +2528,7 @@ mysql> desc statements_with_runtimes_in_95th_percentile; +-------------------+---------------------+------+-----+---------------------+-------+ 16 rows in set (0.11 sec) -mysql> desc x$statements_with_runtimes_in_95th_percentile; +mariadb> desc x$statements_with_runtimes_in_95th_percentile; +-------------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------------------+-------+ @@ -2551,7 +2551,7 @@ mysql> desc x$statements_with_runtimes_in_95th_percentile; +-------------------+---------------------+------+-----+---------------------+-------+ 16 rows in set (0.00 sec) -mysql> desc x$ps_digest_avg_latency_distribution; +mariadb> desc x$ps_digest_avg_latency_distribution; +--------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+---------------+------+-----+---------+-------+ @@ -2560,7 +2560,7 @@ mysql> desc x$ps_digest_avg_latency_distribution; +--------+---------------+------+-----+---------+-------+ 2 rows in set (0.10 sec) -mysql> desc x$ps_digest_95th_percentile_by_avg_us; +mariadb> desc x$ps_digest_95th_percentile_by_avg_us; +------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+---------------+------+-----+---------+-------+ @@ -2573,7 +2573,7 @@ mysql> desc x$ps_digest_95th_percentile_by_avg_us; ##### Example ```SQL -mysql> select * from statements_with_runtimes_in_95th_percentile\G +mariadb> select * from statements_with_runtimes_in_95th_percentile\G *************************** 1. row *************************** query: SELECT * FROM `schema_object_o ... MA` , `information_schema` ... db: sys @@ -2602,7 +2602,7 @@ Lists all normalized statements that have done sorts, ordered by total_latency d ##### Structures ```SQL -mysql> desc statements_with_sorting; +mariadb> desc statements_with_sorting; +-------------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------------------+-------+ @@ -2622,7 +2622,7 @@ mysql> desc statements_with_sorting; +-------------------+---------------------+------+-----+---------------------+-------+ 13 rows in set (0.01 sec) -mysql> desc x$statements_with_sorting; +mariadb> desc x$statements_with_sorting; +-------------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------------------+-------+ @@ -2646,7 +2646,7 @@ mysql> desc x$statements_with_sorting; ##### Example ```SQL -mysql> select * from statements_with_sorting limit 1\G +mariadb> select * from statements_with_sorting limit 1\G *************************** 1. row *************************** query: SELECT * FROM `schema_object_o ... MA` , `information_schema` ... db: sys @@ -2672,7 +2672,7 @@ Lists all normalized statements that use temporary tables ordered by number of o ##### Structures ```SQL -mysql> desc statements_with_temp_tables; +mariadb> desc statements_with_temp_tables; +--------------------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------------+---------------------+------+-----+---------------------+-------+ @@ -2690,7 +2690,7 @@ mysql> desc statements_with_temp_tables; +--------------------------+---------------------+------+-----+---------------------+-------+ 11 rows in set (0.30 sec) -mysql> desc x$statements_with_temp_tables; +mariadb> desc x$statements_with_temp_tables; +--------------------------+---------------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------------+---------------------+------+-----+---------------------+-------+ @@ -2712,7 +2712,7 @@ mysql> desc x$statements_with_temp_tables; ##### Example ```SQL -mysql> select * from statements_with_temp_tables limit 1\G +mariadb> select * from statements_with_temp_tables limit 1\G *************************** 1. row *************************** query: SELECT * FROM `schema_object_o ... MA` , `information_schema` ... db: sys @@ -2735,10 +2735,10 @@ Summarizes statement activity, file IO and connections by user. When the user found is NULL, it is assumed to be a "background" thread. -##### Structures (5.7) +##### Structures ```SQL -mysql> desc user_summary; +mariadb> desc user_summary; +------------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+---------------+------+-----+---------+-------+ @@ -2757,7 +2757,7 @@ mysql> desc user_summary; +------------------------+---------------+------+-----+---------+-------+ 12 rows in set (0.00 sec) -mysql> desc x$user_summary; +mariadb> desc x$user_summary; +------------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+---------------+------+-----+---------+-------+ @@ -2780,7 +2780,7 @@ mysql> desc x$user_summary; ##### Example ```SQL -mysql> select * from user_summary\G +mariadb> select * from user_summary\G *************************** 1. row *************************** user: root statements: 4981 @@ -2820,7 +2820,7 @@ When the user found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc user_summary_by_file_io; +mariadb> desc user_summary_by_file_io; +------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+---------------+------+-----+---------+-------+ @@ -2830,7 +2830,7 @@ mysql> desc user_summary_by_file_io; +------------+---------------+------+-----+---------+-------+ 3 rows in set (0.20 sec) -mysql> desc x$user_summary_by_file_io; +mariadb> desc x$user_summary_by_file_io; +------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+---------------+------+-----+---------+-------+ @@ -2844,7 +2844,7 @@ mysql> desc x$user_summary_by_file_io; ##### Example ```SQL -mysql> select * from user_summary_by_file_io; +mariadb> select * from user_summary_by_file_io; +------------+-------+------------+ | user | ios | io_latency | +------------+-------+------------+ @@ -2864,7 +2864,7 @@ When the user found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc user_summary_by_file_io_type; +mariadb> desc user_summary_by_file_io_type; +-------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------------+------+-----+---------+-------+ @@ -2876,7 +2876,7 @@ mysql> desc user_summary_by_file_io_type; +-------------+---------------------+------+-----+---------+-------+ 5 rows in set (0.02 sec) -mysql> desc x$user_summary_by_file_io_type; +mariadb> desc x$user_summary_by_file_io_type; +-------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------------+------+-----+---------+-------+ @@ -2892,7 +2892,7 @@ mysql> desc x$user_summary_by_file_io_type; ##### Example ```SQL -mysql> select * from user_summary_by_file_io_type; +mariadb> select * from user_summary_by_file_io_type; +------------+--------------------------------------+-------+-----------+-------------+ | user | event_name | total | latency | max_latency | +------------+--------------------------------------+-------+-----------+-------------+ @@ -2936,7 +2936,7 @@ When the user found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc user_summary_by_stages; +mariadb> desc user_summary_by_stages; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -2948,7 +2948,7 @@ mysql> desc user_summary_by_stages; +---------------+---------------------+------+-----+---------+-------+ 5 rows in set (0.01 sec) -mysql> desc x$user_summary_by_stages; +mariadb> desc x$user_summary_by_stages; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -2964,7 +2964,7 @@ mysql> desc x$user_summary_by_stages; ##### Example ```SQL -mysql> select * from user_summary_by_stages; +mariadb> select * from user_summary_by_stages; +------+--------------------------------+-------+---------------+-------------+ | user | event_name | total | total_latency | avg_latency | +------+--------------------------------+-------+---------------+-------------+ @@ -2998,7 +2998,7 @@ When the user found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc user_summary_by_statement_latency; +mariadb> desc user_summary_by_statement_latency; +---------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------+------+-----+---------+-------+ @@ -3014,7 +3014,7 @@ mysql> desc user_summary_by_statement_latency; +---------------+---------------+------+-----+---------+-------+ 9 rows in set (0.00 sec) -mysql> desc x$user_summary_by_statement_latency; +mariadb> desc x$user_summary_by_statement_latency; +---------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------+------+-----+---------+-------+ @@ -3034,7 +3034,7 @@ mysql> desc x$user_summary_by_statement_latency; ##### Example ```SQL -mysql> select * from user_summary_by_statement_latency; +mariadb> select * from user_summary_by_statement_latency; +------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+ | user | total | total_latency | max_latency | lock_latency | rows_sent | rows_examined | rows_affected | full_scans | +------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+ @@ -3053,7 +3053,7 @@ When the user found is NULL, it is assumed to be a "background" thread. ##### Structures ```SQL -mysql> desc user_summary_by_statement_type; +mariadb> desc user_summary_by_statement_type; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -3070,7 +3070,7 @@ mysql> desc user_summary_by_statement_type; +---------------+---------------------+------+-----+---------+-------+ 10 rows in set (0.21 sec) -mysql> desc x$user_summary_by_statement_type; +mariadb> desc x$user_summary_by_statement_type; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -3091,7 +3091,7 @@ mysql> desc x$user_summary_by_statement_type; ##### Example ```SQL -mysql> select * from user_summary_by_statement_type; +mariadb> select * from user_summary_by_statement_type; +------+------------------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+ | user | statement | total | total_latency | max_latency | lock_latency | rows_sent | rows_examined | rows_affected | full_scans | +------+------------------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+ @@ -3124,7 +3124,7 @@ Lists the top wait classes by average latency, ignoring idle (this may be very l ##### Structures ```SQL -mysql> desc wait_classes_global_by_avg_latency; +mariadb> desc wait_classes_global_by_avg_latency; +---------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------+------+-----+---------+-------+ @@ -3137,7 +3137,7 @@ mysql> desc wait_classes_global_by_avg_latency; +---------------+---------------+------+-----+---------+-------+ 6 rows in set (0.11 sec) -mysql> desc x$wait_classes_global_by_avg_latency; +mariadb> desc x$wait_classes_global_by_avg_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -3154,7 +3154,7 @@ mysql> desc x$wait_classes_global_by_avg_latency; ##### Example ```SQL -mysql> select * from wait_classes_global_by_avg_latency where event_class != 'idle'; +mariadb> select * from wait_classes_global_by_avg_latency where event_class != 'idle'; +-------------------+--------+---------------+-------------+-------------+-------------+ | event_class | total | total_latency | min_latency | avg_latency | max_latency | +-------------------+--------+---------------+-------------+-------------+-------------+ @@ -3176,7 +3176,7 @@ Lists the top wait classes by total latency, ignoring idle (this may be very lar ##### Structures ```SQL -mysql> desc wait_classes_global_by_latency; +mariadb> desc wait_classes_global_by_latency; +---------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------+------+-----+---------+-------+ @@ -3189,7 +3189,7 @@ mysql> desc wait_classes_global_by_latency; +---------------+---------------+------+-----+---------+-------+ 6 rows in set (0.00 sec) -mysql> desc x$wait_classes_global_by_latency; +mariadb> desc x$wait_classes_global_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -3206,7 +3206,7 @@ mysql> desc x$wait_classes_global_by_latency; ##### Example ```SQL -mysql> select * from wait_classes_global_by_latency; +mariadb> select * from wait_classes_global_by_latency; +-------------------+--------+---------------+-------------+-------------+-------------+ | event_class | total | total_latency | min_latency | avg_latency | max_latency | +-------------------+--------+---------------+-------------+-------------+-------------+ @@ -3228,7 +3228,7 @@ Lists the top wait events per user by their total latency, ignoring idle (this m ##### Structures ```SQL -mysql> desc waits_by_user_by_latency; +mariadb> desc waits_by_user_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -3241,7 +3241,7 @@ mysql> desc waits_by_user_by_latency; +---------------+---------------------+------+-----+---------+-------+ 6 rows in set (0.00 sec) -mysql> desc x$waits_by_user_by_latency; +mariadb> desc x$waits_by_user_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -3258,7 +3258,7 @@ mysql> desc x$waits_by_user_by_latency; ##### Example ```SQL -mysql> select * from waits_by_user_by_latency; +mariadb> select * from waits_by_user_by_latency; +------+-----------------------------------------------------+--------+---------------+-------------+-------------+ | user | event | total | total_latency | avg_latency | max_latency | +------+-----------------------------------------------------+--------+---------------+-------------+-------------+ @@ -3289,7 +3289,7 @@ Lists the top wait events per host by their total latency, ignoring idle (this m ##### Structures ```SQL -mysql> desc waits_by_host_by_latency; +mariadb> desc waits_by_host_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -3302,7 +3302,7 @@ mysql> desc waits_by_host_by_latency; +---------------+---------------------+------+-----+---------+-------+ 6 rows in set (0.36 sec) -mysql> desc x$waits_by_host_by_latency; +mariadb> desc x$waits_by_host_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -3319,7 +3319,7 @@ mysql> desc x$waits_by_host_by_latency; ##### Example ```SQL - mysql> select * from waits_by_host_by_latency; + mariadb> select * from waits_by_host_by_latency; +------+-----------------------------------------------------+--------+---------------+-------------+-------------+ | host | event | total | total_latency | avg_latency | max_latency | +------+-----------------------------------------------------+--------+---------------+-------------+-------------+ @@ -3350,7 +3350,7 @@ Lists the top wait events by their total latency, ignoring idle (this may be ver ##### Structures ```SQL -mysql> desc waits_global_by_latency; +mariadb> desc waits_global_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -3362,7 +3362,7 @@ mysql> desc waits_global_by_latency; +---------------+---------------------+------+-----+---------+-------+ 5 rows in set (0.01 sec) -mysql> desc x$waits_global_by_latency; +mariadb> desc x$waits_global_by_latency; +---------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+---------+-------+ @@ -3378,7 +3378,7 @@ mysql> desc x$waits_global_by_latency; ##### Example ```SQL -mysql> select * from waits_global_by_latency; +mariadb> select * from waits_global_by_latency; +-----------------------------------------------------+---------+---------------+-------------+-------------+ | events | total | total_latency | avg_latency | max_latency | +-----------------------------------------------------+---------+---------------+-------------+-------------+ @@ -3432,7 +3432,7 @@ VARCHAR(64) ##### Example ```SQL -mysql> SELECT sys.extract_schema_from_file_name('/var/lib/mysql/employees/employee.ibd'); +mariadb> SELECT sys.extract_schema_from_file_name('/var/lib/mysql/employees/employee.ibd'); +----------------------------------------------------------------------------+ | sys.extract_schema_from_file_name('/var/lib/mysql/employees/employee.ibd') | +----------------------------------------------------------------------------+ @@ -3459,7 +3459,7 @@ VARCHAR(64) ##### Example ```SQL -mysql> SELECT sys.extract_table_from_file_name('/var/lib/mysql/employees/employee.ibd'); +mariadb> SELECT sys.extract_table_from_file_name('/var/lib/mysql/employees/employee.ibd'); +---------------------------------------------------------------------------+ | sys.extract_table_from_file_name('/var/lib/mysql/employees/employee.ibd') | +---------------------------------------------------------------------------+ @@ -3484,7 +3484,7 @@ TEXT ##### Example ```SQL -mysql> SELECT sys.format_bytes(2348723492723746) AS size; +mariadb> SELECT sys.format_bytes(2348723492723746) AS size; +----------+ | size | +----------+ @@ -3492,7 +3492,7 @@ mysql> SELECT sys.format_bytes(2348723492723746) AS size; +----------+ 1 row in set (0.00 sec) -mysql> SELECT sys.format_bytes(2348723492723) AS size; +mariadb> SELECT sys.format_bytes(2348723492723) AS size; +----------+ | size | +----------+ @@ -3500,7 +3500,7 @@ mysql> SELECT sys.format_bytes(2348723492723) AS size; +----------+ 1 row in set (0.00 sec) -mysql> SELECT sys.format_bytes(23487234) AS size; +mariadb> SELECT sys.format_bytes(23487234) AS size; +-----------+ | size | +-----------+ @@ -3527,7 +3527,7 @@ VARCHAR(512) CHARSET UTF8 ##### Example ```SQL -mysql> select @@datadir; +mariadb> select @@datadir; +-----------------------------------------------+ | @@datadir | +-----------------------------------------------+ @@ -3535,7 +3535,7 @@ mysql> select @@datadir; +-----------------------------------------------+ 1 row in set (0.06 sec) -mysql> select format_path('/Users/mark/sandboxes/SmallTree/AMaster/data/mysql/proc.MYD') AS path; +mariadb> select format_path('/Users/mark/sandboxes/SmallTree/AMaster/data/mysql/proc.MYD') AS path; +--------------------------+ | path | +--------------------------+ @@ -3564,7 +3564,7 @@ LONGTEXT ##### Example ```SQL -mysql> SELECT sys.format_statement(digest_text) +mariadb> SELECT sys.format_statement(digest_text) -> FROM performance_schema.events_statements_summary_by_digest -> ORDER by sum_timer_wait DESC limit 5; +-------------------------------------------------------------------+ @@ -3597,7 +3597,7 @@ TEXT ##### Example ```SQL -mysql> select format_time(342342342342345); +mariadb> select format_time(342342342342345); +------------------------------+ | format_time(342342342342345) | +------------------------------+ @@ -3605,7 +3605,7 @@ mysql> select format_time(342342342342345); +------------------------------+ 1 row in set (0.00 sec) -mysql> select format_time(342342342); +mariadb> select format_time(342342342); +------------------------+ | format_time(342342342) | +------------------------+ @@ -3613,7 +3613,7 @@ mysql> select format_time(342342342); +------------------------+ 1 row in set (0.00 sec) -mysql> select format_time(34234); +mariadb> select format_time(34234); +--------------------+ | format_time(34234) | +--------------------+ @@ -3643,7 +3643,7 @@ TEXT ##### Example ```SQL -mysql> select @@sql_mode; +mariadb> select @@sql_mode; +-----------------------------------------------------------------------------------+ | @@sql_mode | +-----------------------------------------------------------------------------------+ @@ -3651,10 +3651,10 @@ mysql> select @@sql_mode; +-----------------------------------------------------------------------------------+ 1 row in set (0.00 sec) -mysql> set sql_mode = sys.list_add(@@sql_mode, 'ANSI_QUOTES'); +mariadb> set sql_mode = sys.list_add(@@sql_mode, 'ANSI_QUOTES'); Query OK, 0 rows affected (0.06 sec) -mysql> select @@sql_mode; +mariadb> select @@sql_mode; +-----------------------------------------------------------------------------------------------+ | @@sql_mode | +-----------------------------------------------------------------------------------------------+ @@ -3684,7 +3684,7 @@ TEXT ##### Example ```SQL -mysql> select @@sql_mode; +mariadb> select @@sql_mode; +-----------------------------------------------------------------------------------------------+ | @@sql_mode | +-----------------------------------------------------------------------------------------------+ @@ -3692,10 +3692,10 @@ mysql> select @@sql_mode; +-----------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) -mysql> set sql_mode = sys.list_drop(@@sql_mode, 'ONLY_FULL_GROUP_BY'); +mariadb> set sql_mode = sys.list_drop(@@sql_mode, 'ONLY_FULL_GROUP_BY'); Query OK, 0 rows affected (0.03 sec) -mysql> select @@sql_mode; +mariadb> select @@sql_mode; +----------------------------------------------------------------------------+ | @@sql_mode | +----------------------------------------------------------------------------+ @@ -3721,7 +3721,7 @@ ENUM('YES', 'NO') ##### Example ```SQL -mysql> SELECT sys.ps_is_account_enabled('localhost', 'root'); +mariadb> SELECT sys.ps_is_account_enabled('localhost', 'root'); +------------------------------------------------+ | sys.ps_is_account_enabled('localhost', 'root') | +------------------------------------------------+ @@ -3746,7 +3746,7 @@ ENUM('YES', 'NO') ##### Example ```SQL -mysql> SELECT sys.ps_is_consumer_enabled('events_stages_history'); +mariadb> SELECT sys.ps_is_consumer_enabled('events_stages_history'); +-----------------------------------------------------+ | sys.ps_is_consumer_enabled('events_stages_history') | +-----------------------------------------------------+ @@ -3759,7 +3759,7 @@ mysql> SELECT sys.ps_is_consumer_enabled('events_stages_history'); ##### Description -Returns whether an instrument is enabled by default in this version of MySQL. +Returns whether an instrument is enabled by default in this version of MariaDB. ##### Parameters @@ -3771,7 +3771,7 @@ ENUM('YES', 'NO') ##### Example ```SQL -mysql> SELECT sys.ps_is_instrument_default_enabled('statement/sql/select'); +mariadb> SELECT sys.ps_is_instrument_default_enabled('statement/sql/select'); +--------------------------------------------------------------+ | sys.ps_is_instrument_default_enabled('statement/sql/select') | +--------------------------------------------------------------+ @@ -3784,7 +3784,7 @@ mysql> SELECT sys.ps_is_instrument_default_enabled('statement/sql/select'); ##### Description -Returns whether an instrument is timed by default in this version of MySQL. +Returns whether an instrument is timed by default in this version of MariaDB. ##### Parameters @@ -3796,7 +3796,7 @@ ENUM('YES', 'NO') ##### Example ```SQL -mysql> SELECT sys.ps_is_instrument_default_timed('statement/sql/select'); +mariadb> SELECT sys.ps_is_instrument_default_timed('statement/sql/select'); +------------------------------------------------------------+ | sys.ps_is_instrument_default_timed('statement/sql/select') | +------------------------------------------------------------+ @@ -3821,7 +3821,7 @@ ENUM('YES', 'NO', 'UNKNOWN') ##### Example ```SQL -mysql> SELECT sys.ps_is_thread_instrumented(CONNECTION_ID()); +mariadb> SELECT sys.ps_is_thread_instrumented(CONNECTION_ID()); +------------------------------------------------+ | sys.ps_is_thread_instrumented(CONNECTION_ID()) | +------------------------------------------------+ @@ -3846,7 +3846,7 @@ BIGINT UNSIGNED ##### Example ```SQL -mysql> SELECT sys.ps_thread_id(79); +mariadb> SELECT sys.ps_thread_id(79); +----------------------+ | sys.ps_thread_id(79) | +----------------------+ @@ -3854,7 +3854,7 @@ mysql> SELECT sys.ps_thread_id(79); +----------------------+ 1 row in set (0.00 sec) -mysql> SELECT sys.ps_thread_id(CONNECTION_ID()); +mariadb> SELECT sys.ps_thread_id(CONNECTION_ID()); +-----------------------------------+ | sys.ps_thread_id(CONNECTION_ID()) | +-----------------------------------+ @@ -3878,12 +3878,11 @@ Outputs a JSON formatted stack of all statements, stages and events within Perfo (line separation added for output) ```SQL - mysql> SELECT sys.ps_thread_stack(37, FALSE) AS thread_stack\G + mariadb> SELECT sys.ps_thread_stack(37, FALSE) AS thread_stack\G *************************** 1. row *************************** -thread_stack: {"rankdir": "LR","nodesep": "0.10","stack_created": "2014-02-19 13:39:03", -"mysql_version": "5.7.3-m13","mysql_user": "root@localhost","events": -[{"nesting_event_id": "0", "event_id": "10", "timer_wait": 256.35, "event_info": -"sql/select", "wait_info": "select @@version_comment limit 1\nerrors: 0\nwarnings: 0\nlock time: +thread_stack: {"rankdir": "LR","nodesep": "0.10","stack_created": "2024-09-04 21:21:44", +"mysql_version": "10.6.19-MariaDB","mysql_user": "msandbox@localhost","events": []} + ... ``` @@ -4000,7 +3999,7 @@ TEXT ##### Example ```SQL -mysql> SELECT sys.quote_identifier('my_identifier') AS Identifier; +mariadb> SELECT sys.quote_identifier('my_identifier') AS Identifier; +-----------------+ | Identifier | +-----------------+ @@ -4008,7 +4007,7 @@ mysql> SELECT sys.quote_identifier('my_identifier') AS Identifier; +-----------------+ 1 row in set (0.00 sec) -mysql> SELECT sys.quote_identifier('my`idenfier') AS Identifier; +mariadb> SELECT sys.quote_identifier('my`idenfier') AS Identifier; +----------------+ | Identifier | +----------------+ @@ -4050,7 +4049,7 @@ VARCHAR(128) ##### Example ```SQL -- Get the configuration value from sys.sys_config falling back on 128 if the option is not present in the table. -mysql> SELECT sys.sys_get_config('statement_truncate_len', 128) AS Value; +mariadb> SELECT sys.sys_get_config('statement_truncate_len', 128) AS Value; +-------+ | Value | +-------+ @@ -4059,7 +4058,7 @@ mysql> SELECT sys.sys_get_config('statement_truncate_len', 128) AS Value; 1 row in set (0.00 sec) -- Check whether the option is already set, if not assign - IFNULL(...) one liner example. -mysql> SET @sys.statement_truncate_len = IFNULL(@sys.statement_truncate_len, sys.sys_get_config('statement_truncate_len', 64)); +mariadb> SET @sys.statement_truncate_len = IFNULL(@sys.statement_truncate_len, sys.sys_get_config('statement_truncate_len', 64)); Query OK, 0 rows affected (0.00 sec) -- Check whether the option is already set, if not assign - IF ... THEN ... END IF example. @@ -4072,7 +4071,7 @@ END IF; ##### Description -Returns the major version of MySQL Server. +Returns the major version of MariaDB Server. ##### Returns @@ -4080,12 +4079,12 @@ TINYINT UNSIGNED ##### Example ```SQL -mysql> SELECT VERSION(), sys.version_major(); -+--------------------------------------+---------------------+ -| VERSION() | sys.version_major() | -+--------------------------------------+---------------------+ -| 5.7.9-enterprise-commercial-advanced | 5 | -+--------------------------------------+---------------------+ +mariadb> SELECT VERSION(), sys.version_major(); ++-----------------+---------------------+ +| VERSION() | sys.version_major() | ++-----------------+---------------------+ +| 10.6.19-MariaDB | 10 | ++-----------------+---------------------+ 1 row in set (0.00 sec) ``` @@ -4093,7 +4092,7 @@ mysql> SELECT VERSION(), sys.version_major(); ##### Description -Returns the minor (release series) version of MySQL Server. +Returns the minor (release series) version of MariaDB Server. ##### Returns @@ -4101,12 +4100,12 @@ TINYINT UNSIGNED ##### Example ```SQL -mysql> SELECT VERSION(), sys.server_minor(); -+--------------------------------------+---------------------+ -| VERSION() | sys.version_minor() | -+--------------------------------------+---------------------+ -| 5.7.9-enterprise-commercial-advanced | 7 | -+--------------------------------------+---------------------+ +mariadb> SELECT VERSION(), sys.server_minor(); ++-----------------+---------------------+ +| VERSION() | sys.version_minor() | ++-----------------+---------------------+ +| 10.6.19-MariaDB | 6 | ++-----------------+---------------------+ 1 row in set (0.00 sec) ``` @@ -4114,7 +4113,7 @@ mysql> SELECT VERSION(), sys.server_minor(); ##### Description -Returns the patch release version of MySQL Server. +Returns the patch release version of MariaDB Server. ##### Returns @@ -4122,12 +4121,12 @@ TINYINT UNSIGNED ##### Example ```SQL -mysql> SELECT VERSION(), sys.version_patch(); -+--------------------------------------+---------------------+ -| VERSION() | sys.version_patch() | -+--------------------------------------+---------------------+ -| 5.7.9-enterprise-commercial-advanced | 9 | -+--------------------------------------+---------------------+ +mariadb> SELECT VERSION(), sys.version_patch(); ++-----------------+---------------------+ +| VERSION() | sys.version_patch() | ++-----------------+---------------------+ +| 10.6.19-MariaDB | 19 | ++-----------------+---------------------+ 1 row in set (0.00 sec) ``` @@ -4151,7 +4150,7 @@ Useful for creating a "ps" synonym for "performance_schema", or "is" instead of ##### Example ```SQL -mysql> SHOW DATABASES; +mariadb> SHOW DATABASES; +--------------------+ | Database | +--------------------+ @@ -4163,7 +4162,7 @@ mysql> SHOW DATABASES; +--------------------+ 5 rows in set (0.00 sec) -mysql> CALL sys.create_synonym_db('performance_schema', 'ps'); +mariadb> CALL sys.create_synonym_db('performance_schema', 'ps'); +---------------------------------------+ | summary | +---------------------------------------+ @@ -4173,7 +4172,7 @@ mysql> CALL sys.create_synonym_db('performance_schema', 'ps'); Query OK, 0 rows affected (8.57 sec) -mysql> SHOW DATABASES; +mariadb> SHOW DATABASES; +--------------------+ | Database | +--------------------+ @@ -4186,7 +4185,7 @@ mysql> SHOW DATABASES; +--------------------+ 6 rows in set (0.00 sec) -mysql> SHOW FULL TABLES FROM ps; +mariadb> SHOW FULL TABLES FROM ps; +-----------------------------------------+------------+ | Tables_in_ps | Table_type | +-----------------------------------------+------------+ @@ -4206,7 +4205,6 @@ Create a report of the current status of the server for diagnostics purposes. Da * The GLOBAL VARIABLES * Several sys schema views including metrics or equivalent (depending on version and settings) * Queries in the 95th percentile -* Several ndbinfo views for MySQL Cluster * Replication (both master and slave) information. Some of the sys schema views are calculated as initial (optional), overall, delta: @@ -4224,10 +4222,6 @@ Some of the sys schema views are calculated as initial (optional), overall, delt Requires the SUPER privilege for "SET sql_log_bin = 0;". -Versions supported: -* MySQL 5.6: 5.6.10 and later -* MySQL 5.7: 5.7.9 and later - Some configuration options are supported: * sys.diagnostics.allow_i_s_tables @@ -4269,10 +4263,10 @@ Supported values are: ##### Example ```SQL -mysql> TEE diag.out; -mysql> CALL sys.diagnostics(120, 30, 'current'); +mariadb> TEE diag.out; +mariadb> CALL sys.diagnostics(120, 30, 'current'); ... -mysql> NOTEE; +mariadb> NOTEE; ``` #### ps_setup_disable_background_threads @@ -4287,7 +4281,7 @@ None. ##### Example ```SQL -mysql> CALL sys.ps_setup_disable_background_threads(); +mariadb> CALL sys.ps_setup_disable_background_threads(); +--------------------------------+ | summary | +--------------------------------+ @@ -4318,7 +4312,7 @@ The following configuration option is supported: ##### Example ```SQL -mysql> CALL sys.execute_prepared_stmt('SELECT * FROM sys.sys_config'); +mariadb> CALL sys.execute_prepared_stmt('SELECT * FROM sys.sys_config'); +------------------------+-------+---------------------+--------+ | variable | value | set_time | set_by | +------------------------+-------+---------------------+--------+ @@ -4343,7 +4337,7 @@ Disables consumers within Performance Schema matching the input pattern. To disable all consumers: ```SQL -mysql> CALL sys.ps_setup_disable_consumer(''); +mariadb> CALL sys.ps_setup_disable_consumer(''); +--------------------------+ | summary | +--------------------------+ @@ -4354,7 +4348,7 @@ mysql> CALL sys.ps_setup_disable_consumer(''); To disable just the event_stage consumers: ```SQL -mysql> CALL sys.ps_setup_disable_consumer('stage'); +mariadb> CALL sys.ps_setup_disable_consumer('stage'); +------------------------+ | summary | +------------------------+ @@ -4377,7 +4371,7 @@ Disables instruments within Performance Schema matching the input pattern. To disable all mutex instruments: ```SQL -mysql> CALL sys.ps_setup_disable_instrument('wait/synch/mutex'); +mariadb> CALL sys.ps_setup_disable_instrument('wait/synch/mutex'); +--------------------------+ | summary | +--------------------------+ @@ -4387,7 +4381,7 @@ mysql> CALL sys.ps_setup_disable_instrument('wait/synch/mutex'); ``` To disable just a specific TCP/IP based network IO instrument: ```SQL -mysql> CALL sys.ps_setup_disable_instrument('wait/io/socket/sql/server_tcpip_socket'); +mariadb> CALL sys.ps_setup_disable_instrument('wait/io/socket/sql/server_tcpip_socket'); +------------------------+ | summary | +------------------------+ @@ -4397,7 +4391,7 @@ mysql> CALL sys.ps_setup_disable_instrument('wait/io/socket/sql/server_tcpip_soc ``` To disable all instruments: ```SQL -mysql> CALL sys.ps_setup_disable_instrument(''); +mariadb> CALL sys.ps_setup_disable_instrument(''); +--------------------------+ | summary | +--------------------------+ @@ -4418,7 +4412,7 @@ Disable the given connection/thread in Performance Schema. ##### Example ```SQL -mysql> CALL sys.ps_setup_disable_thread(3); +mariadb> CALL sys.ps_setup_disable_thread(3); +-------------------+ | summary | +-------------------+ @@ -4428,7 +4422,7 @@ mysql> CALL sys.ps_setup_disable_thread(3); ``` To disable the current connection: ```SQL -mysql> CALL sys.ps_setup_disable_thread(CONNECTION_ID()); +mariadb> CALL sys.ps_setup_disable_thread(CONNECTION_ID()); +-------------------+ | summary | +-------------------+ @@ -4449,7 +4443,7 @@ None. ##### Example ```SQL -mysql> CALL sys.ps_setup_enable_background_threads(); +mariadb> CALL sys.ps_setup_enable_background_threads(); +-------------------------------+ | summary | +-------------------------------+ @@ -4472,7 +4466,7 @@ Enables consumers within Performance Schema matching the input pattern. To enable all consumers: ```SQL -mysql> CALL sys.ps_setup_enable_consumer(''); +mariadb> CALL sys.ps_setup_enable_consumer(''); +-------------------------+ | summary | +-------------------------+ @@ -4483,7 +4477,7 @@ mysql> CALL sys.ps_setup_enable_consumer(''); To enable just "waits" consumers: ```SQL -mysql> CALL sys.ps_setup_enable_consumer('waits'); +mariadb> CALL sys.ps_setup_enable_consumer('waits'); +-----------------------+ | summary | +-----------------------+ @@ -4507,7 +4501,7 @@ Enables instruments within Performance Schema matching the input pattern. To enable all mutex instruments: ```SQL -mysql> CALL sys.ps_setup_enable_instrument('wait/synch/mutex'); +mariadb> CALL sys.ps_setup_enable_instrument('wait/synch/mutex'); +-------------------------+ | summary | +-------------------------+ @@ -4517,7 +4511,7 @@ mysql> CALL sys.ps_setup_enable_instrument('wait/synch/mutex'); ``` To enable just a specific TCP/IP based network IO instrument: ```SQL -mysql> CALL sys.ps_setup_enable_instrument('wait/io/socket/sql/server_tcpip_socket'); +mariadb> CALL sys.ps_setup_enable_instrument('wait/io/socket/sql/server_tcpip_socket'); +-----------------------+ | summary | +-----------------------+ @@ -4527,7 +4521,7 @@ mysql> CALL sys.ps_setup_enable_instrument('wait/io/socket/sql/server_tcpip_sock ``` To enable all instruments: ```SQL -mysql> CALL sys.ps_setup_enable_instrument(''); +mariadb> CALL sys.ps_setup_enable_instrument(''); +-------------------------+ | summary | +-------------------------+ @@ -4549,7 +4543,7 @@ Enable the given connection/thread in Performance Schema. ##### Example ```SQL -mysql> CALL sys.ps_setup_enable_thread(3); +mariadb> CALL sys.ps_setup_enable_thread(3); +------------------+ | summary | +------------------+ @@ -4559,7 +4553,7 @@ mysql> CALL sys.ps_setup_enable_thread(3); ``` To enable the current connection: ```SQL -mysql> CALL sys.ps_setup_enable_thread(CONNECTION_ID()); +mariadb> CALL sys.ps_setup_enable_thread(CONNECTION_ID()); +------------------+ | summary | +------------------+ @@ -4584,16 +4578,16 @@ None. ##### Example ```SQL -mysql> CALL sys.ps_setup_save(); +mariadb> CALL sys.ps_setup_save(); Query OK, 0 rows affected (0.08 sec) -mysql> UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES'; +mariadb> UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES'; Query OK, 547 rows affected (0.40 sec) Rows matched: 784 Changed: 547 Warnings: 0 /* Run some tests that need more detailed instrumentation here */ -mysql> CALL sys.ps_setup_reload_saved(); +mariadb> CALL sys.ps_setup_reload_saved(); Query OK, 0 rows affected (0.32 sec) ``` @@ -4609,7 +4603,7 @@ Resets the Performance Schema setup to the default settings. ##### Example ```SQL -mysql> CALL sys.ps_setup_reset_to_default(true)\G +mariadb> CALL sys.ps_setup_reset_to_default(true)\G *************************** 1. row *************************** status: Resetting: setup_actors DELETE @@ -4624,7 +4618,7 @@ VALUES ('%', '%', '%') 1 row in set (0.00 sec) ... -mysql> CALL sys.ps_setup_reset_to_default(false)\G +mariadb> CALL sys.ps_setup_reset_to_default(false)\G Query OK, 0 rows affected (0.00 sec) ``` @@ -4648,17 +4642,17 @@ Requires the SUPER privilege for "SET sql_log_bin = 0;". ##### Example ```SQL -mysql> CALL sys.ps_setup_save(-1); +mariadb> CALL sys.ps_setup_save(-1); Query OK, 0 rows affected (0.08 sec) -mysql> UPDATE performance_schema.setup_instruments +mariadb> UPDATE performance_schema.setup_instruments -> SET enabled = 'YES', timed = 'YES'; Query OK, 547 rows affected (0.40 sec) Rows matched: 784 Changed: 547 Warnings: 0 /* Run some tests that need more detailed instrumentation here */ -mysql> CALL sys.ps_setup_reload_saved(); +mariadb> CALL sys.ps_setup_reload_saved(); Query OK, 0 rows affected (0.32 sec) ``` @@ -4666,10 +4660,8 @@ Query OK, 0 rows affected (0.32 sec) ##### Description -Shows all currently disable Performance Schema configuration. +Shows all currently disabled Performance Schema configurations. -Disabled users is only available for MySQL 5.7.6 and later. -In earlier versions it was only possible to enable users. ##### Parameters @@ -4678,7 +4670,7 @@ In earlier versions it was only possible to enable users. ##### Example ```SQL -mysql> CALL sys.ps_setup_show_disabled(TRUE, TRUE); +mariadb> CALL sys.ps_setup_show_disabled(TRUE, TRUE); +----------------------------+ | performance_schema_enabled | +----------------------------+ @@ -4761,7 +4753,7 @@ None ##### Example ```SQL -mysql> CALL sys.ps_setup_show_disabled_consumers(); +mariadb> CALL sys.ps_setup_show_disabled_consumers(); +---------------------------+ | disabled_consumers | @@ -4787,7 +4779,7 @@ None ##### Example ```SQL -mysql> CALL sys.ps_setup_show_disabled_instruments(); +mariadb> CALL sys.ps_setup_show_disabled_instruments(); ``` #### ps_setup_show_enabled @@ -4803,7 +4795,7 @@ Shows all currently enabled Performance Schema configuration. ##### Example ```SQL -mysql> CALL sys.ps_setup_show_enabled(TRUE, TRUE); +mariadb> CALL sys.ps_setup_show_enabled(TRUE, TRUE); +----------------------------+ | performance_schema_enabled | +----------------------------+ @@ -4895,7 +4887,7 @@ None ##### Example ```SQL -mysql> CALL sys.ps_setup_show_enabled_consumers(); +mariadb> CALL sys.ps_setup_show_enabled_consumers(); +---------------------------+ | enabled_consumers | @@ -4921,7 +4913,7 @@ None ##### Example ```SQL -mysql> CALL sys.ps_setup_show_enabled_instruments(); +mariadb> CALL sys.ps_setup_show_enabled_instruments(); ``` #### ps_statement_avg_latency_histogram @@ -4938,7 +4930,7 @@ None. ##### Example ```SQL -mysql> CALL sys.ps_statement_avg_latency_histogram()\G +mariadb> CALL sys.ps_statement_avg_latency_histogram()\G *************************** 1. row *************************** Performance Schema Statement Digest Average Latency Histogram: @@ -4996,7 +4988,7 @@ Requires the SUPER privilege for "SET sql_log_bin = 0;". ##### Example ```SQL -mysql> call ps_analyze_statement_digest('891ec6860f98ba46d89dd20b0c03652c', 10, 0.1, true, true); +mariadb> call ps_analyze_statement_digest('891ec6860f98ba46d89dd20b0c03652c', 10, 0.1, true, true); +--------------------+ | SUMMARY STATISTICS | +--------------------+ @@ -5091,7 +5083,7 @@ Requires the SUPER privilege for "SET sql_log_bin = 0;". ##### Example ```SQL -mysql> CALL sys.ps_trace_thread(25, CONCAT('/tmp/stack-', REPLACE(NOW(), ' ', '-'), '.dot'), NULL, NULL, TRUE, TRUE, TRUE); +mariadb> CALL sys.ps_trace_thread(25, CONCAT('/tmp/stack-', REPLACE(NOW(), ' ', '-'), '.dot'), NULL, NULL, TRUE, TRUE, TRUE); +-------------------+ | summary | +-------------------+ @@ -5147,7 +5139,7 @@ Truncates all summary tables within Performance Schema, resetting all aggregated ##### Example ```SQL -mysql> CALL sys.ps_truncate_all_tables(false); +mariadb> CALL sys.ps_truncate_all_tables(false); +---------------------+ | summary | +---------------------+ @@ -5252,22 +5244,22 @@ The following configuration options are supported: -- 6. Perform analyzis based on the new snapshot. -- 7. Perform analyzis based on the delta between the initial and new snapshots. -mysql> CALL sys.statement_performance_analyzer('create_tmp', 'mydb.tmp_digests_ini', NULL); +mariadb> CALL sys.statement_performance_analyzer('create_tmp', 'mydb.tmp_digests_ini', NULL); Query OK, 0 rows affected (0.08 sec) -mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); +mariadb> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); Query OK, 0 rows affected (0.02 sec) -mysql> CALL sys.statement_performance_analyzer('save', 'mydb.tmp_digests_ini', NULL); +mariadb> CALL sys.statement_performance_analyzer('save', 'mydb.tmp_digests_ini', NULL); Query OK, 0 rows affected (0.00 sec) -mysql> DO SLEEP(60); +mariadb> DO SLEEP(60); Query OK, 0 rows affected (1 min 0.00 sec) -mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); +mariadb> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); Query OK, 0 rows affected (0.02 sec) -mysql> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile'); +mariadb> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile'); +-----------------------------------------+ | Next Output | +-----------------------------------------+ @@ -5277,7 +5269,7 @@ mysql> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_i ... -mysql> CALL sys.statement_performance_analyzer('delta', 'mydb.tmp_digests_ini', 'with_runtimes_in_95th_percentile'); +mariadb> CALL sys.statement_performance_analyzer('delta', 'mydb.tmp_digests_ini', 'with_runtimes_in_95th_percentile'); +-----------------------------------------+ | Next Output | +-----------------------------------------+ @@ -5290,13 +5282,13 @@ mysql> CALL sys.statement_performance_analyzer('delta', 'mydb.tmp_digests_ini', -- To create an overall report of the 95th percentile queries and the top 10 queries with full table scans: -mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); +mariadb> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); Query OK, 0 rows affected (0.01 sec) -mysql> SET @sys.statement_performance_analyzer.limit = 10; +mariadb> SET @sys.statement_performance_analyzer.limit = 10; Query OK, 0 rows affected (0.00 sec) -mysql> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile,with_full_table_scans'); +mariadb> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile,with_full_table_scans'); +-----------------------------------------+ | Next Output | +-----------------------------------------+ @@ -5319,7 +5311,7 @@ mysql> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_i -- Use a custom view showing the top 10 query sorted by total execution time refreshing the view every minute using -- the watch command in Linux. -mysql> CREATE OR REPLACE VIEW mydb.my_statements AS +mariadb> CREATE OR REPLACE VIEW mydb.my_statements AS -> SELECT sys.format_statement(DIGEST_TEXT) AS query, -> SCHEMA_NAME AS db, -> COUNT_STAR AS exec_count, @@ -5333,10 +5325,10 @@ mysql> CREATE OR REPLACE VIEW mydb.my_statements AS -> ORDER BY SUM_TIMER_WAIT DESC; Query OK, 0 rows affected (0.01 sec) -mysql> CALL sys.statement_performance_analyzer('create_table', 'mydb.digests_prev', NULL); +mariadb> CALL sys.statement_performance_analyzer('create_table', 'mydb.digests_prev', NULL); Query OK, 0 rows affected (0.10 sec) -shell$ watch -n 60 "mysql sys --table -e \" +shell$ watch -n 60 "mariadb sys --table -e \" > SET @sys.statement_performance_analyzer.view = 'mydb.my_statements'; > SET @sys.statement_performance_analyzer.limit = 10; > CALL statement_performance_analyzer('snapshot', NULL, NULL); @@ -5344,7 +5336,7 @@ shell$ watch -n 60 "mysql sys --table -e \" > CALL statement_performance_analyzer('save', 'mydb.digests_prev', NULL); > \"" -Every 60.0s: mysql sys --table -e " ... Mon Dec 22 10:58:51 2014 +Every 60.0s: mariadb sys --table -e " ... Mon Dec 22 10:58:51 2014 +----------------------------------+ | Next Output | @@ -5379,24 +5371,24 @@ name, then 'TEMPORARY' will be returned. ##### Example ```SQL -mysql> CREATE DATABASE db1; +mariadb> CREATE DATABASE db1; Query OK, 1 row affected (0.07 sec) -mysql> use db1; +mariadb> use db1; Database changed -mysql> CREATE TABLE t1 (id INT PRIMARY KEY); +mariadb> CREATE TABLE t1 (id INT PRIMARY KEY); Query OK, 0 rows affected (0.08 sec) -mysql> CREATE TABLE t2 (id INT PRIMARY KEY); +mariadb> CREATE TABLE t2 (id INT PRIMARY KEY); Query OK, 0 rows affected (0.08 sec) -mysql> CREATE view v_t1 AS SELECT * FROM t1; +mariadb> CREATE view v_t1 AS SELECT * FROM t1; Query OK, 0 rows affected (0.00 sec) -mysql> CREATE TEMPORARY TABLE t1 (id INT PRIMARY KEY); +mariadb> CREATE TEMPORARY TABLE t1 (id INT PRIMARY KEY); Query OK, 0 rows affected (0.00 sec) -mysql> CALL sys.table_exists('db1', 't1', @exists); SELECT @exists; +mariadb> CALL sys.table_exists('db1', 't1', @exists); SELECT @exists; Query OK, 0 rows affected (0.00 sec) +------------+ @@ -5406,7 +5398,7 @@ Query OK, 0 rows affected (0.00 sec) +------------+ 1 row in set (0.00 sec) -mysql> CALL sys.table_exists('db1', 't2', @exists); SELECT @exists; +mariadb> CALL sys.table_exists('db1', 't2', @exists); SELECT @exists; Query OK, 0 rows affected (0.00 sec) +------------+ @@ -5416,7 +5408,7 @@ Query OK, 0 rows affected (0.00 sec) +------------+ 1 row in set (0.01 sec) -mysql> CALL sys.table_exists('db1', 'v_t1', @exists); SELECT @exists; +mariadb> CALL sys.table_exists('db1', 'v_t1', @exists); SELECT @exists; Query OK, 0 rows affected (0.00 sec) +---------+ @@ -5426,7 +5418,7 @@ Query OK, 0 rows affected (0.00 sec) +---------+ 1 row in set (0.00 sec) -mysql> CALL sys.table_exists('db1', 't3', @exists); SELECT @exists; +mariadb> CALL sys.table_exists('db1', 't3', @exists); SELECT @exists; Query OK, 0 rows affected (0.01 sec) +---------+ diff --git a/sql/wsrep_high_priority_service.cc b/sql/wsrep_high_priority_service.cc index 2c0e2e643fa..1838095687f 100644 --- a/sql/wsrep_high_priority_service.cc +++ b/sql/wsrep_high_priority_service.cc @@ -392,6 +392,18 @@ int Wsrep_high_priority_service::rollback(const wsrep::ws_handle& ws_handle, wsrep_thd_transaction_state_str(m_thd), m_thd->killed); +#ifdef ENABLED_DEBUG_SYNC + DBUG_EXECUTE_IF("sync.wsrep_rollback_mdl_release", + { + const char act[]= + "now " + "SIGNAL sync.wsrep_rollback_mdl_release_reached " + "WAIT_FOR signal.wsrep_rollback_mdl_release"; + DBUG_ASSERT(!debug_sync_set_action(m_thd, + STRING_WITH_LEN(act))); + };); +#endif + m_thd->release_transactional_locks(); free_root(m_thd->mem_root, MYF(MY_KEEP_PREALLOC)); diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index a0767186866..5b1a5754e6a 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -3209,8 +3209,13 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx, mysql_mutex_lock(&granted_thd->LOCK_thd_kill); mysql_mutex_lock(&granted_thd->LOCK_thd_data); - if (wsrep_thd_is_toi(granted_thd) || - wsrep_thd_is_applying(granted_thd)) + if (granted_thd->wsrep_aborter != 0) + { + DBUG_ASSERT(granted_thd->wsrep_aborter == request_thd->thread_id); + WSREP_DEBUG("BF thread waiting for a victim to release locks"); + } + else if (wsrep_thd_is_toi(granted_thd) || + wsrep_thd_is_applying(granted_thd)) { if (wsrep_thd_is_aborting(granted_thd)) { @@ -3300,6 +3305,7 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx, } mysql_mutex_unlock(&granted_thd->LOCK_thd_data); mysql_mutex_unlock(&granted_thd->LOCK_thd_kill); + DEBUG_SYNC(request_thd, "after_wsrep_thd_abort"); } else { diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 44e9db84be4..45207d9d02d 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -1126,7 +1126,7 @@ void btr_drop_temporary_table(const dict_table_t &table) { if (buf_block_t *block= buf_page_get_gen({SRV_TMP_SPACE_ID, index->page}, 0, RW_X_LATCH, nullptr, BUF_GET, - &mtr, nullptr, nullptr)) + &mtr, nullptr)) { btr_free_but_not_root(block, MTR_LOG_NO_REDO); mtr.set_log_mode(MTR_LOG_NO_REDO); diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 461976497f5..033e3f80754 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -926,24 +926,21 @@ static inline page_cur_mode_t btr_cur_nonleaf_mode(page_cur_mode_t mode) MY_ATTRIBUTE((nonnull,warn_unused_result)) /** Acquire a latch on the previous page without violating the latching order. -@param block index page -@param page_id page identifier with valid space identifier -@param zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param rw_latch the latch on block (RW_S_LATCH or RW_X_LATCH) -@param mtr mini-transaction +@param page_id page identifier with valid space identifier @param err error code +@param mtr mini-transaction @retval 0 if an error occurred @retval 1 if the page could be latched in the wrong order @retval -1 if the latch on block was temporarily released */ -static int btr_latch_prev(buf_block_t *block, page_id_t page_id, - ulint zip_size, - rw_lock_type_t rw_latch, mtr_t *mtr, dberr_t *err) +static int btr_latch_prev(rw_lock_type_t rw_latch, + page_id_t page_id, dberr_t *err, mtr_t *mtr) { ut_ad(rw_latch == RW_S_LATCH || rw_latch == RW_X_LATCH); - ut_ad(page_id.space() == block->page.id().space()); - const auto prev_savepoint= mtr->get_savepoint(); - ut_ad(block == mtr->at_savepoint(prev_savepoint - 1)); + buf_block_t *block= mtr->at_savepoint(mtr->get_savepoint() - 1); + + ut_ad(page_id.space() == block->page.id().space()); const page_t *const page= block->page.frame; page_id.set_page_no(btr_page_get_prev(page)); @@ -959,68 +956,78 @@ static int btr_latch_prev(buf_block_t *block, page_id_t page_id, buffer-fixes on both blocks will prevent eviction. */ retry: - /* Pass no_wait pointer to ensure that we don't wait on the current page - latch while holding the next page latch to avoid latch ordering violation. */ - bool no_wait= false; int ret= 1; - - buf_block_t *prev= buf_page_get_gen(page_id, zip_size, RW_NO_LATCH, nullptr, - BUF_GET, mtr, err, &no_wait); + buf_block_t *prev= buf_pool.page_fix(page_id, err, buf_pool_t::FIX_NOWAIT); if (UNIV_UNLIKELY(!prev)) - { - /* Check if we had to return because we couldn't wait on latch. */ - if (no_wait) - goto ordered_latch; return 0; + if (prev == reinterpret_cast(-1)) + { + /* The block existed in buf_pool.page_hash, but not in a state that is + safe to access without waiting for some pending operation, such as + buf_page_t::read_complete() or buf_pool_t::unzip(). + + Retry while temporarily releasing the successor block->page.lock + (but retaining a buffer-fix so that the block cannot be evicted. */ + + if (rw_latch == RW_S_LATCH) + block->page.lock.s_unlock(); + else + block->page.lock.x_unlock(); + + prev= buf_pool.page_fix(page_id, err, buf_pool_t::FIX_WAIT_READ); + + if (!prev) + { + ut_ad(*err != DB_SUCCESS); + if (rw_latch == RW_S_LATCH) + block->page.lock.s_lock(); + else + block->page.lock.x_lock(); + return 0; + } + else if (rw_latch == RW_S_LATCH) + goto wait_for_s; + else + goto wait_for_x; } static_assert(MTR_MEMO_PAGE_S_FIX == mtr_memo_type_t(BTR_SEARCH_LEAF), ""); static_assert(MTR_MEMO_PAGE_X_FIX == mtr_memo_type_t(BTR_MODIFY_LEAF), ""); if (rw_latch == RW_S_LATCH - ? prev->page.lock.s_lock_try() : prev->page.lock.x_lock_try()) - { - mtr->lock_register(prev_savepoint, mtr_memo_type_t(rw_latch)); - if (UNIV_UNLIKELY(prev->page.id() != page_id)) - { - fail: - /* the page was just read and found to be corrupted */ - mtr->rollback_to_savepoint(prev_savepoint); - return 0; - } - } + ? prev->page.lock.s_lock_try() + : prev->page.lock.x_lock_try()) + mtr->memo_push(prev, mtr_memo_type_t(rw_latch)); else { - ut_ad(mtr->at_savepoint(mtr->get_savepoint() - 1)->page.id() == page_id); - mtr->release_last_page(); -ordered_latch: if (rw_latch == RW_S_LATCH) + { block->page.lock.s_unlock(); - else - block->page.lock.x_unlock(); - - prev= buf_page_get_gen(page_id, zip_size, rw_latch, prev, - BUF_GET, mtr, err); - if (rw_latch == RW_S_LATCH) + wait_for_s: + prev->page.lock.s_lock(); block->page.lock.s_lock(); + } else + { + block->page.lock.x_unlock(); + wait_for_x: + prev->page.lock.x_lock(); block->page.lock.x_lock(); + } + ut_ad(block == mtr->at_savepoint(mtr->get_savepoint() - 1)); + mtr->memo_push(prev, mtr_memo_type_t(rw_latch)); const page_id_t prev_page_id= page_id; page_id.set_page_no(btr_page_get_prev(page)); + ret= -1; if (UNIV_UNLIKELY(page_id != prev_page_id)) { mtr->release_last_page(); if (page_id.page_no() == FIL_NULL) - return -1; + return ret; goto retry; } - - if (UNIV_UNLIKELY(!prev)) - goto fail; - - ret= -1; } const page_t *const p= prev->page.frame; @@ -1047,11 +1054,11 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, btr_intention_t lock_intention; bool detected_same_key_root= false; - mem_heap_t* heap = NULL; - rec_offs offsets_[REC_OFFS_NORMAL_SIZE]; - rec_offs* offsets = offsets_; - rec_offs offsets2_[REC_OFFS_NORMAL_SIZE]; - rec_offs* offsets2 = offsets2_; + mem_heap_t *heap= nullptr; + rec_offs offsets_[REC_OFFS_NORMAL_SIZE]; + rec_offs *offsets= offsets_; + rec_offs offsets2_[REC_OFFS_NORMAL_SIZE]; + rec_offs *offsets2= offsets2_; rec_offs_init(offsets_); rec_offs_init(offsets2_); @@ -1208,7 +1215,7 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, ut_a(page_zip_validate(page_zip, block->page.frame, index())); #endif /* UNIV_ZIP_DEBUG */ - const uint32_t page_level= btr_page_get_level(block->page.frame); + uint32_t page_level= btr_page_get_level(block->page.frame); if (height == ULINT_UNDEFINED) { @@ -1216,6 +1223,7 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, #ifdef BTR_CUR_ADAPT info->root_guess= block; #endif + reached_root: height= page_level; tree_height= height + 1; @@ -1225,35 +1233,53 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, We may have to reacquire the page latch in a different mode. */ switch (rw_latch) { case RW_S_LATCH: - if ((latch_mode & ~12) != RW_S_LATCH) + if (!(latch_mode & BTR_SEARCH_LEAF)) { + rw_latch= RW_X_LATCH; ut_ad(rw_lock_type_t(latch_mode & ~12) == RW_X_LATCH); - goto relatch_x; + mtr->lock_register(block_savepoint, MTR_MEMO_PAGE_X_FIX); + if (!block->page.lock.s_x_upgrade_try()) + { + block->page.lock.s_unlock(); + block->page.lock.x_lock(); + /* Dropping the index tree (and freeing the root page) + should be impossible while we hold index()->lock. */ + ut_ad(!block->page.is_freed()); + page_level= btr_page_get_level(block->page.frame); + if (UNIV_UNLIKELY(page_level != 0)) + { + /* btr_root_raise_and_insert() was executed meanwhile */ + ut_ad(mtr->memo_contains_flagged(&index()->lock, + MTR_MEMO_S_LOCK)); + block->page.lock.x_u_downgrade(); + block->page.lock.u_s_downgrade(); + rw_latch= RW_S_LATCH; + mtr->lock_register(block_savepoint, MTR_MEMO_PAGE_S_FIX); + goto reached_root; + } + } } - else - { - if (!latch_by_caller) - /* Release the tree s-latch */ - mtr->rollback_to_savepoint(savepoint, savepoint + 1); - goto reached_latched_leaf; - } - /* fall through */ + if (rw_latch != RW_S_LATCH) + break; + if (!latch_by_caller) + /* Release the tree s-latch */ + mtr->rollback_to_savepoint(savepoint, savepoint + 1); + goto reached_latched_leaf; case RW_SX_LATCH: - ut_ad(rw_latch == RW_S_LATCH || - latch_mode == BTR_MODIFY_ROOT_AND_LEAF); - relatch_x: - mtr->rollback_to_savepoint(block_savepoint); - height= ULINT_UNDEFINED; + ut_ad(latch_mode == BTR_MODIFY_ROOT_AND_LEAF); + static_assert(int{BTR_MODIFY_ROOT_AND_LEAF} == int{RW_SX_LATCH}, ""); rw_latch= RW_X_LATCH; - goto search_loop; + mtr->lock_register(block_savepoint, MTR_MEMO_PAGE_X_FIX); + block->page.lock.u_x_upgrade(); + break; case RW_X_LATCH: if (latch_mode == BTR_MODIFY_TREE) goto reached_index_root_and_leaf; - goto reached_root_and_leaf; + break; case RW_NO_LATCH: ut_ad(0); } - goto reached_leaf; + goto reached_root_and_leaf; } } else if (UNIV_UNLIKELY(height != page_level)) @@ -1277,7 +1303,6 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, if (!height) { - reached_leaf: /* We reached the leaf level. */ ut_ad(block == mtr->at_savepoint(block_savepoint)); @@ -1307,7 +1332,7 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, /* latch also siblings from left to right */ if (page_has_prev(block->page.frame) && - !btr_latch_prev(block, page_id, zip_size, rw_latch, mtr, &err)) + !btr_latch_prev(rw_latch, page_id, &err, mtr)) goto func_exit; if (page_has_next(block->page.frame) && !btr_block_get(*index(), btr_page_get_next(block->page.frame), @@ -1333,7 +1358,7 @@ release_tree: ut_ad(rw_latch == RW_X_LATCH); /* x-latch also siblings from left to right */ if (page_has_prev(block->page.frame) && - !btr_latch_prev(block, page_id, zip_size, rw_latch, mtr, &err)) + !btr_latch_prev(rw_latch, page_id, &err, mtr)) goto func_exit; if (page_has_next(block->page.frame) && !btr_block_get(*index(), btr_page_get_next(block->page.frame), @@ -1480,7 +1505,7 @@ release_tree: ut_ad(rw_latch == RW_S_LATCH); if (!not_first_access) - buf_read_ahead_linear(page_id, zip_size); + buf_read_ahead_linear(page_id); if (page_has_prev(block->page.frame) && page_rec_is_first(page_cur.rec, block->page.frame)) @@ -1489,7 +1514,7 @@ release_tree: /* Latch the previous page if the node pointer is the leftmost of the current page. */ - int ret= btr_latch_prev(block, page_id, zip_size, rw_latch, mtr, &err); + int ret= btr_latch_prev(rw_latch, page_id, &err, mtr); if (!ret) goto func_exit; ut_ad(block_savepoint + 2 == mtr->get_savepoint()); @@ -1515,7 +1540,7 @@ release_tree: case BTR_SEARCH_LEAF: rw_latch= rw_lock_type_t(latch_mode); if (!not_first_access) - buf_read_ahead_linear(page_id, zip_size); + buf_read_ahead_linear(page_id); break; case BTR_MODIFY_TREE: ut_ad(rw_latch == RW_X_LATCH); @@ -1666,8 +1691,7 @@ dberr_t btr_cur_t::pessimistic_search_leaf(const dtuple_t *tuple, #endif /* UNIV_ZIP_DEBUG */ if (page_has_prev(block->page.frame) && - !btr_latch_prev(block, page_id, block->zip_size(), - RW_X_LATCH, mtr, &err)) + !btr_latch_prev(RW_X_LATCH, page_id, &err, mtr)) goto func_exit; if (page_has_next(block->page.frame) && !btr_block_get(*index(), btr_page_get_next(block->page.frame), @@ -1880,7 +1904,6 @@ index_locked: page_cur.index = index; uint32_t page= index->page; - const auto zip_size= index->table->space->zip_size(); for (ulint height= ULINT_UNDEFINED;;) { @@ -1931,8 +1954,7 @@ index_locked: { /* x-latch also siblings from left to right */ if (page_has_prev(block->page.frame) && - !btr_latch_prev(block, block->page.id(), zip_size, RW_X_LATCH, - mtr, &err)) + !btr_latch_prev(RW_X_LATCH, block->page.id(), &err, mtr)) break; if (page_has_next(block->page.frame) && !btr_block_get(*index, btr_page_get_next(block->page.frame), @@ -1986,8 +2008,7 @@ index_locked: if (latch_mode != BTR_MODIFY_TREE) { if (!height && first && first_access) - buf_read_ahead_linear(page_id_t(block->page.id().space(), page), - block->page.zip_size()); + buf_read_ahead_linear(page_id_t(block->page.id().space(), page)); } else if (btr_cur_need_opposite_intention(block->page, index->is_clust(), lock_intention, @@ -2012,7 +2033,8 @@ index_locked: { if (!btr_cur_will_modify_tree(index, block->page.frame, lock_intention, page_cur.rec, - node_ptr_max_size, zip_size, mtr)) + node_ptr_max_size, + index->table->space->zip_size(), mtr)) { ut_ad(n_blocks); /* release buffer-fixes on pages that will not be modified @@ -6408,7 +6430,7 @@ btr_copy_blob_prefix( return copied_len; } if (!buf_page_make_young_if_needed(&block->page)) { - buf_read_ahead_linear(id, 0); + buf_read_ahead_linear(id); } page = buf_block_get_frame(block); @@ -6487,7 +6509,7 @@ btr_copy_zblob_prefix( bpage is protected by the B-tree page latch that is being held on the clustered index record, or, in row_merge_copy_blobs(), by an exclusive table lock. */ - bpage = buf_page_get_zip(id, zip_size); + bpage = buf_page_get_zip(id); if (UNIV_UNLIKELY(!bpage)) { ib::error() << "Cannot load compressed BLOB " << id; diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc index 10005e5b501..b879ef12534 100644 --- a/storage/innobase/btr/btr0pcur.cc +++ b/storage/innobase/btr/btr0pcur.cc @@ -533,8 +533,7 @@ btr_pcur_move_to_next_page( const auto s = mtr->get_savepoint(); mtr->rollback_to_savepoint(s - 2, s - 1); if (first_access) { - buf_read_ahead_linear(next_block->page.id(), - next_block->zip_size()); + buf_read_ahead_linear(next_block->page.id()); } return DB_SUCCESS; } diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index cfcc49cc7b9..a7e5fd0e86d 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2347,13 +2347,10 @@ be implemented at a higher level. In other words, all possible accesses to a given page through this function must be protected by the same set of mutexes or latches. @param page_id page identifier -@param zip_size ROW_FORMAT=COMPRESSED page size in bytes @return pointer to the block, s-latched */ TRANSACTIONAL_TARGET -buf_page_t* buf_page_get_zip(const page_id_t page_id, ulint zip_size) +buf_page_t* buf_page_get_zip(const page_id_t page_id) { - ut_ad(zip_size); - ut_ad(ut_is_2pow(zip_size)); ha_handler_stats *const stats= mariadb_stats; buf_inc_get(stats); @@ -2454,7 +2451,7 @@ lookup: return bpage; must_read_page: - switch (dberr_t err= buf_read_page(page_id, zip_size, chain)) { + switch (dberr_t err= buf_read_page(page_id, chain)) { case DB_SUCCESS: case DB_SUCCESS_LOCKED_REC: mariadb_increment_pages_read(stats); @@ -2489,8 +2486,8 @@ buf_block_init_low( /********************************************************************//** Decompress a block. -@return TRUE if successful */ -ibool +@return true if successful */ +bool buf_zip_decompress( /*===============*/ buf_block_t* block, /*!< in/out: block */ @@ -2534,7 +2531,7 @@ func_exit: if (space) { space->release(); } - return(TRUE); + return true; } ib::error() << "Unable to decompress " @@ -2568,10 +2565,101 @@ err_exit: space->release(); } - return(FALSE); + return false; } -buf_block_t* buf_pool_t::page_fix(const page_id_t id) +ATTRIBUTE_COLD +buf_block_t *buf_pool_t::unzip(buf_page_t *b, buf_pool_t::hash_chain &chain) +{ + buf_block_t *block= buf_LRU_get_free_block(have_no_mutex); + buf_block_init_low(block); + page_hash_latch &hash_lock= page_hash.lock_get(chain); + wait_for_unfix: + mysql_mutex_lock(&mutex); + hash_lock.lock(); + + /* b->lock implies !b->can_relocate() */ + ut_ad(b->lock.have_x()); + ut_ad(b == page_hash.get(b->id(), chain)); + + /* Wait for b->unfix() in any other threads. */ + uint32_t state= b->state(); + ut_ad(buf_page_t::buf_fix_count(state)); + ut_ad(!buf_page_t::is_freed(state)); + + switch (state) { + case buf_page_t::UNFIXED + 1: + case buf_page_t::REINIT + 1: + break; + default: + ut_ad(state < buf_page_t::READ_FIX); + + if (state < buf_page_t::UNFIXED + 1) + { + ut_ad(state > buf_page_t::FREED); + b->lock.x_unlock(); + hash_lock.unlock(); + buf_LRU_block_free_non_file_page(block); + mysql_mutex_unlock(&mutex); + b->unfix(); + return nullptr; + } + + mysql_mutex_unlock(&mutex); + hash_lock.unlock(); + std::this_thread::sleep_for(std::chrono::microseconds(100)); + goto wait_for_unfix; + } + + /* Ensure that another buf_page_get_low() or buf_page_t::page_fix() + will wait for block->page.lock.x_unlock(). buf_relocate() will + copy the state from b to block and replace b with block in page_hash. */ + b->set_state(buf_page_t::READ_FIX); + + mysql_mutex_lock(&flush_list_mutex); + buf_relocate(b, &block->page); + + /* X-latch the block for the duration of the decompression. */ + block->page.lock.x_lock(); + + buf_flush_relocate_on_flush_list(b, &block->page); + mysql_mutex_unlock(&flush_list_mutex); + + /* Insert at the front of unzip_LRU list */ + buf_unzip_LRU_add_block(block, false); + + mysql_mutex_unlock(&mutex); + hash_lock.unlock(); + +#if defined SUX_LOCK_GENERIC || defined UNIV_DEBUG + b->lock.x_unlock(); + b->lock.free(); +#endif + ut_free(b); + + n_pend_unzip++; + const bool ok{buf_zip_decompress(block, false)}; + n_pend_unzip--; + + if (UNIV_UNLIKELY(!ok)) + { + mysql_mutex_lock(&mutex); + block->page.read_unfix(state); + block->page.lock.x_unlock(); + if (!buf_LRU_free_page(&block->page, true)) + ut_ad(0); + mysql_mutex_unlock(&mutex); + return nullptr; + } + else + block->page.read_unfix(state); + + return block; +} + +buf_block_t *buf_pool_t::page_fix(const page_id_t id, + dberr_t *err, + buf_pool_t::page_fix_conflicts c) { ha_handler_stats *const stats= mariadb_stats; buf_inc_get(stats); @@ -2583,35 +2671,83 @@ buf_block_t* buf_pool_t::page_fix(const page_id_t id) buf_page_t *b= page_hash.get(id, chain); if (b) { - uint32_t state= b->fix(); - hash_lock.unlock_shared(); + uint32_t state= b->fix() + 1; ut_ad(!b->in_zip_hash); - ut_ad(b->frame); - ut_ad(state >= buf_page_t::FREED); + hash_lock.unlock_shared(); + + if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED)) + { + ut_ad(state > buf_page_t::FREED); + if (c == FIX_ALSO_FREED && b->id() == id) + { + ut_ad(state == buf_page_t::FREED + 1); + return reinterpret_cast(b); + } + /* The page was marked as freed or corrupted. */ + b->unfix(); + corrupted: + if (err) + *err= DB_CORRUPTION; + return nullptr; + } + if (state >= buf_page_t::READ_FIX && state < buf_page_t::WRITE_FIX) { + if (c == FIX_NOWAIT) + { + would_block: + b->unfix(); + return reinterpret_cast(-1); + } + + if (UNIV_UNLIKELY(!b->frame)) + { + wait_for_unzip: + b->unfix(); + std::this_thread::sleep_for(std::chrono::microseconds(100)); + continue; + } b->lock.s_lock(); state= b->state(); ut_ad(state < buf_page_t::READ_FIX || state >= buf_page_t::WRITE_FIX); + b->lock.s_unlock(); } - if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED)) + + if (UNIV_UNLIKELY(!b->frame)) { - /* The page was marked as freed or corrupted. */ - b->unfix(); - b= nullptr; + if (b->lock.x_lock_try()); + else if (c == FIX_NOWAIT) + goto would_block; + else + goto wait_for_unzip; + + buf_block_t *block= unzip(b, chain); + if (!block) + goto corrupted; + + b= &block->page; + state= b->state(); + b->lock.x_unlock(); } + return reinterpret_cast(b); } hash_lock.unlock_shared(); - switch (buf_read_page(id, 0, chain)) { + + if (c == FIX_NOWAIT) + return reinterpret_cast(-1); + + switch (dberr_t local_err= buf_read_page(id, chain)) { default: + if (err) + *err= local_err; return nullptr; case DB_SUCCESS: case DB_SUCCESS_LOCKED_REC: mariadb_increment_pages_read(stats); - buf_read_ahead_random(id, 0); + buf_read_ahead_random(id); } } } @@ -2619,27 +2755,24 @@ buf_block_t* buf_pool_t::page_fix(const page_id_t id) /** Low level function used to get access to a database page. @param[in] page_id page id @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH +@param[in] rw_latch latch mode @param[in] guess guessed block or NULL @param[in] mode BUF_GET, BUF_GET_IF_IN_POOL, or BUF_PEEK_IF_IN_POOL @param[in] mtr mini-transaction @param[out] err DB_SUCCESS or error code -@param[in,out] no_wait If not NULL on input, then we must not -wait for current page latch. On output, the value is set to true if we had to -return because we could not wait on page latch. -@return pointer to the block or NULL */ +@return pointer to the block +@retval nullptr if the block is corrupted or unavailable */ TRANSACTIONAL_TARGET buf_block_t* buf_page_get_gen( const page_id_t page_id, ulint zip_size, - ulint rw_latch, + rw_lock_type_t rw_latch, buf_block_t* guess, ulint mode, mtr_t* mtr, - dberr_t* err, - bool* no_wait) + dberr_t* err) { ulint retries = 0; @@ -2658,12 +2791,7 @@ buf_page_get_gen( || log_sys.get_lsn() == recv_sys.lsn + SIZE_OF_FILE_CHECKPOINT || ibuf_upgrade_was_needed : !recv_recovery_is_on() || recv_sys.after_apply); - ut_ad(!mtr || mtr->is_active()); - ut_ad(mtr || mode == BUF_PEEK_IF_IN_POOL); - ut_ad((rw_latch == RW_S_LATCH) - || (rw_latch == RW_X_LATCH) - || (rw_latch == RW_SX_LATCH) - || (rw_latch == RW_NO_LATCH)); + ut_ad(mtr->is_active()); if (err) { *err = DB_SUCCESS; @@ -2745,11 +2873,11 @@ loop: corrupted, or if an encrypted page with a valid checksum cannot be decypted. */ - switch (dberr_t local_err = buf_read_page(page_id, zip_size, chain)) { + switch (dberr_t local_err = buf_read_page(page_id, chain)) { case DB_SUCCESS: case DB_SUCCESS_LOCKED_REC: mariadb_increment_pages_read(stats); - buf_read_ahead_random(page_id, zip_size); + buf_read_ahead_random(page_id); break; default: if (mode != BUF_GET_POSSIBLY_FREED @@ -2793,18 +2921,7 @@ ignore_unfixed: in buf_page_t::read_complete() or buf_pool_t::corrupted_evict(), or after buf_zip_decompress() in this function. */ - if (!no_wait) { - block->page.lock.s_lock(); - } else if (!block->page.lock.s_lock_try()) { - ut_ad(rw_latch == RW_NO_LATCH); - /* We should not wait trying to acquire S latch for - current page while holding latch for the next page. - It would violate the latching order resulting in - possible deadlock. Caller must handle the failure. */ - block->page.unfix(); - *no_wait= true; - return nullptr; - } + block->page.lock.s_lock(); state = block->page.state(); ut_ad(state < buf_page_t::READ_FIX || state >= buf_page_t::WRITE_FIX); @@ -2834,18 +2951,6 @@ ignore_unfixed: } ut_ad(id == page_id); } else if (mode != BUF_PEEK_IF_IN_POOL) { - } else if (!mtr) { - ut_ad(!block->page.oldest_modification()); - mysql_mutex_lock(&buf_pool.mutex); - block->unfix(); - -free_unfixed_block: - if (!buf_LRU_free_page(&block->page, true)) { - ut_ad(0); - } - - mysql_mutex_unlock(&buf_pool.mutex); - return nullptr; } else if (UNIV_UNLIKELY(!block->page.frame)) { /* The BUF_PEEK_IF_IN_POOL mode is mainly used for dropping an adaptive hash index. There cannot be an @@ -2856,120 +2961,35 @@ free_unfixed_block: ut_ad(mode == BUF_GET_IF_IN_POOL || mode == BUF_PEEK_IF_IN_POOL || block->zip_size() == zip_size); - if (UNIV_UNLIKELY(!block->page.frame)) { - if (!block->page.lock.x_lock_try()) { -wait_for_unzip: - /* The page is being read or written, or - another thread is executing buf_zip_decompress() - in buf_page_get_gen() on it. */ - block->page.unfix(); - std::this_thread::sleep_for( - std::chrono::microseconds(100)); - goto loop; - } - - buf_block_t *new_block = buf_LRU_get_free_block(have_no_mutex); - buf_block_init_low(new_block); - -wait_for_unfix: - mysql_mutex_lock(&buf_pool.mutex); - page_hash_latch& hash_lock=buf_pool.page_hash.lock_get(chain); - - /* It does not make sense to use - transactional_lock_guard here, because buf_relocate() - would likely make a memory transaction too large. */ - hash_lock.lock(); - - /* block->page.lock implies !block->page.can_relocate() */ - ut_ad(&block->page == buf_pool.page_hash.get(page_id, chain)); - - /* Wait for any other threads to release their buffer-fix - on the compressed-only block descriptor. */ - state = block->page.state(); - - switch (state) { - case buf_page_t::UNFIXED + 1: - case buf_page_t::REINIT + 1: - break; - default: - ut_ad(state < buf_page_t::READ_FIX); - - if (state < buf_page_t::UNFIXED + 1) { - ut_ad(state > buf_page_t::FREED); - block->page.lock.x_unlock(); - hash_lock.unlock(); - buf_LRU_block_free_non_file_page(new_block); - mysql_mutex_unlock(&buf_pool.mutex); - goto ignore_block; - } - - mysql_mutex_unlock(&buf_pool.mutex); - hash_lock.unlock(); - std::this_thread::sleep_for( - std::chrono::microseconds(100)); - goto wait_for_unfix; - } - - /* Ensure that another buf_page_get_gen() will wait for - new_block->page.lock.x_unlock(). */ - block->page.set_state(buf_page_t::READ_FIX); - - /* Move the compressed page from block->page to new_block, - and uncompress it. */ - - mysql_mutex_lock(&buf_pool.flush_list_mutex); - buf_relocate(&block->page, &new_block->page); - - /* X-latch the block for the duration of the decompression. */ - new_block->page.lock.x_lock(); - ut_d(block->page.lock.x_unlock()); - - buf_flush_relocate_on_flush_list(&block->page, - &new_block->page); - mysql_mutex_unlock(&buf_pool.flush_list_mutex); - - /* Insert at the front of unzip_LRU list */ - buf_unzip_LRU_add_block(new_block, FALSE); - - mysql_mutex_unlock(&buf_pool.mutex); - hash_lock.unlock(); - -#if defined SUX_LOCK_GENERIC || defined UNIV_DEBUG - block->page.lock.free(); -#endif - ut_free(reinterpret_cast(block)); - block = new_block; - - buf_pool.n_pend_unzip++; - - /* Decompress the page while not holding - buf_pool.mutex. */ - const auto ok = buf_zip_decompress(block, false); - --buf_pool.n_pend_unzip; - if (!ok) { - if (err) { - *err = DB_PAGE_CORRUPTED; - } - mysql_mutex_lock(&buf_pool.mutex); - } - state = block->page.read_unfix(state); - block->page.lock.x_unlock(); - - if (!ok) { - goto free_unfixed_block; - } - } - if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED)) { goto ignore_block; } ut_ad((~buf_page_t::LRU_MASK) & state); ut_ad(state > buf_page_t::WRITE_FIX || state < buf_page_t::READ_FIX); + if (UNIV_UNLIKELY(!block->page.frame)) { + if (!block->page.lock.x_lock_try()) { +wait_for_unzip: + /* The page is being read or written, or + another thread is executing buf_pool.unzip() on it. */ + block->page.unfix(); + std::this_thread::sleep_for( + std::chrono::microseconds(100)); + goto loop; + } + + block = buf_pool.unzip(&block->page, chain); + + if (!block) { + goto ignore_unfixed; + } + + block->page.lock.x_unlock(); + } + #ifdef UNIV_DEBUG if (!(++buf_dbg_counter % 5771)) buf_pool.validate(); #endif /* UNIV_DEBUG */ - ut_ad(block->page.frame); /* The state = block->page.state() may be stale at this point, and in fact, at any point of time if we consider its diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 8149f1017fe..b9f1e65fe3b 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -2682,12 +2682,12 @@ ATTRIBUTE_COLD void buf_flush_page_cleaner_init() /** Flush the buffer pool on shutdown. */ ATTRIBUTE_COLD void buf_flush_buffer_pool() { - ut_ad(!os_aio_pending_reads()); ut_ad(!buf_page_cleaner_is_active); ut_ad(!buf_flush_sync_lsn); service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, "Waiting to flush the buffer pool"); + os_aio_wait_until_no_pending_reads(false); mysql_mutex_lock(&buf_pool.flush_list_mutex); diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index 84b04beae34..d6868f3597a 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -303,10 +303,9 @@ pages: to avoid deadlocks this function must be written such that it cannot end up waiting for these latches! @param[in] page_id page id of a page which the current thread wants to access -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @return number of page read requests issued */ TRANSACTIONAL_TARGET -ulint buf_read_ahead_random(const page_id_t page_id, ulint zip_size) +ulint buf_read_ahead_random(const page_id_t page_id) { if (!srv_random_read_ahead || page_id.space() >= SRV_TMP_SPACE_ID) /* Disable the read-ahead for temporary tablespace */ @@ -353,6 +352,7 @@ read_ahead: /* Read all the suitable blocks within the area */ buf_block_t *block= nullptr; + unsigned zip_size{space->zip_size()}; if (UNIV_LIKELY(!zip_size)) { allocate_block: @@ -405,15 +405,14 @@ if it is not already there. Sets the io_fix and an exclusive lock on the buffer frame. The flag is cleared and the x-lock released by the i/o-handler thread. @param page_id page id -@param zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param chain buf_pool.page_hash cell for page_id -@retval DB_SUCCESS if the page was read and is not corrupted, +@retval DB_SUCCESS if the page was read and is not corrupted @retval DB_SUCCESS_LOCKED_REC if the page was not read @retval DB_PAGE_CORRUPTED if page based on checksum check is corrupted, @retval DB_DECRYPTION_FAILED if page post encryption checksum matches but after decryption normal page checksum does not match. @retval DB_TABLESPACE_DELETED if tablespace .ibd file is missing */ -dberr_t buf_read_page(const page_id_t page_id, ulint zip_size, +dberr_t buf_read_page(const page_id_t page_id, buf_pool_t::hash_chain &chain) { fil_space_t *space= fil_space_t::get(page_id.space()); @@ -427,6 +426,8 @@ dberr_t buf_read_page(const page_id_t page_id, ulint zip_size, /* Our caller should already have ensured that the page does not exist in buf_pool.page_hash. */ buf_block_t *block= nullptr; + unsigned zip_size= space->zip_size(); + if (UNIV_LIKELY(!zip_size)) { allocate_block: @@ -511,10 +512,9 @@ NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this function must be written such that it cannot end up waiting for these latches! @param[in] page_id page id; see NOTE 3 above -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @return number of page read requests issued */ TRANSACTIONAL_TARGET -ulint buf_read_ahead_linear(const page_id_t page_id, ulint zip_size) +ulint buf_read_ahead_linear(const page_id_t page_id) { /* check if readahead is disabled. Disable the read ahead logic for temporary tablespace */ @@ -553,6 +553,11 @@ fail: return 0; } + if (trx_sys_hdr_page(page_id)) + /* If it is an ibuf bitmap page or trx sys hdr, we do no + read-ahead, as that could break the ibuf page access order */ + goto fail; + /* How many out of order accessed pages can we ignore when working out the access pattern for linear readahead */ ulint count= std::min(buf_pool_t::READ_AHEAD_PAGES - @@ -647,6 +652,7 @@ failed: /* If we got this far, read-ahead can be sensible: do it */ buf_block_t *block= nullptr; + unsigned zip_size{space->zip_size()}; if (UNIV_LIKELY(!zip_size)) { allocate_block: diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index 7d4c7730499..c544325bc4c 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -647,7 +647,7 @@ dberr_t rtr_search_to_nth_level(btr_cur_t *cur, que_thr_t *thr, search_loop: auto buf_mode= BUF_GET; - ulint rw_latch= RW_NO_LATCH; + rw_lock_type_t rw_latch= RW_NO_LATCH; if (height) { @@ -658,7 +658,7 @@ dberr_t rtr_search_to_nth_level(btr_cur_t *cur, que_thr_t *thr, rw_latch= upper_rw_latch; } else if (latch_mode <= BTR_MODIFY_LEAF) - rw_latch= latch_mode; + rw_latch= rw_lock_type_t(latch_mode); dberr_t err; auto block_savepoint= mtr->get_savepoint(); diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index f2736b9b218..8316c02de95 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -191,33 +191,29 @@ be implemented at a higher level. In other words, all possible accesses to a given page through this function must be protected by the same set of mutexes or latches. @param page_id page identifier -@param zip_size ROW_FORMAT=COMPRESSED page size in bytes @return pointer to the block, s-latched */ -buf_page_t *buf_page_get_zip(const page_id_t page_id, ulint zip_size); +buf_page_t *buf_page_get_zip(const page_id_t page_id); /** Get access to a database page. Buffered redo log may be applied. @param[in] page_id page id @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH +@param[in] rw_latch latch mode @param[in] guess guessed block or NULL @param[in] mode BUF_GET, BUF_GET_IF_IN_POOL, or BUF_PEEK_IF_IN_POOL @param[in,out] mtr mini-transaction @param[out] err DB_SUCCESS or error code -@param[in,out] no_wait If not NULL on input, then we must not -wait for current page latch. On output, the value is set to true if we had to -return because we could not wait on page latch. -@return pointer to the block or NULL */ +@return pointer to the block +@retval nullptr if the block is corrupted or unavailable */ buf_block_t* buf_page_get_gen( const page_id_t page_id, ulint zip_size, - ulint rw_latch, + rw_lock_type_t rw_latch, buf_block_t* guess, ulint mode, mtr_t* mtr, - dberr_t* err = nullptr, - bool* no_wait = nullptr); + dberr_t* err = nullptr); /** Initialize a page in the buffer pool. The page is usually not read from a file even if it cannot be found in the buffer buf_pool. This is one @@ -357,8 +353,8 @@ void buf_page_print(const byte* read_buf, ulint zip_size = 0) ATTRIBUTE_COLD __attribute__((nonnull)); /********************************************************************//** Decompress a block. -@return TRUE if successful */ -ibool +@return true if successful */ +bool buf_zip_decompress( /*===============*/ buf_block_t* block, /*!< in/out: block */ @@ -627,30 +623,42 @@ public: public: const page_id_t &id() const { return id_; } uint32_t state() const { return zip.fix; } - uint32_t buf_fix_count() const - { - uint32_t f= state(); - ut_ad(f >= FREED); - return f < UNFIXED ? (f - FREED) : (~LRU_MASK & f); - } + static uint32_t buf_fix_count(uint32_t s) + { ut_ad(s >= FREED); return s < UNFIXED ? (s - FREED) : (~LRU_MASK & s); } + + uint32_t buf_fix_count() const { return buf_fix_count(state()); } + /** Check if a file block is io-fixed. + @param s state() + @return whether s corresponds to an io-fixed block */ + static bool is_io_fixed(uint32_t s) + { ut_ad(s >= FREED); return s >= READ_FIX; } + /** Check if a file block is read-fixed. + @param s state() + @return whether s corresponds to a read-fixed block */ + static bool is_read_fixed(uint32_t s) + { return is_io_fixed(s) && s < WRITE_FIX; } + /** Check if a file block is write-fixed. + @param s state() + @return whether s corresponds to a write-fixed block */ + static bool is_write_fixed(uint32_t s) + { ut_ad(s >= FREED); return s >= WRITE_FIX; } + /** @return whether this block is read or write fixed; read_complete() or write_complete() will always release the io-fix before releasing U-lock or X-lock */ - bool is_io_fixed() const - { const auto s= state(); ut_ad(s >= FREED); return s >= READ_FIX; } + bool is_io_fixed() const { return is_io_fixed(state()); } /** @return whether this block is write fixed; write_complete() will always release the write-fix before releasing U-lock */ - bool is_write_fixed() const { return state() >= WRITE_FIX; } - /** @return whether this block is read fixed; this should never hold - when a thread is holding the block lock in any mode */ - bool is_read_fixed() const { return is_io_fixed() && !is_write_fixed(); } + bool is_write_fixed() const { return is_write_fixed(state()); } + /** @return whether this block is read fixed */ + bool is_read_fixed() const { return is_read_fixed(state()); } /** @return if this belongs to buf_pool.unzip_LRU */ bool belongs_to_unzip_LRU() const { return UNIV_LIKELY_NULL(zip.data) && frame; } - bool is_freed() const - { const auto s= state(); ut_ad(s >= FREED); return s < UNFIXED; } + static bool is_freed(uint32_t s) { ut_ad(s >= FREED); return s < UNFIXED; } + bool is_freed() const { return is_freed(state()); } bool is_reinit() const { return !(~state() & REINIT); } void set_reinit(uint32_t prev_state) @@ -1358,11 +1366,43 @@ public: } public: + /** page_fix() mode of operation */ + enum page_fix_conflicts{ + /** Fetch if in the buffer pool, also blocks marked as free */ + FIX_ALSO_FREED= -1, + /** Fetch, waiting for page read completion */ + FIX_WAIT_READ, + /** Fetch, but avoid any waits for */ + FIX_NOWAIT + }; + /** Look up and buffer-fix a page. + Note: If the page is read-fixed (being read into the buffer pool), + we would have to wait for the page latch before determining if the page + is accessible (it could be corrupted and have been evicted again). + If the caller is holding other page latches so that waiting for this + page latch could lead to lock order inversion (latching order violation), + the mode c=FIX_WAIT_READ must not be used. @param id page identifier + @param err error code (will only be assigned when returning nullptr) + @param c how to handle conflicts @return undo log page, buffer-fixed + @retval -1 if c=FIX_NOWAIT and buffer-fixing would require waiting @retval nullptr if the undo page was corrupted or freed */ - buf_block_t *page_fix(const page_id_t id); + buf_block_t *page_fix(const page_id_t id, dberr_t *err, + page_fix_conflicts c); + + buf_block_t *page_fix(const page_id_t id) + { return page_fix(id, nullptr, FIX_WAIT_READ); } + + + /** Decompress a page and relocate the block descriptor + @param b buffer-fixed compressed-only ROW_FORMAT=COMPRESSED page + @param chain hash table chain for b->id().fold() + @return the decompressed block, x-latched and read-fixed + @retval nullptr if the decompression failed (b->unfix() will be invoked) */ + ATTRIBUTE_COLD __attribute__((nonnull, warn_unused_result)) + buf_block_t *unzip(buf_page_t *b, hash_chain &chain); /** @return whether the buffer pool contains a page @param page_id page identifier @@ -1572,8 +1612,8 @@ public: /** map of block->frame to buf_block_t blocks that belong to buf_buddy_alloc(); protected by buf_pool.mutex */ hash_table_t zip_hash; - Atomic_counter - n_pend_unzip; /*!< number of pending decompressions */ + /** number of pending unzip() */ + Atomic_counter n_pend_unzip; time_t last_printout_time; /*!< when buf_print_io was last time diff --git a/storage/innobase/include/buf0rea.h b/storage/innobase/include/buf0rea.h index 46d08243596..a439c9c80c0 100644 --- a/storage/innobase/include/buf0rea.h +++ b/storage/innobase/include/buf0rea.h @@ -33,15 +33,14 @@ buffer buf_pool if it is not already there. Sets the io_fix flag and sets an exclusive lock on the buffer frame. The flag is cleared and the x-lock released by the i/o-handler thread. @param page_id page id -@param zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param chain buf_pool.page_hash cell for page_id -@retval DB_SUCCESS if the page was read and is not corrupted, +@retval DB_SUCCESS if the page was read and is not corrupted @retval DB_SUCCESS_LOCKED_REC if the page was not read @retval DB_PAGE_CORRUPTED if page based on checksum check is corrupted, @retval DB_DECRYPTION_FAILED if page post encryption checksum matches but after decryption normal page checksum does not match. @retval DB_TABLESPACE_DELETED if tablespace .ibd file is missing */ -dberr_t buf_read_page(const page_id_t page_id, ulint zip_size, +dberr_t buf_read_page(const page_id_t page_id, buf_pool_t::hash_chain &chain); /** High-level function which reads a page asynchronously from a file to the @@ -63,9 +62,8 @@ pages: to avoid deadlocks this function must be written such that it cannot end up waiting for these latches! @param[in] page_id page id of a page which the current thread wants to access -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @return number of page read requests issued */ -ulint buf_read_ahead_random(const page_id_t page_id, ulint zip_size); +ulint buf_read_ahead_random(const page_id_t page_id); /** Applies linear read-ahead if in the buf_pool the page is a border page of a linear read-ahead area and all the pages in the area have been accessed. @@ -87,9 +85,8 @@ NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this function must be written such that it cannot end up waiting for these latches! @param[in] page_id page id; see NOTE 3 above -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @return number of page read requests issued */ -ulint buf_read_ahead_linear(const page_id_t page_id, ulint zip_size); +ulint buf_read_ahead_linear(const page_id_t page_id); /** Schedule a page for recovery. @param space tablespace diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 190591652c7..0d3440e79f6 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -2178,38 +2178,43 @@ updated then its state must be set to BUF_PAGE_NOT_USED. @retval DB_SUCCESS or error code. */ dberr_t PageConverter::operator()(buf_block_t* block) UNIV_NOTHROW { - /* If we already had an old page with matching number - in the buffer pool, evict it now, because - we no longer evict the pages on DISCARD TABLESPACE. */ - buf_page_get_gen(block->page.id(), get_zip_size(), RW_NO_LATCH, - nullptr, BUF_PEEK_IF_IN_POOL, - nullptr, nullptr, nullptr); + /* If we already had an old page with matching number in the buffer + pool, evict it now, because we no longer evict the pages on + DISCARD TABLESPACE. */ + if (buf_block_t *b= buf_pool.page_fix(block->page.id(), nullptr, + buf_pool_t::FIX_ALSO_FREED)) + { + ut_ad(!b->page.oldest_modification()); + mysql_mutex_lock(&buf_pool.mutex); + b->unfix(); - uint16_t page_type; + if (!buf_LRU_free_page(&b->page, true)) + ut_ad(0); - if (dberr_t err = update_page(block, page_type)) { - return err; - } + mysql_mutex_unlock(&buf_pool.mutex); + } - const bool full_crc32 = fil_space_t::full_crc32(get_space_flags()); - byte* frame = get_frame(block); - memset_aligned<8>(frame + FIL_PAGE_LSN, 0, 8); + uint16_t page_type; - if (!block->page.zip.data) { - buf_flush_init_for_writing( - NULL, block->page.frame, NULL, full_crc32); - } else if (fil_page_type_is_index(page_type)) { - buf_flush_init_for_writing( - NULL, block->page.zip.data, &block->page.zip, - full_crc32); - } else { - /* Calculate and update the checksum of non-index - pages for ROW_FORMAT=COMPRESSED tables. */ - buf_flush_update_zip_checksum( - block->page.zip.data, block->zip_size()); - } + if (dberr_t err= update_page(block, page_type)) + return err; - return DB_SUCCESS; + const bool full_crc32= fil_space_t::full_crc32(get_space_flags()); + byte *frame= get_frame(block); + memset_aligned<8>(frame + FIL_PAGE_LSN, 0, 8); + + if (!block->page.zip.data) + buf_flush_init_for_writing(nullptr, block->page.frame, nullptr, + full_crc32); + else if (fil_page_type_is_index(page_type)) + buf_flush_init_for_writing(nullptr, block->page.zip.data, &block->page.zip, + full_crc32); + else + /* Calculate and update the checksum of non-index + pages for ROW_FORMAT=COMPRESSED tables. */ + buf_flush_update_zip_checksum(block->page.zip.data, block->zip_size()); + + return DB_SUCCESS; } static void reload_fts_table(row_prebuilt_t *prebuilt, diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 2d19aa343e1..56e930417f5 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -2157,38 +2157,6 @@ corrupted_rec: mem_heap_empty(row_heap); if (!mtr_started) { - goto scan_next; - } - - if (clust_index->lock.is_waiting()) { - /* There are waiters on the clustered - index tree lock, likely the purge - thread. Store and restore the cursor - position, and yield so that scanning a - large table will not starve other - threads. */ - - /* Store the cursor position on the last user - record on the page. */ - if (!btr_pcur_move_to_prev_on_page(&pcur)) { - goto corrupted_index; - } - /* Leaf pages must never be empty, unless - this is the only page in the index tree. */ - if (!btr_pcur_is_on_user_rec(&pcur) - && btr_pcur_get_block(&pcur)->page.id() - .page_no() != clust_index->page) { - goto corrupted_index; - } - - btr_pcur_store_position(&pcur, &mtr); - mtr.commit(); - mtr_started = false; - - /* Give the waiters a chance to proceed. */ - std::this_thread::yield(); -scan_next: - ut_ad(!mtr_started); ut_ad(!mtr.is_active()); mtr.start(); mtr_started = true; @@ -2201,7 +2169,7 @@ scan_next: corrupted_index: err = DB_CORRUPTION; goto func_exit; - } + } /* Move to the successor of the original record. */ if (!btr_pcur_move_to_next_user_rec( @@ -2236,14 +2204,14 @@ end_of_index: buf_page_make_young_if_needed(&block->page); + const auto s = mtr.get_savepoint(); + mtr.rollback_to_savepoint(s - 2, s - 1); + page_cur_set_before_first(block, cur); if (!page_cur_move_to_next(cur) || page_cur_is_after_last(cur)) { goto corrupted_rec; } - - const auto s = mtr.get_savepoint(); - mtr.rollback_to_savepoint(s - 2, s - 1); } } else { mem_heap_empty(row_heap); diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index 93d68036755..264a021e3b1 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -185,7 +185,7 @@ trx_undo_get_prev_rec_from_prev_page(buf_block_t *&block, uint16_t rec, return nullptr; if (!buf_page_make_young_if_needed(&block->page)) - buf_read_ahead_linear(block->page.id(), 0); + buf_read_ahead_linear(block->page.id()); return trx_undo_page_get_last_rec(block, page_no, offset); } @@ -242,7 +242,7 @@ trx_undo_get_prev_rec(buf_block_t *&block, uint16_t rec, uint32_t page_no, static trx_undo_rec_t* trx_undo_get_next_rec_from_next_page(const buf_block_t *&block, uint32_t page_no, uint16_t offset, - ulint mode, mtr_t *mtr) + rw_lock_type_t mode, mtr_t *mtr) { if (page_no == block->page.id().page_no() && mach_read_from_2(block->page.frame + offset + TRX_UNDO_NEXT_LOG)) @@ -272,7 +272,8 @@ trx_undo_get_next_rec_from_next_page(const buf_block_t *&block, @retval nullptr if none */ static trx_undo_rec_t* trx_undo_get_first_rec(const fil_space_t &space, uint32_t page_no, - uint16_t offset, ulint mode, const buf_block_t*& block, + uint16_t offset, rw_lock_type_t mode, + const buf_block_t *&block, mtr_t *mtr, dberr_t *err) { buf_block_t *b= buf_page_get_gen(page_id_t{space.id, page_no}, 0, mode, @@ -282,7 +283,7 @@ trx_undo_get_first_rec(const fil_space_t &space, uint32_t page_no, return nullptr; if (!buf_page_make_young_if_needed(&b->page)) - buf_read_ahead_linear(b->page.id(), 0); + buf_read_ahead_linear(b->page.id()); if (trx_undo_rec_t *rec= trx_undo_page_get_first_rec(b, page_no, offset)) return rec;