List:Commits« Previous MessageNext Message »
From:He Zhenxing Date:July 7 2009 7:24am
Subject:bzr commit into mysql-5.4 branch (zhenxing.he:2804) Bug#45819
View as plain text  
#At file:///media/sdb2/hezx/work/mysql/bzrwork/b45819/azalea-bugfixing/ based on revid:alik@stripped

 2804 He Zhenxing	2009-07-07
      BUG#45819 Semisynchronous replication: unstable operation with row-based binlog
      
      The master semi-sync wait timeout values was in milliseconds, and
      the defualt was 10ms, which caused a lot timeouts, and there were
      no log information about the semi-sync status changes because of
      timeout.
      
      This patch change the timeout precision to seconds, and also add
      log information when semi-sync on master switches on or off.

    M  mysql-test/suite/rpl/r/rpl_semi_sync.result
    M  mysql-test/suite/rpl/t/rpl_semi_sync.test
    M  plugin/semisync/semisync_master.cc
    M  plugin/semisync/semisync_master.h
    M  plugin/semisync/semisync_master_plugin.cc
=== modified file 'mysql-test/suite/rpl/r/rpl_semi_sync.result'
--- a/mysql-test/suite/rpl/r/rpl_semi_sync.result	2009-06-17 10:37:04 +0000
+++ b/mysql-test/suite/rpl/r/rpl_semi_sync.result	2009-07-07 07:23:54 +0000
@@ -289,7 +289,7 @@ Rpl_semi_sync_slave_status	OFF
 #
 set sql_log_bin=0;
 INSTALL PLUGIN rpl_semi_sync_master SONAME 'libsemisync_master.so';
-set global rpl_semi_sync_master_timeout= 5000;
+set global rpl_semi_sync_master_timeout= 5;
 /* 5s */
 set sql_log_bin=1;
 set global rpl_semi_sync_master_enabled= 1;

=== modified file 'mysql-test/suite/rpl/t/rpl_semi_sync.test'
--- a/mysql-test/suite/rpl/t/rpl_semi_sync.test	2009-06-17 10:37:04 +0000
+++ b/mysql-test/suite/rpl/t/rpl_semi_sync.test	2009-07-07 07:23:54 +0000
@@ -46,7 +46,7 @@ if (`select '$value' = 'No such row'`)
 {
     set sql_log_bin=0;
     INSTALL PLUGIN rpl_semi_sync_master SONAME 'libsemisync_master.so';
-    set global rpl_semi_sync_master_timeout= 5000; /* 5s */
+    set global rpl_semi_sync_master_timeout= 5; /* 5s */
     set sql_log_bin=1;
 }
 enable_query_log;
@@ -328,7 +328,7 @@ SHOW STATUS LIKE 'Rpl_semi_sync_slave_st
 connection master;
 set sql_log_bin=0;
 INSTALL PLUGIN rpl_semi_sync_master SONAME 'libsemisync_master.so';
-set global rpl_semi_sync_master_timeout= 5000; /* 5s */
+set global rpl_semi_sync_master_timeout= 5; /* 5s */
 set sql_log_bin=1;
 set global rpl_semi_sync_master_enabled= 1;
 

=== modified file 'plugin/semisync/semisync_master.cc'
--- a/plugin/semisync/semisync_master.cc	2009-06-17 10:37:04 +0000
+++ b/plugin/semisync/semisync_master.cc	2009-07-07 07:23:54 +0000
@@ -438,7 +438,7 @@ int ReplSemiSyncMaster::enableMaster()
     }
     else
     {
-      sql_print_information("Semi-sync replication not able to allocate memory.");
+      sql_print_error("Cannot allocate memory to enable semi-sync on the master.");
       result = -1;
     }
   }
