Commit cbc75e99 authored by Rucha Deodhar's avatar Rucha Deodhar

MDEV-20939: Race condition between mysqldump import and InnoDB persistent

statistics calculation

 Analysis: When --replace or --insert-ignore is not given, dumping of
mysql.innodb_index_stats and mysql.innodb_table_stats will result into race
condition.
Fix: Check if these options are present with --system=stats (because dumping
under --system=stats is safe). Otherwise, dump only structure, ignoring data
because innodb will recalculate data anyway.
parent 5fd3c747
......@@ -1052,6 +1052,20 @@ static int get_options(int *argc, char ***argv)
if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))
return(ho_error);
/*
Dumping under --system=stats with --replace or --inser-ignore is safe and will not
retult into race condition. Otherwise dump only structure and ignore data by default
while dumping.
*/
if (!(opt_system & OPT_SYSTEM_STATS) && !(opt_ignore || opt_replace_into))
{
if (my_hash_insert(&ignore_data,
(uchar*) my_strdup("mysql.innodb_index_stats", MYF(MY_WME))) ||
my_hash_insert(&ignore_data,
(uchar*) my_strdup("mysql.innodb_table_stats", MYF(MY_WME))))
return(EX_EOM);
}
if (opt_system & OPT_SYSTEM_ALL)
opt_system|= ~0;
......
This diff is collapsed.
......@@ -2735,4 +2735,27 @@ INSERT INTO t1 (a) VALUES (1),(2),(3);
--exec $MYSQL_DUMP --default-character-set=utf8mb4 --triggers --no-data --no-create-info --add-drop-trigger --skip-comments --databases test
DROP TABLE t1;
--echo #
--echo # MDEV-20939: Race condition between mysqldump import and InnoDB
--echo # persistent statistics calculation
--echo #
--let $ignore= --ignore-table=mysql.proxies_priv --ignore-table=mysql.user --ignore-table=mysql.column_stats --ignore-table=mysql.columns_priv --ignore-table=mysql.db --ignore-table=mysql.event --ignore-table=mysql.func --ignore-table=mysql.gtid_slave_pos --ignore-table=mysql.help_category --ignore-table=mysql.help_keyword --ignore-table=mysql.help_relation --ignore-table=mysql.help_topic --ignore-table=mysql.host --ignore-table=mysql.index_stats --ignore-table=mysql.plugin --ignore-table=mysql.proc --ignore-table=mysql.procs_priv --ignore-table=mysql.roles_mapping --ignore-table=mysql.servers --ignore-table=mysql.table_stats --ignore-table=mysql.tables_priv --ignore-table=mysql.time_zone --ignore-table=mysql.time_zone_leap_second --ignore-table=mysql.time_zone_name --ignore-table=mysql.time_zone_transition --ignore-table=mysql.time_zone_transition_type --ignore-table=mysql.general_log --ignore-table=mysql.slow_log
--let $skip_opts= --skip-dump-date --skip-comments
--echo #
--echo # Without --replace and --insert-ignore
--echo #
--exec $MYSQL_DUMP $ignore $skip_opts mysql
--echo #
--echo # With --replace
--echo #
--exec $MYSQL_DUMP $ignore $skip_opts --replace mysql
--echo #
--echo # With --insert-ignore
--echo #
--exec $MYSQL_DUMP $ignore $skip_opts --insert-ignore mysql
--echo # End of 10.2 tests
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment