diff options
author | Eugene Kosov <claprix@yandex.ru> | 2020-10-27 12:24:55 +0300 |
---|---|---|
committer | Eugene Kosov <claprix@yandex.ru> | 2020-10-27 19:09:20 +0300 |
commit | afc9d00c66db946c8240fe1fa6b345a3a8b6fec1 (patch) | |
tree | 6046d3f57efbdb10767daaf3238af9d0bf07434c /mysql-test/suite | |
parent | 42e1815ad850384fad292534665ff61b78dd96f6 (diff) | |
download | mariadb-git-afc9d00c66db946c8240fe1fa6b345a3a8b6fec1.tar.gz |
MDEV-23991 dict_table_stats_lock() has unnecessarily long scope
Patch removes dict_index_t::stats_latch. Table/index statistics now
protected with dict_sys->mutex. That way statistics computation can
happen in parallel in several threads and dict_sys->mutex will be locked
only for a short period of time.
This patch is a joint work with Marko Mäkelä
dict_index_t::lock: make mutable which allows to pass const pointer
when only lock is touched in an object
btr_height_get()
btr_get_size(): make index argument const for better type safety
btr_estimate_number_of_different_key_vals(): now returns computed values
instead of setting fields in dict_index_t directly
remove everything related to dict_index_t::stats_latch
dict_stats_index_set_n_diff(): now returns computed values instead
of setting fields in dict_index_t directly
dict_stats_analyze_index(): now returns computed values instead
of setting fields in dict_index_t directly
Reviewed by: Marko Mäkelä
Diffstat (limited to 'mysql-test/suite')
-rw-r--r-- | mysql-test/suite/innodb/r/stats_persistent.result | 18 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/stats_persistent.test | 27 |
2 files changed, 45 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/r/stats_persistent.result b/mysql-test/suite/innodb/r/stats_persistent.result new file mode 100644 index 00000000000..c96afb41af2 --- /dev/null +++ b/mysql-test/suite/innodb/r/stats_persistent.result @@ -0,0 +1,18 @@ +# +# MDEV-23991 dict_table_stats_lock() has unnecessarily long scope +# +CREATE TABLE t1(a INT) ENGINE=INNODB STATS_PERSISTENT=1; +SET DEBUG_SYNC='dict_stats_update_persistent SIGNAL stop WAIT_FOR go'; +ANALYZE TABLE t1; +connect con1, localhost, root; +SET DEBUG_SYNC='now WAIT_FOR stop'; +SELECT ENGINE,SUM(DATA_LENGTH+INDEX_LENGTH),COUNT(ENGINE),SUM(DATA_LENGTH),SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE ENGINE='InnoDB'; +ENGINE SUM(DATA_LENGTH+INDEX_LENGTH) COUNT(ENGINE) SUM(DATA_LENGTH) SUM(INDEX_LENGTH) +InnoDB 49152 3 49152 0 +SET DEBUG_SYNC='now SIGNAL go'; +disconnect con1; +connection default; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET DEBUG_SYNC= 'RESET'; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/stats_persistent.test b/mysql-test/suite/innodb/t/stats_persistent.test new file mode 100644 index 00000000000..ac412d56d0d --- /dev/null +++ b/mysql-test/suite/innodb/t/stats_persistent.test @@ -0,0 +1,27 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/count_sessions.inc + +--echo # +--echo # MDEV-23991 dict_table_stats_lock() has unnecessarily long scope +--echo # +CREATE TABLE t1(a INT) ENGINE=INNODB STATS_PERSISTENT=1; + +SET DEBUG_SYNC='dict_stats_update_persistent SIGNAL stop WAIT_FOR go'; +--send ANALYZE TABLE t1 + +--connect(con1, localhost, root) +SET DEBUG_SYNC='now WAIT_FOR stop'; + +SELECT ENGINE,SUM(DATA_LENGTH+INDEX_LENGTH),COUNT(ENGINE),SUM(DATA_LENGTH),SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE ENGINE='InnoDB'; + +SET DEBUG_SYNC='now SIGNAL go'; +--disconnect con1 + +--connection default +--reap +SET DEBUG_SYNC= 'RESET'; +DROP TABLE t1; + +--source include/wait_until_count_sessions.inc |