mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
e66928ab28
Problem: ======= - When online alter of InnoDB statistics table happens, any transaction which updates the statistics table has to read the undo log and log the DML changes during transaction commit. Applying undo log (UndorecApplier::apply_undo_rec) requires a shared lock on dictionary cache but dict_stats_save() already holds write lock on dictionary cache. This leads to abort of server during commit of statistics table changes. Solution: ======== - Disallow LOCK=NONE operation for the InnoDB statistics table. The reasoning is that statistics tables are typically rather small, so any blocking would be rather short. Writes to the statistics tables should be a rare operation.
183 lines
5 KiB
Text
183 lines
5 KiB
Text
set @save_use_stat_tables = @@use_stat_tables;
|
|
set @@use_stat_tables = COMPLEMENTARY;
|
|
CREATE TABLE test_ps_fetch
|
|
(a INT, b INT, c INT, d INT, PRIMARY KEY (a, b), INDEX idx (c, d))
|
|
ENGINE=INNODB STATS_PERSISTENT=1;
|
|
ANALYZE TABLE test_ps_fetch;
|
|
Table test.test_ps_fetch
|
|
Op analyze
|
|
Msg_type status
|
|
Msg_text Engine-independent statistics collected
|
|
Table test.test_ps_fetch
|
|
Op analyze
|
|
Msg_type status
|
|
Msg_text OK
|
|
SELECT n_rows, clustered_index_size, sum_of_other_index_sizes
|
|
FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_fetch';
|
|
n_rows 0
|
|
clustered_index_size 1
|
|
sum_of_other_index_sizes 1
|
|
SELECT index_name, stat_name, stat_value, sample_size, stat_description
|
|
FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_fetch'
|
|
ORDER BY index_name, stat_name;
|
|
index_name PRIMARY
|
|
stat_name n_diff_pfx01
|
|
stat_value 0
|
|
sample_size 1
|
|
stat_description a
|
|
index_name PRIMARY
|
|
stat_name n_diff_pfx02
|
|
stat_value 0
|
|
sample_size 1
|
|
stat_description a,b
|
|
index_name PRIMARY
|
|
stat_name n_leaf_pages
|
|
stat_value 1
|
|
sample_size NULL
|
|
stat_description Number of leaf pages in the index
|
|
index_name PRIMARY
|
|
stat_name size
|
|
stat_value 1
|
|
sample_size NULL
|
|
stat_description Number of pages in the index
|
|
index_name idx
|
|
stat_name n_diff_pfx01
|
|
stat_value 0
|
|
sample_size 1
|
|
stat_description c
|
|
index_name idx
|
|
stat_name n_diff_pfx02
|
|
stat_value 0
|
|
sample_size 1
|
|
stat_description c,d
|
|
index_name idx
|
|
stat_name n_diff_pfx03
|
|
stat_value 0
|
|
sample_size 1
|
|
stat_description c,d,a
|
|
index_name idx
|
|
stat_name n_diff_pfx04
|
|
stat_value 0
|
|
sample_size 1
|
|
stat_description c,d,a,b
|
|
index_name idx
|
|
stat_name n_leaf_pages
|
|
stat_value 1
|
|
sample_size NULL
|
|
stat_description Number of leaf pages in the index
|
|
index_name idx
|
|
stat_name size
|
|
stat_value 1
|
|
sample_size NULL
|
|
stat_description Number of pages in the index
|
|
SELECT index_name, seq_in_index, column_name, cardinality
|
|
FROM information_schema.statistics WHERE table_name = 'test_ps_fetch'
|
|
ORDER BY index_name, seq_in_index;
|
|
index_name idx
|
|
seq_in_index 1
|
|
column_name c
|
|
cardinality 0
|
|
index_name idx
|
|
seq_in_index 2
|
|
column_name d
|
|
cardinality 0
|
|
index_name PRIMARY
|
|
seq_in_index 1
|
|
column_name a
|
|
cardinality 0
|
|
index_name PRIMARY
|
|
seq_in_index 2
|
|
column_name b
|
|
cardinality 0
|
|
SELECT
|
|
table_rows, avg_row_length, max_data_length, index_length
|
|
FROM information_schema.tables WHERE table_name = 'test_ps_fetch';
|
|
table_rows 0
|
|
avg_row_length 0
|
|
max_data_length 0
|
|
index_length 16384
|
|
UPDATE mysql.innodb_table_stats SET
|
|
n_rows = 1000,
|
|
clustered_index_size = 5
|
|
WHERE
|
|
table_name = 'test_ps_fetch';
|
|
UPDATE mysql.innodb_index_stats SET
|
|
stat_value = 20
|
|
WHERE
|
|
table_name = 'test_ps_fetch' AND
|
|
index_name = 'PRIMARY' AND
|
|
stat_name = 'n_diff_pfx01';
|
|
UPDATE mysql.innodb_index_stats SET
|
|
stat_value = 90
|
|
WHERE
|
|
table_name = 'test_ps_fetch' AND
|
|
index_name = 'PRIMARY' AND
|
|
stat_name = 'n_diff_pfx02';
|
|
UPDATE mysql.innodb_index_stats SET
|
|
stat_value = 3
|
|
WHERE
|
|
table_name = 'test_ps_fetch' AND
|
|
index_name = 'idx' AND
|
|
stat_name = 'n_diff_pfx01';
|
|
UPDATE mysql.innodb_index_stats SET
|
|
stat_value = 11
|
|
WHERE
|
|
table_name = 'test_ps_fetch' AND
|
|
index_name = 'idx' AND
|
|
stat_name = 'n_diff_pfx02';
|
|
FLUSH TABLE test_ps_fetch;
|
|
SELECT seq_in_index, column_name, cardinality
|
|
FROM information_schema.statistics WHERE table_name = 'test_ps_fetch'
|
|
ORDER BY index_name, seq_in_index;
|
|
seq_in_index 1
|
|
column_name c
|
|
cardinality 6
|
|
seq_in_index 2
|
|
column_name d
|
|
cardinality 22
|
|
seq_in_index 1
|
|
column_name a
|
|
cardinality 40
|
|
seq_in_index 2
|
|
column_name b
|
|
cardinality 200
|
|
SELECT
|
|
table_rows, avg_row_length, max_data_length, index_length
|
|
FROM information_schema.tables WHERE table_name = 'test_ps_fetch';
|
|
table_rows 1000
|
|
avg_row_length 81
|
|
max_data_length 0
|
|
index_length 16384
|
|
DROP TABLE test_ps_fetch;
|
|
set @@use_stat_tables = @save_use_stat_tables;
|
|
#
|
|
# MDEV-28613 LeakSanitizer caused by I_S query using LIMIT ROWS EXAMINED
|
|
#
|
|
CREATE TABLE t1(f1 VARCHAR(255), FULLTEXT(f1))ENGINE=InnoDB;
|
|
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES LIMIT ROWS EXAMINED 5;
|
|
Warnings:
|
|
Level Warning
|
|
Code 1931
|
|
Message Query execution was interrupted. The query exceeded LIMIT ROWS EXAMINED 5. The query result may be incomplete
|
|
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES LIMIT ROWS EXAMINED 5;
|
|
Warnings:
|
|
Level Warning
|
|
Code 1931
|
|
Message Query execution was interrupted. The query exceeded LIMIT ROWS EXAMINED 5. The query result may be incomplete
|
|
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS LIMIT ROWS EXAMINED 5;
|
|
Warnings:
|
|
Level Warning
|
|
Code 1931
|
|
Message Query execution was interrupted. The query exceeded LIMIT ROWS EXAMINED 5. The query result may be incomplete
|
|
SELECT SPACE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES LIMIT ROWS EXAMINED 5;
|
|
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_VIRTUAL LIMIT ROWS EXAMINED 5;
|
|
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN LIMIT ROWS EXAMINED 5;
|
|
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS LIMIT ROWS EXAMINED 5;
|
|
DROP TABLE t1;
|
|
#
|
|
# MDEV-33462 Disallow LOCK=NONE operation on statistics table
|
|
#
|
|
ALTER TABLE mysql.innodb_table_stats FORCE, LOCK=NONE;
|
|
ERROR 0A000: LOCK=NONE is not supported. Reason: innodb_table_stats. Try LOCK=SHARED
|
|
ALTER TABLE mysql.innodb_index_stats FORCE, LOCK=NONE;
|
|
ERROR 0A000: LOCK=NONE is not supported. Reason: innodb_index_stats. Try LOCK=SHARED
|