@@ -726,23 +726,9 @@ int ReplSemiSyncMaster::commitTrx(const 
 
       if (start_time_err == 0)
       {
-        int diff_usecs = start_tv.tv_usec + wait_timeout_ * TIME_THOUSAND;
-
         /* Calcuate the waiting period. */
-        abstime.tv_sec = start_tv.tv_sec;
-        if (diff_usecs < TIME_MILLION)
-	{
-          abstime.tv_nsec = diff_usecs * TIME_THOUSAND;
-        }
-	else
-	{
-          while (diff_usecs >= TIME_MILLION)
-	  {
-            abstime.tv_sec++;
-            diff_usecs -= TIME_MILLION;
-          }
-          abstime.tv_nsec = diff_usecs * TIME_THOUSAND;
-        }
+        abstime.tv_sec = start_tv.tv_sec + wait_timeout_;
+        abstime.tv_nsec = start_tv.tv_usec * TIME_THOUSAND;
 
         /* In semi-synchronous replication, we wait until the binlog-dump
          * thread has received the reply on the relevant binlog segment from the
@@ -755,7 +741,7 @@ int ReplSemiSyncMaster::commitTrx(const 
         wait_sessions_++;
 
         if (trace_level_ & kTraceDetail)
-          sql_print_information("%s: wait %lu ms for binlog sent (%s, %lu)",
+          sql_print_information("%s: wait %lu seconds for binlog sent (%s, %lu)",
                                 kWho, wait_timeout_,
                                 wait_file_name_, (unsigned long)wait_file_pos_);
 
@@ -764,17 +750,11 @@ int ReplSemiSyncMaster::commitTrx(const 
 
         if (wait_result != 0)
 	{
-          if (trace_level_ & kTraceGeneral)
-	  {
-            /* This is a real wait timeout. */
-            sql_print_warning("Replication semi-sync not sent binlog to "
-                            "slave within the timeout %lu ms - OFF.",
-                            wait_timeout_);
-            sql_print_warning("          semi-sync up to file %s, position %lu",
+          /* This is a real wait timeout. */
+          sql_print_warning("Timeout waiting for reply of binlog (file: %s, pos: %lu), "
+                            "semi-sync up to file %s, position %lu.",
+                            trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos,
                             reply_file_name_, (unsigned long)reply_file_pos_);
-            sql_print_warning("          transaction needs file %s, position %lu",
-                            trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos);
-          }
           total_wait_timeouts_++;
 
           /* switch semi-sync off */
@@ -867,7 +847,7 @@ int ReplSemiSyncMaster::switch_off()
   switched_off_times_++;
   wait_file_name_inited_   = false;
   reply_file_name_inited_  = false;
-  commit_file_name_inited_ = false;
+  sql_print_information("Semi-sync replication switched OFF.");
   cond_broadcast();                            /* wake up all waiting threads */
 
   return function_exit(kWho, result);
@@ -904,11 +884,10 @@ int ReplSemiSyncMaster::try_switch_on(in
     /* Switch semi-sync replication on. */
     state_ = true;
 
-    if (trace_level_ & kTraceGeneral)
-      sql_print_information("%s switch semi-sync ON with server(%d) "
-                            "at (%s, %lu), repl(%d)",
-                            kWho, server_id, log_file_name,
-                            (unsigned long)log_file_pos, (int)is_on());
+    sql_print_information("Semi-sync replication switched ON with slave (server_id: %d) "
+                          "at (%s, %lu)",
+                          server_id, log_file_name,
+                          (unsigned long)log_file_pos);
   }
 
   return function_exit(kWho, 0);
@@ -930,6 +909,9 @@ int ReplSemiSyncMaster::reserveSyncHeade
     /* No enough space for the extra header, disable semi-sync master */
     if (sizeof(kSyncHeader) > size)
     {
+      sql_print_warning("No enough space in the packet "
+                        "for semi-sync extra header, "
+                        "semi-sync replication disabled");
       disableMaster();
       return 0;
     }

=== modified file 'plugin/semisync/semisync_master.h'
--- a/plugin/semisync/semisync_master.h	2009-06-15 13:30:20 +0000
+++ b/plugin/semisync/semisync_master.h	2009-07-07 07:23:54 +0000
@@ -173,7 +173,7 @@ class ReplSemiSyncMaster
 
   /* All global variables which can be set by parameters. */
   volatile bool            master_enabled_;      /* semi-sync is enabled on the master */
-  unsigned long           wait_timeout_;      /* timeout period(ms) during tranx wait */
+  unsigned long           wait_timeout_;      /* timeout period (seconds) during tranx wait */
 
   /* All status variables. */
   bool            state_;                    /* whether semi-sync is switched */
@@ -228,7 +228,7 @@ class ReplSemiSyncMaster
       active_tranxs_->trace_level_ = trace_level;
   }
 
-  /* Set the transaction wait timeout period, in milliseconds. */
+  /* Set the transaction wait timeout period, in seconds. */
   void setWaitTimeout(unsigned long wait_timeout) {
     wait_timeout_ = wait_timeout;
   }

=== modified file 'plugin/semisync/semisync_master_plugin.cc'
--- a/plugin/semisync/semisync_master_plugin.cc	2009-06-17 10:37:04 +0000
+++ b/plugin/semisync/semisync_master_plugin.cc	2009-07-07 07:23:54 +0000
@@ -156,7 +156,7 @@ static MYSQL_SYSVAR_BOOL(enabled, rpl_se
 
 static MYSQL_SYSVAR_ULONG(timeout, rpl_semi_sync_master_timeout,
   PLUGIN_VAR_OPCMDARG,
- "The timeout value (in ms) for semi-synchronous replication in the master",
+ "The timeout value (in seconds) for semi-synchronous replication in the master",
   NULL, 			// check
   fix_rpl_semi_sync_master_timeout,	// update
   10, 0, ~0L, 1);


Attachment: [text/bzr-bundle] bzr/zhenxing.he@sun.com-20090707072354-ukbk3gjbrzyg0urt.bundle
Thread
bzr commit into mysql-5.4 branch (zhenxing.he:2804) Bug#45819He Zhenxing7 Jul