summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-12-09 21:33:08 -0800
committerIgor Babaev <igor@askmonty.org>2012-12-09 21:33:08 -0800
commit109c104d07c6cce68ecae66c1a4dcdb83826954f (patch)
tree71e5a958c3bc7ee2a559231f699062eb3188649c
parent2447bc4c818434d2e6411dccf58887b45d47af58 (diff)
downloadmariadb-git-109c104d07c6cce68ecae66c1a4dcdb83826954f.tar.gz
Addressed the following issue from the review of the patch for
engine-independent statistics. If a table was created for InnoDB then the execution of the ANALYZE command over this table blocked any INSERT/DELETE/UPDATE of the table.
-rw-r--r--mysql-test/r/stat_tables_par.result40
-rw-r--r--mysql-test/r/stat_tables_par_innodb.result46
-rw-r--r--mysql-test/t/stat_tables_par.test50
-rw-r--r--sql/sql_statistics.cc2
-rw-r--r--storage/xtradb/handler/ha_innodb.cc3
5 files changed, 140 insertions, 1 deletions
diff --git a/mysql-test/r/stat_tables_par.result b/mysql-test/r/stat_tables_par.result
index c5ae92456b7..c97f8a027d9 100644
--- a/mysql-test/r/stat_tables_par.result
+++ b/mysql-test/r/stat_tables_par.result
@@ -162,6 +162,46 @@ dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
+select * from mysql.index_stats where table_name='lineitem'
+ order by index_name, prefix_arity;
+db_name table_name index_name prefix_arity avg_frequency
+dbt3_s001 lineitem PRIMARY 1 4.0033
+dbt3_s001 lineitem PRIMARY 2 1.0000
+dbt3_s001 lineitem i_l_commitdate 1 2.7160
+dbt3_s001 lineitem i_l_orderkey 1 4.0033
+dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
+dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
+dbt3_s001 lineitem i_l_partkey 1 30.0250
+dbt3_s001 lineitem i_l_receiptdate 1 2.6477
+dbt3_s001 lineitem i_l_shipdate 1 2.6500
+dbt3_s001 lineitem i_l_suppkey 1 600.5000
+dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
+dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
+set debug_sync='RESET';
+set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish';
+use dbt3_s001;
+set use_stat_tables='preferably';
+analyze table lineitem persistent for all;
+set debug_sync='now WAIT_FOR parked';
+use dbt3_s001;
+set use_stat_tables='never';
+set debug_sync='now SIGNAL finish';
+set debug_sync='RESET';
+select * from mysql.index_stats where table_name='lineitem'
+ order by index_name, prefix_arity;
+db_name table_name index_name prefix_arity avg_frequency
+dbt3_s001 lineitem PRIMARY 1 4.0033
+dbt3_s001 lineitem PRIMARY 2 1.0000
+dbt3_s001 lineitem i_l_commitdate 1 2.7160
+dbt3_s001 lineitem i_l_orderkey 1 4.0033
+dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
+dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
+dbt3_s001 lineitem i_l_partkey 1 30.0250
+dbt3_s001 lineitem i_l_receiptdate 1 2.6477
+dbt3_s001 lineitem i_l_shipdate 1 2.6500
+dbt3_s001 lineitem i_l_suppkey 1 600.5000
+dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
+dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
DROP DATABASE dbt3_s001;
use test;
set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/r/stat_tables_par_innodb.result b/mysql-test/r/stat_tables_par_innodb.result
index 7d73838ed37..9ef67245c8c 100644
--- a/mysql-test/r/stat_tables_par_innodb.result
+++ b/mysql-test/r/stat_tables_par_innodb.result
@@ -165,6 +165,52 @@ dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
+select * from mysql.index_stats where table_name='lineitem'
+ order by index_name, prefix_arity;
+db_name table_name index_name prefix_arity avg_frequency
+dbt3_s001 lineitem PRIMARY 1 4.0033
+dbt3_s001 lineitem PRIMARY 2 1.0000
+dbt3_s001 lineitem i_l_commitdate 1 2.7160
+dbt3_s001 lineitem i_l_orderkey 1 4.0033
+dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
+dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
+dbt3_s001 lineitem i_l_partkey 1 30.0250
+dbt3_s001 lineitem i_l_receiptdate 1 2.6477
+dbt3_s001 lineitem i_l_shipdate 1 2.6500
+dbt3_s001 lineitem i_l_suppkey 1 600.5000
+dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
+dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
+set debug_sync='RESET';
+set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish';
+use dbt3_s001;
+set use_stat_tables='preferably';
+analyze table lineitem persistent for all;
+set debug_sync='now WAIT_FOR parked';
+use dbt3_s001;
+set use_stat_tables='never';
+select * from lineitem where l_orderkey=1 and l_partkey=156;
+l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
+1 156 4 1 17 17954.55 0.04 0.02 N O 1996-03-13 1996-02-12 1996-03-22 DELIVER IN PERSON TRUCK blithely regular ideas caj
+delete from lineitem where l_orderkey=1 and l_partkey=156;
+select * from lineitem where l_orderkey=1 and l_partkey=156;
+l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
+set debug_sync='now SIGNAL finish';
+set debug_sync='RESET';
+select * from mysql.index_stats where table_name='lineitem'
+ order by index_name, prefix_arity;
+db_name table_name index_name prefix_arity avg_frequency
+dbt3_s001 lineitem PRIMARY 1 4.0027
+dbt3_s001 lineitem PRIMARY 2 1.0000
+dbt3_s001 lineitem i_l_commitdate 1 2.7155
+dbt3_s001 lineitem i_l_orderkey 1 4.0027
+dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0027
+dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
+dbt3_s001 lineitem i_l_partkey 1 30.0200
+dbt3_s001 lineitem i_l_receiptdate 1 2.6473
+dbt3_s001 lineitem i_l_shipdate 1 2.6496
+dbt3_s001 lineitem i_l_suppkey 1 600.4000
+dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0200
+dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5771
DROP DATABASE dbt3_s001;
use test;
set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/t/stat_tables_par.test b/mysql-test/t/stat_tables_par.test
index ee2edfd8c01..f3f2b084c95 100644
--- a/mysql-test/t/stat_tables_par.test
+++ b/mysql-test/t/stat_tables_par.test
@@ -146,6 +146,56 @@ set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
+#
+# Test for parallel statistics collection and update (innodb)
+#
+
+select * from mysql.index_stats where table_name='lineitem'
+ order by index_name, prefix_arity;
+set debug_sync='RESET';
+
+let $innodb_storage_engine= 0;
+if (`SELECT UPPER(@@storage_engine) = 'INNODB'`)
+{
+ let $innodb_storage_engine= 1;
+}
+
+connect (con1, localhost, root,,);
+connect (con2, localhost, root,,);
+
+connection con1;
+set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish';
+use dbt3_s001;
+set use_stat_tables='preferably';
+--send analyze table lineitem persistent for all
+
+connection con2;
+set debug_sync='now WAIT_FOR parked';
+use dbt3_s001;
+set use_stat_tables='never';
+if ($innodb_storage_engine)
+{
+ select * from lineitem where l_orderkey=1 and l_partkey=156;
+ delete from lineitem where l_orderkey=1 and l_partkey=156;
+ select * from lineitem where l_orderkey=1 and l_partkey=156;
+}
+set debug_sync='now SIGNAL finish';
+
+connection con1;
+--disable_result_log
+--disable_warnings
+--reap
+--enable_warnings
+--enable_result_log
+
+connection default;
+disconnect con1;
+disconnect con2;
+set debug_sync='RESET';
+
+select * from mysql.index_stats where table_name='lineitem'
+ order by index_name, prefix_arity;
+
DROP DATABASE dbt3_s001;
use test;
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index f8f1175ac28..4becf5ab7ae 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -2058,6 +2058,8 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
/* Perform a full table scan to collect statistics on 'table's columns */
if (!(rc= file->ha_rnd_init(TRUE)))
{
+ DEBUG_SYNC(table->in_use, "statistics_collection_start");
+
while ((rc= file->ha_rnd_next(table->record[0])) != HA_ERR_END_OF_FILE)
{
if (thd->killed)
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 5cf3b021510..6ad4a4b0a66 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -11078,7 +11078,8 @@ ha_innobase::store_lock(
prebuilt->select_lock_type = LOCK_NONE;
prebuilt->stored_select_lock_type = LOCK_NONE;
- } else if (sql_command == SQLCOM_CHECKSUM) {
+ } else if (sql_command == SQLCOM_CHECKSUM ||
+ sql_command == SQLCOM_ANALYZE) {
/* Use consistent read for checksum table */
prebuilt->select_lock_type = LOCK_NONE;