From d8dee8cb32a8acc23a95f5288b30f7c488815fa1 Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Sun, 18 Oct 2009 20:29:03 +0800 Subject: [PATCH 1/6] Postfix of bug#45674 rpl_semi_sync_master_wait_sessions was reset by FLUSH STATUS, which could cause the master fail to wake up waiting sessions and result in master timeout waiting for slave reply. rpl_semi_sync_master_wait_session should not be reset, this problem is fixed by this patch. plugin/semisync/semisync_master_plugin.cc: Change wait_sessions from SHOW_LONG back to SHOW_FUNC so that it will not be reset by FLUSH STATUS. --- plugin/semisync/semisync_master_plugin.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/semisync/semisync_master_plugin.cc b/plugin/semisync/semisync_master_plugin.cc index d2ef500d932..efcb7172b28 100644 --- a/plugin/semisync/semisync_master_plugin.cc +++ b/plugin/semisync/semisync_master_plugin.cc @@ -278,6 +278,7 @@ Binlog_transmit_observer transmit_observer = { DEF_SHOW_FUNC(status, SHOW_BOOL) DEF_SHOW_FUNC(clients, SHOW_LONG) +DEF_SHOW_FUNC(wait_sessions, SHOW_LONG) DEF_SHOW_FUNC(trx_wait_time, SHOW_LONGLONG) DEF_SHOW_FUNC(trx_wait_num, SHOW_LONGLONG) DEF_SHOW_FUNC(net_wait_time, SHOW_LONGLONG) @@ -301,8 +302,8 @@ static SHOW_VAR semi_sync_master_status_vars[]= { (char*) &rpl_semi_sync_master_no_transactions, SHOW_LONG}, {"Rpl_semi_sync_master_wait_sessions", - (char*) &rpl_semi_sync_master_wait_sessions, - SHOW_LONG}, + (char*) &SHOW_FNAME(wait_sessions), + SHOW_FUNC}, {"Rpl_semi_sync_master_no_times", (char*) &rpl_semi_sync_master_off_times, SHOW_LONG}, From 36fd029eff9526e0f09f6cb081cb84cfd5dd3773 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Oct 2009 14:30:15 +0800 Subject: [PATCH 2/6] Bug#13963 SHOW SLAVE HOSTS is unreliable Before the patch, slaves only appear in the output of SHOW SLAVE HOSTS when report-host option is set. If an expected slave does not appear in the list, nobody knows whether the slave does not connect or has started without the "report-host" option. The output also contains a strange field "Rpl_recovery_rank" which has never been implemented and the manual of MySQL5.4 declares that the field has been removed from MySQL5.4. This patch is done with these, According to the manual of MySQL5.4, "Rpl_recovery_rank" is removed. Slaves will register themselves to master no matter if report_host option is set or not. When slaves are registering themselves, their Server_ids, report_host and other information are together sent to master. Sever_ids are never null and is unique in one replication group. Slaves always can be identified with different Server_ids no matter if report_host exists. --- mysql-test/include/wait_show_condition.inc | 74 +++++++++++++------ .../suite/rpl/r/rpl_mixed_ddl_dml.result | 4 +- .../suite/rpl/r/rpl_show_slave_hosts.result | 17 +++++ .../suite/rpl/t/rpl_show_slave_hosts.cnf | 20 +++++ .../suite/rpl/t/rpl_show_slave_hosts.test | 44 +++++++++++ sql/repl_failsafe.cc | 8 +- sql/slave.cc | 36 +++++++-- 7 files changed, 166 insertions(+), 37 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_show_slave_hosts.result create mode 100644 mysql-test/suite/rpl/t/rpl_show_slave_hosts.cnf create mode 100644 mysql-test/suite/rpl/t/rpl_show_slave_hosts.test diff --git a/mysql-test/include/wait_show_condition.inc b/mysql-test/include/wait_show_condition.inc index 253101d1e07..f683ca7b47b 100644 --- a/mysql-test/include/wait_show_condition.inc +++ b/mysql-test/include/wait_show_condition.inc @@ -2,13 +2,16 @@ # # SUMMARY # -# Waits until the show statement ($show_statement) has at least within one of -# the rows of the result set for the field ($field) a value which fulfils +# Waits until the show statement ($show_statement) has one or all of the +# rows of the result set for the field ($field) a value which fulfils # a condition ($condition), or the operation times out. # # # USAGE # +# All rows of the result must fulfil the condition if $all_rows_fulfil is 1 +# else at least one of the result must fulfil the condition. +# let $wait_for_all= 1; # let $show_statement= SHOW PROCESSLIST; # let $field= State; # let $condition= = 'Updating'; @@ -46,27 +49,56 @@ inc $max_run_time; let $found= 0; let $max_end_time= `SELECT UNIX_TIMESTAMP() + $max_run_time`; -while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`) + +if (`SELECT '$wait_for_all' != '1'`) { - # Sleep a bit to avoid too heavy load. - real_sleep 0.2; - let $rowno= 1; - let $process_result= 1; - while (`SELECT $process_result = 1 AND $found = 0`) - { - let $field_value= query_get_value($show_statement, $field, $rowno); - if (`SELECT '$field_value' $condition`) - { - let $found= 1; - } - if (`SELECT '$field_value' = 'No such row'`) - { - # We are behind the last row of the result set. - let $process_result= 0; - } - inc $rowno; - } + while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`) + { + # Sleep a bit to avoid too heavy load. + real_sleep 0.2; + let $rowno= 1; + let $process_result= 1; + while (`SELECT $process_result = 1 AND $found = 0`) + { + let $field_value= query_get_value($show_statement, $field, $rowno); + if (`SELECT '$field_value' $condition`) + { + let $found= 1; + } + if (`SELECT '$field_value' = 'No such row'`) + { + # We are behind the last row of the result set. + let $process_result= 0; + } + inc $rowno; + } + } } + +if (`SELECT '$wait_for_all' = '1'`) +{ + while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`) + { + # Sleep a bit to avoid too heavy load. + real_sleep 0.2; + let $rowno= 1; + let $process_result= 1; + while (`SELECT $process_result = 1 AND $found = 0`) + { + let $field_value= query_get_value($show_statement, $field, $rowno); + if (`SELECT '$field_value' = 'No such row'`) + { + let $found= 1; + } + if (`SELECT $found = 0 AND NOT '$field_value' $condition`) + { + let process_result= 0; + } + inc $rowno; + } + } +} + if (!$found) { echo # Timeout in include/wait_show_condition.inc for $wait_condition; diff --git a/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result b/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result index 08d3241c48f..a353ee73d3f 100644 --- a/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result +++ b/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result @@ -13,8 +13,8 @@ n 2001 2002 show slave hosts; -Server_id Host Port Rpl_recovery_rank Master_id -2 127.0.0.1 9999 0 1 +Server_id Host Port Master_id +2 127.0.0.1 9999 1 drop table t1; stop slave; create table t2(id int auto_increment primary key, created datetime); diff --git a/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result b/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result new file mode 100644 index 00000000000..c9cefc4625b --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result @@ -0,0 +1,17 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +RESET SLAVE; +CHANGE MASTER TO master_host='127.0.0.1',master_port=13000,master_user='root'; +START SLAVE IO_THREAD; +SHOW SLAVE HOSTS; +Server_id Host Port Master_id +3 slave2 3306 1 +2 13001 1 +STOP SLAVE IO_THREAD; +SHOW SLAVE HOSTS; +Server_id Host Port Master_id +2 13001 1 diff --git a/mysql-test/suite/rpl/t/rpl_show_slave_hosts.cnf b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.cnf new file mode 100644 index 00000000000..288f0132fba --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.cnf @@ -0,0 +1,20 @@ +!include ../my.cnf + +[mysqld.1] +server_id=1 + +[mysqld.2] +server_id=2 +report-host= +report-user= + +[mysqld.3] +server_id=3 +report-host=slave2 +slave-net-timeout=5 + +[ENV] +SLAVE_MYPORT2= @mysqld.3.port +SLAVE_MYSOCK2= @mysqld.3.socket + + diff --git a/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test new file mode 100644 index 00000000000..19ec680cbd1 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test @@ -0,0 +1,44 @@ +############################################################################### +# Bug#13963 SHOW SLAVE HOSTS is unreliable +# +# Slaves only appear in the output of SHOW SLAVE HOSTS when report-host option +# is set. If an expected slave does not appear in the list, nobody knows +# whether the slave does not connect or has started without the "report-host" +# option. +# +# Remove the "Rpl_recovery_rank" column from SHOW SLAVE HOSTS, It is not +# implemented. +####################################################################### +source include/master-slave.inc; +connect (slave2,127.0.0.1,root,,test,$SLAVE_MYPORT2,); + +connection slave2; +RESET SLAVE; +--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root' +START SLAVE IO_THREAD; +source include/wait_for_slave_io_to_start.inc; + +connection master; +let $show_statement= SHOW SLAVE HOSTS; +let $field= Server_id; +# 3 is server_id of slave2. +let $connection= ='3'; +source include/wait_show_condition.inc; +SHOW SLAVE HOSTS; + +connection slave2; +STOP SLAVE IO_THREAD; +source include/wait_for_slave_io_to_stop.inc; + +connection master; +let $show_statement= SHOW SLAVE HOSTS; +let $field= Server_id; +# 3 is server_id of slave2. +let $condition= <> '3'; +# All rows of 'SHOW SLAVE HOSTS' are not equal to 3. It mean that master has +# knew the leave of slave2 and has unregistered it. +let $wait_for_all= 1; +source include/wait_show_condition.inc; +SHOW SLAVE HOSTS; + +source include/master-slave-end.inc; diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 582348608de..3d375f906ec 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -183,12 +183,11 @@ int register_slave(THD* thd, uchar* packet, uint packet_length) get_object(p,si->host, "Failed to register slave: too long 'report-host'"); get_object(p,si->user, "Failed to register slave: too long 'report-user'"); get_object(p,si->password, "Failed to register slave; too long 'report-password'"); - if (p+10 > p_end) + /*6 is the total length of port and master_id*/ + if (p+6 != p_end) goto err; si->port= uint2korr(p); p += 2; - si->rpl_recovery_rank= uint4korr(p); - p += 4; if (!(si->master_id= uint4korr(p))) si->master_id= server_id; si->thd= thd; @@ -669,8 +668,6 @@ bool show_slave_hosts(THD* thd) field_list.push_back(new Item_empty_string("Password",20)); } field_list.push_back(new Item_return_int("Port", 7, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Rpl_recovery_rank", 7, - MYSQL_TYPE_LONG)); field_list.push_back(new Item_return_int("Master_id", 10, MYSQL_TYPE_LONG)); @@ -692,7 +689,6 @@ bool show_slave_hosts(THD* thd) protocol->store(si->password, &my_charset_bin); } protocol->store((uint32) si->port); - protocol->store((uint32) si->rpl_recovery_rank); protocol->store((uint32) si->master_id); if (protocol->write()) { diff --git a/sql/slave.cc b/sql/slave.cc index 834ed8ed933..36111ef2bc9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1745,28 +1745,48 @@ int register_slave_on_master(MYSQL* mysql, Master_info *mi, bool *suppress_warnings) { uchar buf[1024], *pos= buf; - uint report_host_len, report_user_len=0, report_password_len=0; + uint report_host_len=0, report_user_len=0, report_password_len=0; DBUG_ENTER("register_slave_on_master"); *suppress_warnings= FALSE; - if (!report_host) + if (report_host) + report_host_len= strlen(report_host); + if (report_host_len > HOSTNAME_LENGTH) + { + sql_print_warning("The length of report_host is %d. " + "It is larger than the max length(%d), so this " + "slave cannot be registered to the master.", + report_host_len, HOSTNAME_LENGTH); DBUG_RETURN(0); - report_host_len= strlen(report_host); + } + if (report_user) report_user_len= strlen(report_user); + if (report_user_len > USERNAME_LENGTH) + { + sql_print_warning("The length of report_user is %d. " + "It is larger than the max length(%d), so this " + "slave cannot be registered to the master.", + report_user_len, USERNAME_LENGTH); + DBUG_RETURN(0); + } + if (report_password) report_password_len= strlen(report_password); - /* 30 is a good safety margin */ - if (report_host_len + report_user_len + report_password_len + 30 > - sizeof(buf)) - DBUG_RETURN(0); // safety + if (report_password_len > MAX_PASSWORD_LENGTH) + { + sql_print_warning("The length of report_password is %d. " + "It is larger than the max length(%d), so this " + "slave cannot be registered to the master.", + report_password_len, MAX_PASSWORD_LENGTH); + DBUG_RETURN(0); + } int4store(pos, server_id); pos+= 4; pos= net_store_data(pos, (uchar*) report_host, report_host_len); pos= net_store_data(pos, (uchar*) report_user, report_user_len); pos= net_store_data(pos, (uchar*) report_password, report_password_len); int2store(pos, (uint16) report_port); pos+= 2; - int4store(pos, rpl_recovery_rank); pos+= 4; /* The master will fill in master_id */ int4store(pos, 0); pos+= 4; From 871bc4bd64efc4d94280cfab91525d54710869e5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Oct 2009 10:19:50 +0800 Subject: [PATCH 3/6] BUG #13963 Postfix --- mysql-test/suite/rpl/r/rpl_show_slave_hosts.result | 8 ++++---- mysql-test/suite/rpl/t/rpl_show_slave_hosts.test | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result b/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result index c9cefc4625b..9838d8b08a8 100644 --- a/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result +++ b/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result @@ -5,13 +5,13 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; RESET SLAVE; -CHANGE MASTER TO master_host='127.0.0.1',master_port=13000,master_user='root'; +CHANGE MASTER TO master_host='127.0.0.1',master_port=MASTER_PORT,master_user='root'; START SLAVE IO_THREAD; SHOW SLAVE HOSTS; Server_id Host Port Master_id -3 slave2 3306 1 -2 13001 1 +3 slave2 DEFAULT_PORT 1 +2 SLAVE_PORT 1 STOP SLAVE IO_THREAD; SHOW SLAVE HOSTS; Server_id Host Port Master_id -2 13001 1 +2 SLAVE_PORT 1 diff --git a/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test index 19ec680cbd1..9f202487968 100644 --- a/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test +++ b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test @@ -14,6 +14,7 @@ connect (slave2,127.0.0.1,root,,test,$SLAVE_MYPORT2,); connection slave2; RESET SLAVE; +--replace_result $MASTER_MYPORT MASTER_PORT --eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root' START SLAVE IO_THREAD; source include/wait_for_slave_io_to_start.inc; @@ -24,6 +25,7 @@ let $field= Server_id; # 3 is server_id of slave2. let $connection= ='3'; source include/wait_show_condition.inc; +--replace_result $SLAVE_MYPORT SLAVE_PORT $DEFAULT_MASTER_PORT DEFAULT_PORT SHOW SLAVE HOSTS; connection slave2; @@ -39,6 +41,7 @@ let $condition= <> '3'; # knew the leave of slave2 and has unregistered it. let $wait_for_all= 1; source include/wait_show_condition.inc; +--replace_result $SLAVE_MYPORT SLAVE_PORT SHOW SLAVE HOSTS; source include/master-slave-end.inc; From e9acb9f0212f31e9fc5e8a09ee2932f37faed13a Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Fri, 23 Oct 2009 12:56:30 +0800 Subject: [PATCH 4/6] Add semi-sync support for Windows CMakeLists.txt: Add plugin/semisync subdirectory mysql-test/mysql-test-run.pl: Check for semisync dll for Windows mysql-test/suite/rpl/r/rpl_semi_sync.result: Update result file mysql-test/suite/rpl/t/rpl_semi_sync.test: Test semi-sync on Windows plugin/semisync/semisync_master.cc: Define gettimeofday for Windows --- CMakeLists.txt | 4 ++ mysql-test/mysql-test-run.pl | 52 +++++++++++++-------- mysql-test/suite/rpl/r/rpl_semi_sync.result | 4 +- mysql-test/suite/rpl/t/rpl_semi_sync.test | 11 +++-- plugin/semisync/Makefile.am | 2 + plugin/semisync/semisync_master.cc | 18 +++++++ 6 files changed, 65 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d91e39eb6d..e7d05f33ffa 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,6 +276,10 @@ FOREACH(DIR ${DYNAMIC_ENGINE_DIRECTORIES}) ADD_SUBDIRECTORY(${DIR}) ENDFOREACH(DIR ${DYNAMIC_ENGINE_DIRECTORIES}) +# Add subdirectories for semisync plugin +IF(NOT WITHOUT_DYNAMIC_PLUGINS) + ADD_SUBDIRECTORY(plugin/semisync) +ENDIF(NOT WITHOUT_DYNAMIC_PLUGINS) # FIXME "debug" only needed if build type is "Debug", but # CMAKE_BUILD_TYPE is not set during configure time. diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 1c14104957d..6f3822cfd85 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1818,25 +1818,39 @@ sub environment_setup { # -------------------------------------------------------------------------- # Add the path where mysqld will find semisync plugins # -------------------------------------------------------------------------- - my $lib_semisync_master_plugin= - mtr_file_exists(vs_config_dirs('plugin/semisync',"libsemisync_master.so"), - "$basedir/plugin/semisync/.libs/libsemisync_master.so", - "$basedir/lib/mysql/plugin/libsemisync_master.so"); - my $lib_semisync_slave_plugin= - mtr_file_exists(vs_config_dirs('plugin/semisync',"libsemisync_slave.so"), - "$basedir/plugin/semisync/.libs/libsemisync_slave.so", - "$basedir/lib/mysql/plugin/libsemisync_slave.so"); - if ($lib_semisync_master_plugin && $lib_semisync_slave_plugin) - { - $ENV{'SEMISYNC_MASTER_PLUGIN'}= basename($lib_semisync_master_plugin); - $ENV{'SEMISYNC_SLAVE_PLUGIN'}= basename($lib_semisync_slave_plugin); - $ENV{'SEMISYNC_PLUGIN_OPT'}= "--plugin-dir=".dirname($lib_semisync_master_plugin); - } - else - { - $ENV{'SEMISYNC_MASTER_PLUGIN'}= ""; - $ENV{'SEMISYNC_SLAVE_PLUGIN'}= ""; - $ENV{'SEMISYNC_PLUGIN_OPT'}="--plugin-dir="; + if (!$opt_embedded_server) { + my $semisync_master_filename; + my $semisync_slave_filename; + if (IS_WINDOWS) + { + $semisync_master_filename = "semisync_master.dll"; + $semisync_slave_filename = "semisync_slave.dll"; + } + else + { + $semisync_master_filename = "libsemisync_master.so"; + $semisync_slave_filename = "libsemisync_slave.so"; + } + my $lib_semisync_master_plugin= + mtr_file_exists(vs_config_dirs('plugin/semisync',$semisync_master_filename), + "$basedir/plugin/semisync/.libs/" . $semisync_master_filename, + "$basedir/lib/mysql/plugin/" . $semisync_master_filename); + my $lib_semisync_slave_plugin= + mtr_file_exists(vs_config_dirs('plugin/semisync',$semisync_slave_filename), + "$basedir/plugin/semisync/.libs/" . $semisync_slave_filename, + "$basedir/lib/mysql/plugin/" . $semisync_slave_filename); + if ($lib_semisync_master_plugin && $lib_semisync_slave_plugin) + { + $ENV{'SEMISYNC_MASTER_PLUGIN'}= basename($lib_semisync_master_plugin); + $ENV{'SEMISYNC_SLAVE_PLUGIN'}= basename($lib_semisync_slave_plugin); + $ENV{'SEMISYNC_PLUGIN_OPT'}= "--plugin-dir=".dirname($lib_semisync_master_plugin); + } + else + { + $ENV{'SEMISYNC_MASTER_PLUGIN'}= ""; + $ENV{'SEMISYNC_SLAVE_PLUGIN'}= ""; + $ENV{'SEMISYNC_PLUGIN_OPT'}="--plugin-dir="; + } } # ---------------------------------------------------- diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync.result b/mysql-test/suite/rpl/r/rpl_semi_sync.result index 607b77fbd04..1e220b28d78 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync.result @@ -397,7 +397,7 @@ Rpl_semi_sync_slave_status OFF # Test non-semi-sync slave connect to semi-sync master # set sql_log_bin=0; -INSTALL PLUGIN rpl_semi_sync_master SONAME 'libsemisync_master.so'; +INSTALL PLUGIN rpl_semi_sync_master SONAME 'SEMISYNC_MASTER_PLUGIN'; set global rpl_semi_sync_master_timeout= 5000; /* 5s */ set sql_log_bin=1; @@ -416,7 +416,7 @@ SHOW STATUS LIKE 'Rpl_semi_sync_slave_status'; Variable_name Value include/stop_slave.inc [ reinstall semi-sync slave plugin and disable semi-sync ] -INSTALL PLUGIN rpl_semi_sync_slave SONAME 'libsemisync_slave.so'; +INSTALL PLUGIN rpl_semi_sync_slave SONAME 'SEMISYNC_SLAVE_PLUGIN'; set global rpl_semi_sync_slave_enabled= 0; SHOW VARIABLES LIKE 'rpl_semi_sync_slave_enabled'; Variable_name Value diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync.test b/mysql-test/suite/rpl/t/rpl_semi_sync.test index faf961bb580..4900acc1e91 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync.test @@ -1,6 +1,5 @@ source include/have_semisync_plugin.inc; source include/not_embedded.inc; -source include/not_windows.inc; source include/have_innodb.inc; source include/master-slave.inc; @@ -61,7 +60,7 @@ let $value = query_get_value(show variables like 'rpl_semi_sync_master_enabled', if (`select '$value' = 'No such row'`) { set sql_log_bin=0; - INSTALL PLUGIN rpl_semi_sync_master SONAME 'libsemisync_master.so'; + eval INSTALL PLUGIN rpl_semi_sync_master SONAME '$SEMISYNC_MASTER_PLUGIN'; set global rpl_semi_sync_master_timeout= 5000; /* 5s */ set sql_log_bin=1; } @@ -126,7 +125,7 @@ let $value= query_get_value(show variables like 'rpl_semi_sync_slave_enabled', V if (`select '$value' = 'No such row'`) { set sql_log_bin=0; - INSTALL PLUGIN rpl_semi_sync_slave SONAME 'libsemisync_slave.so'; + eval INSTALL PLUGIN rpl_semi_sync_slave SONAME '$SEMISYNC_SLAVE_PLUGIN'; set sql_log_bin=1; } enable_query_log; @@ -536,7 +535,8 @@ SHOW STATUS LIKE 'Rpl_semi_sync_slave_status'; connection master; set sql_log_bin=0; -INSTALL PLUGIN rpl_semi_sync_master SONAME 'libsemisync_master.so'; +replace_result $SEMISYNC_MASTER_PLUGIN SEMISYNC_MASTER_PLUGIN; +eval INSTALL PLUGIN rpl_semi_sync_master SONAME '$SEMISYNC_MASTER_PLUGIN'; set global rpl_semi_sync_master_timeout= 5000; /* 5s */ set sql_log_bin=1; set global rpl_semi_sync_master_enabled= 1; @@ -554,7 +554,8 @@ SHOW STATUS LIKE 'Rpl_semi_sync_slave_status'; source include/stop_slave.inc; echo [ reinstall semi-sync slave plugin and disable semi-sync ]; -INSTALL PLUGIN rpl_semi_sync_slave SONAME 'libsemisync_slave.so'; +replace_result $SEMISYNC_SLAVE_PLUGIN SEMISYNC_SLAVE_PLUGIN; +eval INSTALL PLUGIN rpl_semi_sync_slave SONAME '$SEMISYNC_SLAVE_PLUGIN'; set global rpl_semi_sync_slave_enabled= 0; SHOW VARIABLES LIKE 'rpl_semi_sync_slave_enabled'; SHOW STATUS LIKE 'Rpl_semi_sync_slave_status'; diff --git a/plugin/semisync/Makefile.am b/plugin/semisync/Makefile.am index dfe539b8386..25949485987 100644 --- a/plugin/semisync/Makefile.am +++ b/plugin/semisync/Makefile.am @@ -34,3 +34,5 @@ libsemisync_slave_la_LDFLAGS = -module libsemisync_slave_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN libsemisync_slave_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN libsemisync_slave_la_SOURCES = semisync.cc semisync_slave.cc semisync_slave_plugin.cc + +EXTRA_DIST= CMakeLists.txt plug.in diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc index 1a7106621a4..cc83978ad4e 100644 --- a/plugin/semisync/semisync_master.cc +++ b/plugin/semisync/semisync_master.cc @@ -45,6 +45,18 @@ char rpl_semi_sync_master_wait_no_slave = 1; static int getWaitTime(const struct timeval& start_tv); +#ifdef __WIN__ +static int gettimeofday(struct timeval *tv, void *tz) +{ + unsigned int ticks; + ticks= GetTickCount(); + tv->tv_usec= ticks*1000; + tv->tv_sec= ticks/1000; + + return 0; +} +#endif /* __WIN__ */ + /******************************************************************************* * * class : manage all active transaction nodes @@ -728,6 +740,11 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, int diff_usecs = start_tv.tv_usec + wait_timeout_ * TIME_THOUSAND; /* Calcuate the waiting period. */ +#ifdef __WIN__ + abstime.tv.i64 = (__int64)start_tv.tv_sec * TIME_MILLION * 10; + abstime.tv.i64 += (__int64)diff_usecs * 10; + abstime.max_timeout_msec= (long)wait_timeout_; +#else abstime.tv_sec = start_tv.tv_sec; if (diff_usecs < TIME_MILLION) { @@ -742,6 +759,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, } abstime.tv_nsec = diff_usecs * TIME_THOUSAND; } +#endif /* __WIN__ */ /* In semi-synchronous replication, we wait until the binlog-dump * thread has received the reply on the relevant binlog segment from the From 0e93befd36cde7b27c60a3530ef525032ae872dc Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Fri, 23 Oct 2009 15:22:20 +0800 Subject: [PATCH 5/6] Postfix of previews commit, add missing file plugin/semisync/CMakeLists.txt: Add CMakeLists.txt for semisync --- plugin/semisync/CMakeLists.txt | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 plugin/semisync/CMakeLists.txt diff --git a/plugin/semisync/CMakeLists.txt b/plugin/semisync/CMakeLists.txt new file mode 100644 index 00000000000..d42510fab18 --- /dev/null +++ b/plugin/semisync/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright (C) 2006 MySQL AB +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# This is CMakeLists.txt for semi-sync replication plugins + +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +# Add common include directories +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib + ${CMAKE_SOURCE_DIR}/sql + ${CMAKE_SOURCE_DIR}/regex + ${CMAKE_SOURCE_DIR}/extra/yassl/include) + +SET(SEMISYNC_MASTER_SOURCES semisync.cc semisync_master.cc semisync_master_plugin.cc) +SET(SEMISYNC_SLAVE_SOURCES semisync.cc semisync_slave.cc semisync_slave_plugin.cc) + +ADD_DEFINITIONS(-DMYSQL_DYNAMIC_PLUGIN) +ADD_LIBRARY(semisync_master SHARED ${SEMISYNC_MASTER_SOURCES}) +TARGET_LINK_LIBRARIES(semisync_master mysqld) +ADD_LIBRARY(semisync_slave SHARED ${SEMISYNC_SLAVE_SOURCES}) +TARGET_LINK_LIBRARIES(semisync_slave mysqld) +MESSAGE("build SEMISYNC as DLL") From a02972d8206e1f1d01618ef065f47a32e1749ac7 Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Fri, 23 Oct 2009 21:26:17 +0800 Subject: [PATCH 6/6] Skip semisync test if the plugin-dir is not set to semisync plugin dir --- mysql-test/include/have_semisync_plugin.inc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mysql-test/include/have_semisync_plugin.inc b/mysql-test/include/have_semisync_plugin.inc index 38e2fcd6115..37c9a744b6a 100644 --- a/mysql-test/include/have_semisync_plugin.inc +++ b/mysql-test/include/have_semisync_plugin.inc @@ -13,3 +13,10 @@ if (`select LENGTH('$SEMISYNC_MASTER_PLUGIN') = 0`) { skip Need semisync plugins; } + +# +# Check if --plugin-dir was setup for semisync +# +if (`SELECT CONCAT('--plugin-dir=', @@plugin_dir) != '$SEMISYNC_PLUGIN_OPT'`) { + --skip SEMISYNC plugin requires that --plugin-dir is set to the semisync plugin dir (either the .opt file does not contain \$SEMISYNC_PLUGIN_OPT or another plugin is in use) +}