From d7b0b8ddacd6a27e0ea1c5fbad75aae60ed03d6b Mon Sep 17 00:00:00 2001 From: Monty Date: Sun, 3 Dec 2017 15:21:53 +0200 Subject: [PATCH 1/2] MDEV-10688 rpl.rpl_row_log_innodb failed in buildbot Problem was that Binlog_checkpoint can happen at random times. Fixed by not write binlog_checkpoint for the rpl_log test. Other things: - Removed not used variable "$keep_gtid_events" - Added option for show_binlog_events to skip binlog_checkpoint --- mysql-test/extra/rpl_tests/rpl_log.test | 2 ++ mysql-test/include/filter_file.inc | 11 ++++++++++- mysql-test/include/show_binlog_events.inc | 8 +------- mysql-test/include/show_events.inc | 7 +++++++ mysql-test/suite/rpl/r/rpl_row_log.result | 2 -- mysql-test/suite/rpl/r/rpl_row_log_innodb.result | 2 -- mysql-test/suite/rpl/r/rpl_stm_log.result | 2 -- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_log.test b/mysql-test/extra/rpl_tests/rpl_log.test index 01e8497e4de..934f40306ab 100644 --- a/mysql-test/extra/rpl_tests/rpl_log.test +++ b/mysql-test/extra/rpl_tests/rpl_log.test @@ -65,6 +65,8 @@ flush logs; # To make it predictable, we do a useless update now, but which has the # interest of making the slave catch both rotate events. +let $skip_checkpoint_events=1; + eval create table t3 (a int)ENGINE=$engine_type; # Sync slave and force it to start on another binary log diff --git a/mysql-test/include/filter_file.inc b/mysql-test/include/filter_file.inc index 17c7c1985d7..bfe53896710 100644 --- a/mysql-test/include/filter_file.inc +++ b/mysql-test/include/filter_file.inc @@ -53,6 +53,9 @@ # # $rpl_debug # If set, verbose debug info is printed. +# +# $filter_script +# If set, rows matching this regexp will be filtered out --let $include_filename= filter_file.inc --source include/begin_include_file.inc @@ -67,10 +70,12 @@ if ($rpl_debug) --let _FF_PRE_SCRIPT= $pre_script --let _FF_SCRIPT= $script +--let _FF_FILTER_SCRIPT= $filter_script --let _FF_INPUT_FILE= $input_file --let _FF_OUTPUT_FILE= $output_file --let _FF_SELECT_COLUMNS= $select_columns --let _FF_DEBUG= $rpl_debug + if (!$output_file) { --let _FF_OUTPUT_FILE= $input_file @@ -79,6 +84,7 @@ perl; my $pre_script = $ENV{'_FF_PRE_SCRIPT'}; $pre_script =~ s/DOLLAR/\$/g; my $script = $ENV{'_FF_SCRIPT'}; + my $filter_script = $ENV{'_FF_FILTER_SCRIPT'}; $script =~ s/DOLLAR/\$/g; my $input_file = $ENV{'_FF_INPUT_FILE'}; my $output_file = $ENV{'_FF_OUTPUT_FILE'}; @@ -123,7 +129,10 @@ perl; { ' . $script . ' } - $filtered_contents .= $_."\n"; + if (!$filter_script || ! m/$filter_script/) + { + $filtered_contents .= $_."\n"; + } } close FILE or die "Error closing $input_file: $!"; open FILE, "> $output_file" or die "Error opening $output_file: $!"; diff --git a/mysql-test/include/show_binlog_events.inc b/mysql-test/include/show_binlog_events.inc index b2462e0d1b1..57fe1ffe0e3 100644 --- a/mysql-test/include/show_binlog_events.inc +++ b/mysql-test/include/show_binlog_events.inc @@ -7,7 +7,7 @@ # [--let $binlog_file= [ | LAST]] # [--let $binlog_start= ] # [--let $binlog_limit= 1, 3 ] -# [--let $keep_gtid_events= 1] +# [--let $skip_checkpoint_events= 1] # --source include/show_binlog_events.inc # # Parameters: @@ -26,12 +26,6 @@ # Limit for the 'LIMIT' clause of SHOW BINLOG EVENTS, i.e.: # $binlog_limit= 3 -- print three events # $binlog_limit= 4, 3 -- skip four events, print the three next events -# -# $keep_gtid_events -# By default, Gtid_log_event and Previous_gtid_log_event are -# filtered out, so that the output is independent of whether GTIDs -# are enabled or not. If this flag is set, events are kept but -# the actual GTID values are masked out. --let $include_filename= show_binlog_events.inc --source include/begin_include_file.inc diff --git a/mysql-test/include/show_events.inc b/mysql-test/include/show_events.inc index 368cfc9e3a7..9ee01f73999 100644 --- a/mysql-test/include/show_events.inc +++ b/mysql-test/include/show_events.inc @@ -104,8 +104,15 @@ let $script= s{DOLLARmysqltest_vardir}{MYSQLTEST_VARDIR}g; || --let $pre_script= my DOLLARmysqltest_vardir = DOLLARENV{'MYSQLTEST_VARDIR'}; + --delimiter ; +if ($skip_checkpoint_events) +{ + let $filter_script=Binlog_checkpoint; +} + + #--let $select_columns= 1 3 6 --let $input_file= $output_file --source include/filter_file.inc diff --git a/mysql-test/suite/rpl/r/rpl_row_log.result b/mysql-test/suite/rpl/r/rpl_row_log.result index 83ec26486e0..4ff3d45e2bb 100644 --- a/mysql-test/suite/rpl/r/rpl_row_log.result +++ b/mysql-test/suite/rpl/r/rpl_row_log.result @@ -215,7 +215,6 @@ master-bin.000001 # Query # # COMMIT master-bin.000001 # Rotate # # master-bin.000002;pos=POS include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000002 # Binlog_checkpoint # # master-bin.000002 master-bin.000002 # Gtid # # GTID #-#-# master-bin.000002 # Query # # use `test`; create table t3 (a int)ENGINE=MyISAM master-bin.000002 # Gtid # # GTID #-#-# @@ -253,7 +252,6 @@ slave-bin.000001 # Query # # use `test`; create table t3 (a int)ENGINE=MyISAM slave-bin.000001 # Rotate # # slave-bin.000002;pos=POS include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -slave-bin.000002 # Binlog_checkpoint # # slave-bin.000002 slave-bin.000002 # Gtid # # GTID #-#-# slave-bin.000002 # Query # # use `test`; create table t2 (n int)ENGINE=MyISAM slave-bin.000002 # Gtid # # BEGIN GTID #-#-# diff --git a/mysql-test/suite/rpl/r/rpl_row_log_innodb.result b/mysql-test/suite/rpl/r/rpl_row_log_innodb.result index 3b9733a18e8..c78e0e4816e 100644 --- a/mysql-test/suite/rpl/r/rpl_row_log_innodb.result +++ b/mysql-test/suite/rpl/r/rpl_row_log_innodb.result @@ -215,7 +215,6 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Rotate # # master-bin.000002;pos=POS include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000002 # Binlog_checkpoint # # master-bin.000002 master-bin.000002 # Gtid # # GTID #-#-# master-bin.000002 # Query # # use `test`; create table t3 (a int)ENGINE=InnoDB master-bin.000002 # Gtid # # GTID #-#-# @@ -253,7 +252,6 @@ slave-bin.000001 # Query # # use `test`; create table t3 (a int)ENGINE=InnoDB slave-bin.000001 # Rotate # # slave-bin.000002;pos=POS include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -slave-bin.000002 # Binlog_checkpoint # # slave-bin.000002 slave-bin.000002 # Gtid # # GTID #-#-# slave-bin.000002 # Query # # use `test`; create table t2 (n int)ENGINE=InnoDB slave-bin.000002 # Gtid # # BEGIN GTID #-#-# diff --git a/mysql-test/suite/rpl/r/rpl_stm_log.result b/mysql-test/suite/rpl/r/rpl_stm_log.result index da925035c9c..4d187095d17 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_log.result +++ b/mysql-test/suite/rpl/r/rpl_stm_log.result @@ -215,7 +215,6 @@ master-bin.000001 # Query # # COMMIT master-bin.000001 # Rotate # # master-bin.000002;pos=POS include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000002 # Binlog_checkpoint # # master-bin.000002 master-bin.000002 # Gtid # # GTID #-#-# master-bin.000002 # Query # # use `test`; create table t3 (a int)ENGINE=MyISAM master-bin.000002 # Gtid # # GTID #-#-# @@ -252,7 +251,6 @@ slave-bin.000001 # Query # # use `test`; create table t3 (a int)ENGINE=MyISAM slave-bin.000001 # Rotate # # slave-bin.000002;pos=POS include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -slave-bin.000002 # Binlog_checkpoint # # slave-bin.000002 slave-bin.000002 # Gtid # # GTID #-#-# slave-bin.000002 # Query # # use `test`; create table t2 (n int)ENGINE=MyISAM slave-bin.000002 # Gtid # # BEGIN GTID #-#-# From 63cbb982752eda34c8025c6daea9e4d2389807d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 5 Dec 2017 13:25:09 +0200 Subject: [PATCH 2/2] MDEV-14587 dict_stats_process_entry_from_defrag_pool() fails to call dict_table_close() when index==NULL dict_stats_process_entry_from_defrag_pool(): Simplify the logic, and always call dict_table_close() when dict_table_open() returned a non-NULL handle. --- storage/innobase/dict/dict0stats_bg.cc | 30 +++++++------------------- storage/xtradb/dict/dict0stats_bg.cc | 30 +++++++------------------- 2 files changed, 16 insertions(+), 44 deletions(-) diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 43ee1a236ce..1c599136a6d 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -478,7 +478,6 @@ stats and eventually save its stats. */ static void dict_stats_process_entry_from_defrag_pool() -/*=======================================*/ { table_id_t table_id; index_id_t index_id; @@ -500,31 +499,18 @@ dict_stats_process_entry_from_defrag_pool() table = dict_table_open_on_id(table_id, TRUE, DICT_TABLE_OP_OPEN_ONLY_IF_CACHED); - if (table == NULL) { + dict_index_t* index = table && !table->corrupted + ? dict_table_find_index_on_id(table, index_id) + : NULL; + + if (!index || dict_index_is_corrupted(index)) { + if (table) { + dict_table_close(table, TRUE, FALSE); + } mutex_exit(&dict_sys->mutex); return; } - /* Check whether table is corrupted */ - if (table->corrupted) { - dict_table_close(table, TRUE, FALSE); - mutex_exit(&dict_sys->mutex); - return; - } - mutex_exit(&dict_sys->mutex); - - dict_index_t* index = dict_table_find_index_on_id(table, index_id); - - if (index == NULL) { - return; - } - - /* Check whether index is corrupted */ - if (dict_index_is_corrupted(index)) { - dict_table_close(table, FALSE, FALSE); - return; - } - dict_stats_save_defrag_stats(index); dict_table_close(table, FALSE, FALSE); } diff --git a/storage/xtradb/dict/dict0stats_bg.cc b/storage/xtradb/dict/dict0stats_bg.cc index ba6fd115551..e2e7ad827b6 100644 --- a/storage/xtradb/dict/dict0stats_bg.cc +++ b/storage/xtradb/dict/dict0stats_bg.cc @@ -479,7 +479,6 @@ stats and eventually save its stats. */ static void dict_stats_process_entry_from_defrag_pool() -/*=======================================*/ { table_id_t table_id; index_id_t index_id; @@ -501,31 +500,18 @@ dict_stats_process_entry_from_defrag_pool() table = dict_table_open_on_id(table_id, TRUE, DICT_TABLE_OP_OPEN_ONLY_IF_CACHED); - if (table == NULL) { + dict_index_t* index = table && !table->corrupted + ? dict_table_find_index_on_id(table, index_id) + : NULL; + + if (!index || dict_index_is_corrupted(index)) { + if (table) { + dict_table_close(table, TRUE, FALSE); + } mutex_exit(&dict_sys->mutex); return; } - /* Check whether table is corrupted */ - if (table->corrupted) { - dict_table_close(table, TRUE, FALSE); - mutex_exit(&dict_sys->mutex); - return; - } - mutex_exit(&dict_sys->mutex); - - dict_index_t* index = dict_table_find_index_on_id(table, index_id); - - if (index == NULL) { - return; - } - - /* Check whether index is corrupted */ - if (dict_index_is_corrupted(index)) { - dict_table_close(table, FALSE, FALSE); - return; - } - dict_stats_save_defrag_stats(index); dict_table_close(table, FALSE, FALSE); }