WL#3949, second part. Added soft switching of the binlog format (w/o restart a server)

parent d7f570c0
...@@ -367,6 +367,7 @@ sub collect_one_suite($$) ...@@ -367,6 +367,7 @@ sub collect_one_suite($$)
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if ($combinations && $begin_index <= $#{@$cases}) if ($combinations && $begin_index <= $#{@$cases})
{ {
my $prepared = {};
my $end_index = $#{@$cases}; my $end_index = $#{@$cases};
my $is_copy; my $is_copy;
# Keep original master/slave options # Keep original master/slave options
...@@ -397,7 +398,7 @@ sub collect_one_suite($$) ...@@ -397,7 +398,7 @@ sub collect_one_suite($$)
@$new_arr = @{$orig_opts[$idx]{$param}}; @$new_arr = @{$orig_opts[$idx]{$param}};
$copied_test->{$param} = $new_arr; $copied_test->{$param} = $new_arr;
} }
elsif ($param =~ /(comment|combinations)/) elsif ($param =~ /combinations/)
{ {
$copied_test->{$param} = ''; $copied_test->{$param} = '';
} }
...@@ -415,18 +416,29 @@ sub collect_one_suite($$) ...@@ -415,18 +416,29 @@ sub collect_one_suite($$)
if ($comb_opt =~ /^--binlog-format=.+$/) if ($comb_opt =~ /^--binlog-format=.+$/)
{ {
my @opt_pairs = split(/=/, $comb_opt); my @opt_pairs = split(/=/, $comb_opt);
if ($test->{'binlog_format'} =~ /^$opt_pairs[1]$/ || $test->{'binlog_format'} eq '') if (defined $::used_binlog_format)
{ {
$test->{'skip'} = 0; if ($test->{'binlog_format'} ne $::used_binlog_format)
$test->{'comment'} = ''; {
$test->{'skip'} = 1;
$test->{'comment'} = "Requiring binlog format ".join(' or ', @{$test->{'sup_binlog_formats'}});
}
} }
else else
{ {
$test->{'skip'} = 1; foreach my $binlog_format (@{$test->{'sup_binlog_formats'}})
$test->{'comment'} = "Requiring binlog format '$test->{'binlog_format'}'";; {
} $test->{'binlog_format'}= $binlog_format if ($binlog_format eq $opt_pairs[1]);
}
if (defined $prepared->{$test->{'name'}.'|'.$test->{'binlog_format'}} and $test->{'skip'} ne 1 )
{
$test->{'skip'} = 1;
$test->{'comment'} = "Test for binlog format '$test->{'binlog_format'}' already executed";
}
}
} }
} }
$prepared->{$test->{'name'}.'|'.$test->{'binlog_format'}}= 1;
$test->{'combination'} = $comb_set; $test->{'combination'} = $comb_set;
} }
$is_copy = 1; $is_copy = 1;
...@@ -524,6 +536,7 @@ sub collect_one_test_case($$$$$$$$$) { ...@@ -524,6 +536,7 @@ sub collect_one_test_case($$$$$$$$$) {
$tinfo->{'slave_opt'}= []; $tinfo->{'slave_opt'}= [];
$tinfo->{'slave_mi'}= []; $tinfo->{'slave_mi'}= [];
# Add suite opts # Add suite opts
foreach my $opt ( @$suite_opts ) foreach my $opt ( @$suite_opts )
{ {
...@@ -737,14 +750,43 @@ sub collect_one_test_case($$$$$$$$$) { ...@@ -737,14 +750,43 @@ sub collect_one_test_case($$$$$$$$$) {
return; return;
} }
if ( defined $tinfo->{'binlog_format'} and # Replication test needs an adjustment of binlog format
! ( $tinfo->{'binlog_format'} eq $::used_binlog_format ) ) if ($tinfo->{'name'} =~ /^rpl/)
{ {
$tinfo->{'skip'}= 1; # Set default binlog format priority
$tinfo->{'comment'}= "Requiring binlog format '$tinfo->{'binlog_format'}'"; if ($tinfo->{'name'} =~ /^rpl/ and !defined $tinfo->{'sup_binlog_formats'})
return; {
if ($::mysql_version_id >= 50100)
{
$tinfo->{'sup_binlog_formats'} = ["mixed", "row", "statement"];
}
else
{
$tinfo->{'sup_binlog_formats'} = ["statement", "row"];
}
}
# Check that a test supports binlog format defined via --binlog-format
if (defined $::used_binlog_format)
{
# Try to find a supported binlog formats
foreach my $binlog_format (@{$tinfo->{'sup_binlog_formats'}})
{
$tinfo->{'binlog_format'}= $binlog_format unless ($binlog_format ne $::used_binlog_format);
}
# Skip a test because
if (!defined $tinfo->{'binlog_format'})
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Requiring binlog format ".join(' or ', @{$tinfo->{'sup_binlog_formats'}});
return;
}
}
else
{
$tinfo->{'binlog_format'}= $tinfo->{'sup_binlog_formats'}->[0];
}
} }
if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries ) if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries )
{ {
$tinfo->{'skip'}= 1; $tinfo->{'skip'}= 1;
...@@ -824,10 +866,13 @@ sub collect_one_test_case($$$$$$$$$) { ...@@ -824,10 +866,13 @@ sub collect_one_test_case($$$$$$$$$) {
our @tags= our @tags=
( (
["include/have_innodb.inc", "innodb_test", 1], ["include/have_innodb.inc", "innodb_test", 1],
["include/have_binlog_format_row.inc", "binlog_format", "row"], ["include/have_binlog_format_row.inc", "sup_binlog_formats", ["row"]],
["include/have_log_bin.inc", "need_binlog", 1], ["include/have_log_bin.inc", "need_binlog", 1],
["include/have_binlog_format_statement.inc", "binlog_format", "statement"], ["include/have_binlog_format_statement.inc", "sup_binlog_formats", ["statement"]],
["include/have_binlog_format_mixed.inc", "binlog_format", "mixed"], ["include/have_binlog_format_mixed.inc", "sup_binlog_formats", ["mixed"]],
["include/have_binlog_format_mixed_or_row.inc", "sup_binlog_formats", ["mixed","row"]],
["include/have_binlog_format_mixed_or_statement.inc", "sup_binlog_formats", ["mixed","statement"]],
["include/have_binlog_format_row_or_statement.inc", "sup_binlog_formats", ["row","statement"]],
["include/big_test.inc", "big_test", 1], ["include/big_test.inc", "big_test", 1],
["include/have_debug.inc", "need_debug", 1], ["include/have_debug.inc", "need_debug", 1],
["include/have_ndb.inc", "ndb_test", 1], ["include/have_ndb.inc", "ndb_test", 1],
...@@ -853,8 +898,8 @@ sub mtr_options_from_test_file($$) { ...@@ -853,8 +898,8 @@ sub mtr_options_from_test_file($$) {
{ {
if ( index($line, $tag->[0]) >= 0 ) if ( index($line, $tag->[0]) >= 0 )
{ {
# Tag matched, assign value to "tinfo" # Tag matched, assign value to "tinfo"
$tinfo->{"$tag->[1]"}= $tag->[2]; $tinfo->{"$tag->[1]"}= $tag->[2];
} }
} }
......
...@@ -280,4 +280,33 @@ sub mtr_cmp_opts ($$) { ...@@ -280,4 +280,33 @@ sub mtr_cmp_opts ($$) {
return 0; # They are the same return 0; # They are the same
} }
#
# Compare two arrays and put all unequal elements into a new one
#
sub mtr_diff_opts ($$) {
my $l1= shift;
my $l2= shift;
my $f;
my $l= [];
foreach my $e1 (@$l1)
{
$f= undef;
foreach my $e2 (@$l2)
{
$f= 1 unless ($e1 ne $e2);
}
push(@$l, $e1) unless (defined $f);
}
foreach my $e2 (@$l2)
{
$f= undef;
foreach my $e1 (@$l1)
{
$f= 1 unless ($e1 ne $e2);
}
push(@$l, $e2) unless (defined $f);
}
return $l;
}
1; 1;
...@@ -792,20 +792,23 @@ sub command_line_setup () { ...@@ -792,20 +792,23 @@ sub command_line_setup () {
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Find out type of logging that are being used # Find out type of logging that are being used
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# NOTE if the default binlog format is changed, this has to be changed
$used_binlog_format= "statement";
if (!$opt_extern && $mysql_version_id >= 50100 ) if (!$opt_extern && $mysql_version_id >= 50100 )
{ {
$used_binlog_format= "mixed"; # Default value for binlog format
foreach my $arg ( @opt_extra_mysqld_opt ) foreach my $arg ( @opt_extra_mysqld_opt )
{ {
if ( $arg =~ /binlog[-_]format=(\S+)/ ) if ( $arg =~ /binlog[-_]format=(\S+)/ )
{ {
$used_binlog_format= $1; $used_binlog_format= $1;
} }
} }
mtr_report("Using binlog format '$used_binlog_format'"); if (defined $used_binlog_format)
{
mtr_report("Using binlog format '$used_binlog_format'");
}
else
{
mtr_report("Using dynamic switching of binlog format");
}
} }
...@@ -3304,6 +3307,7 @@ sub run_testcase_check_skip_test($) ...@@ -3304,6 +3307,7 @@ sub run_testcase_check_skip_test($)
sub do_before_run_mysqltest($) sub do_before_run_mysqltest($)
{ {
my $tinfo= shift; my $tinfo= shift;
my $args;
# Remove old files produced by mysqltest # Remove old files produced by mysqltest
my $base_file= mtr_match_extension($tinfo->{'result_file'}, my $base_file= mtr_match_extension($tinfo->{'result_file'},
...@@ -3324,6 +3328,26 @@ sub do_before_run_mysqltest($) ...@@ -3324,6 +3328,26 @@ sub do_before_run_mysqltest($)
# if script decided to run mysqltest cluster _is_ installed ok # if script decided to run mysqltest cluster _is_ installed ok
$ENV{'NDB_STATUS_OK'} = "YES"; $ENV{'NDB_STATUS_OK'} = "YES";
} }
if (defined $tinfo->{"binlog_format"} and $mysql_version_id > 50100 )
{
foreach my $server ((@$master,@$slave))
{
if ($server->{'pid'})
{
mtr_init_args(\$args);
mtr_add_arg($args, "--no-defaults");
mtr_add_arg($args, "--user=root");
mtr_add_arg($args, "--port=$server->{'port'}");
mtr_add_arg($args, "--socket=$server->{'path_sock'}");
mtr_run($exe_mysql, $args, "$glob_mysql_test_dir/include/set_binlog_format_".$tinfo->{"binlog_format"}.".inc", "", "", "", {});
}
}
}
} }
} }
...@@ -4218,10 +4242,19 @@ sub run_testcase_need_master_restart($) ...@@ -4218,10 +4242,19 @@ sub run_testcase_need_master_restart($)
elsif (! mtr_same_opts($master->[0]->{'start_opts'}, elsif (! mtr_same_opts($master->[0]->{'start_opts'},
$tinfo->{'master_opt'}) ) $tinfo->{'master_opt'}) )
{ {
$do_restart= 1; # Chech that diff is binlog format only
mtr_verbose("Restart master: running with different options '" . my $diff_opts= mtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
join(" ", @{$tinfo->{'master_opt'}}) . "' != '" . if (scalar(@$diff_opts) eq 2)
join(" ", @{$master->[0]->{'start_opts'}}) . "'" ); {
$do_restart= 1 unless ($diff_opts->[0] =~/^--binlog-format=/ and $diff_opts->[1] =~/^--binlog-format=/);
}
else
{
$do_restart= 1;
mtr_verbose("Restart master: running with different options '" .
join(" ", @{$tinfo->{'master_opt'}}) . "' != '" .
join(" ", @{$master->[0]->{'start_opts'}}) . "'" );
}
} }
elsif( ! $master->[0]->{'pid'} ) elsif( ! $master->[0]->{'pid'} )
{ {
......
set autocommit=1;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; insert into bug16206 values(2)
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb
f n Query 1 n use `test`; insert into bug16206 values(0)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; BEGIN
f n Query 1 n use `test`; insert into bug16206 values(2)
f n Query 1 n use `test`; COMMIT
f n Query 1 n use `test`; insert into bug16206 values(3)
drop table bug16206;
set autocommit=0;
End of 5.0 tests
...@@ -116,23 +116,23 @@ t12 ...@@ -116,23 +116,23 @@ t12
t13 t13
t2 t2
t3 t3
SELECT table_name FROM information_schema.views WHERE table_schema='test'; SELECT table_name FROM information_schema.views WHERE table_schema='test' ORDER BY table_name;
table_name table_name
v1 v1
v11 v11
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test'; SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test' ORDER BY trigger_name;
trigger_name event_manipulation event_object_table trigger_name event_manipulation event_object_table
t1_tr1 INSERT t1
t1_tr2 UPDATE t1
t11_tr1 INSERT t11 t11_tr1 INSERT t11
t11_tr2 UPDATE t11 t11_tr2 UPDATE t11
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test'; t1_tr1 INSERT t1
t1_tr2 UPDATE t1
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test' ORDER BY routine_name;
routine_type routine_name routine_type routine_name
FUNCTION f1 FUNCTION f1
FUNCTION f2 FUNCTION f2
PROCEDURE p1 PROCEDURE p1
PROCEDURE p11 PROCEDURE p11
SELECT event_name, status FROM information_schema.events WHERE event_schema='test'; SELECT event_name, status FROM information_schema.events WHERE event_schema='test' ORDER BY event_name;
event_name status event_name status
e1 DISABLED e1 DISABLED
e11 DISABLED e11 DISABLED
...@@ -276,23 +276,23 @@ t12 ...@@ -276,23 +276,23 @@ t12
t13 t13
t2 t2
t3 t3
SELECT table_name FROM information_schema.views WHERE table_schema='test'; SELECT table_name FROM information_schema.views WHERE table_schema='test' ORDER BY table_name;
table_name table_name
v1 v1
v11 v11
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test'; SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test' ORDER BY trigger_name;
trigger_name event_manipulation event_object_table trigger_name event_manipulation event_object_table
t1_tr1 INSERT t1
t1_tr2 UPDATE t1
t11_tr1 INSERT t11 t11_tr1 INSERT t11
t11_tr2 UPDATE t11 t11_tr2 UPDATE t11
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test'; t1_tr1 INSERT t1
t1_tr2 UPDATE t1
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test' ORDER BY routine_name;
routine_type routine_name routine_type routine_name
FUNCTION f1 FUNCTION f1
FUNCTION f2 FUNCTION f2
PROCEDURE p1 PROCEDURE p1
PROCEDURE p11 PROCEDURE p11
SELECT event_name, status FROM information_schema.events WHERE event_schema='test'; SELECT event_name, status FROM information_schema.events WHERE event_schema='test' ORDER BY event_name;
event_name status event_name status
e1 SLAVESIDE_DISABLED e1 SLAVESIDE_DISABLED
e11 SLAVESIDE_DISABLED e11 SLAVESIDE_DISABLED
......
...@@ -202,10 +202,10 @@ SET GLOBAL EVENT_SCHEDULER = off; ...@@ -202,10 +202,10 @@ SET GLOBAL EVENT_SCHEDULER = off;
# Check original objects # Check original objects
--echo --echo
SHOW TABLES LIKE 't%'; SHOW TABLES LIKE 't%';
SELECT table_name FROM information_schema.views WHERE table_schema='test'; SELECT table_name FROM information_schema.views WHERE table_schema='test' ORDER BY table_name;
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test'; SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test' ORDER BY trigger_name;
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test'; SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test' ORDER BY routine_name;
SELECT event_name, status FROM information_schema.events WHERE event_schema='test'; SELECT event_name, status FROM information_schema.events WHERE event_schema='test' ORDER BY event_name;
# Check original data # Check original data
--echo --echo
...@@ -229,10 +229,10 @@ SELECT a,b FROM v11 ORDER BY a; ...@@ -229,10 +229,10 @@ SELECT a,b FROM v11 ORDER BY a;
# Check replicated objects # Check replicated objects
--echo --echo
SHOW TABLES LIKE 't%'; SHOW TABLES LIKE 't%';
SELECT table_name FROM information_schema.views WHERE table_schema='test'; SELECT table_name FROM information_schema.views WHERE table_schema='test' ORDER BY table_name;
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test'; SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test' ORDER BY trigger_name;
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test'; SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test' ORDER BY routine_name;
SELECT event_name, status FROM information_schema.events WHERE event_schema='test'; SELECT event_name, status FROM information_schema.events WHERE event_schema='test' ORDER BY event_name;
# Check replicated data # Check replicated data
--echo --echo
......
...@@ -109,6 +109,7 @@ DROP TABLE t1, t1_slave; ...@@ -109,6 +109,7 @@ DROP TABLE t1, t1_slave;
DROP PROCEDURE test_replication_sp1; DROP PROCEDURE test_replication_sp1;
DROP PROCEDURE test_replication_sp2; DROP PROCEDURE test_replication_sp2;
DROP FUNCTION test_replication_sf; DROP FUNCTION test_replication_sf;
--remove_file $MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile
--sync_slave_with_master --sync_slave_with_master
...@@ -51,8 +51,9 @@ CREATE TABLE t1 ( ...@@ -51,8 +51,9 @@ CREATE TABLE t1 (
`data` varchar(100), `data` varchar(100),
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=MyISAM; ) ENGINE=MyISAM;
--disable_warnings
INSERT INTO t1(data) VALUES(SESSION_USER()); INSERT INTO t1(data) VALUES(SESSION_USER());
--enable_warnings
save_master_pos; save_master_pos;
connection slave; connection slave;
sync_with_master; sync_with_master;
......
-- source include/not_embedded.inc
-- source include/have_bdb.inc
#
# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode
#
set autocommit=1;
let $VERSION=`select version()`;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
set autocommit=0;
--echo End of 5.0 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