List:Commits« Previous MessageNext Message »
From:Li-Bing.Song Date:September 18 2009 3:52am
Subject:bzr commit into mysql-5.1-bugteam branch (Li-Bing.Song:3113) Bug#42914
View as plain text  
#At file:///home/anders/work/bzrwork/August/bug42914/mysql-5.1-bugteam/ based on revid:staale.smedseng@stripped90917152552-4ayal3h40ebxg9lh

 3113 Li-Bing.Song@stripped	2009-09-18
      Bug #42914 Log event that larger than max_allowed_packet results in stop of slave I/O thread, 
                 But there is no Last_IO_Error reported.
      
      On the master, if a binary log event is larger than max_allowed_packet,
      ER_MASTER_FATAL_ERROR_READING_BINLOG and the specific reason of this error is
      sent to a slave when it requests a dump from the master, thus leading
      the I/O thread to stop.
      
      On a slave, the I/O thread stops when receiving a packet larger than max_allowed_packet.
      
      In both cases, however, there was no Last_IO_Error reported.
      
      This patch adds code to report the Last_IO_Error and exact reason before stopping the
      I/O thread and also reports the case the out memory pops up while
      handling packets from the master.
     @ sql/sql_repl.cc
        The master send the Specific reasons instead of "error reading log entry" to the slave which is requesting a dump.
        if an fatal error is returned by read_log_event function.

    modified:
      mysql-test/suite/rpl/r/rpl_packet.result
      mysql-test/suite/rpl/t/rpl_packet.test
      sql/share/errmsg.txt
      sql/slave.cc
      sql/sql_repl.cc
=== modified file 'mysql-test/suite/rpl/r/rpl_packet.result'
--- a/mysql-test/suite/rpl/r/rpl_packet.result	2009-01-23 12:22:05 +0000
+++ b/mysql-test/suite/rpl/r/rpl_packet.result	2009-09-18 03:52:37 +0000
@@ -32,6 +32,21 @@ include/start_slave.inc
 CREATE TABLE `t1` (`f1` LONGTEXT) ENGINE=MyISAM;
 INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048');
 Slave_IO_Running = No (expect No)
+SELECT "Got a packet bigger than 'max_allowed_packet' bytes" AS Last_IO_Error;
+Last_IO_Error
+Got a packet bigger than 'max_allowed_packet' bytes
+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;
+CREATE TABLE t1 (f1 int PRIMARY KEY, f2 LONGTEXT, f3 LONGTEXT) ENGINE=MyISAM;
+INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), REPEAT('b', @@global.max_allowed_packet));
+Slave_IO_Running = No (expect No)
+SELECT "Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master'" AS Last_IO_Error;
+Last_IO_Error
+Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master'
 ==== clean up ====
 DROP TABLE t1;
 SET @@global.max_allowed_packet= 1024;

=== modified file 'mysql-test/suite/rpl/t/rpl_packet.test'
--- a/mysql-test/suite/rpl/t/rpl_packet.test	2009-01-23 12:22:05 +0000
+++ b/mysql-test/suite/rpl/t/rpl_packet.test	2009-09-18 03:52:37 +0000
@@ -5,6 +5,7 @@
 
 # max-out size db name 
 source include/master-slave.inc;
+source include/have_binlog_format_row.inc;
 
 let $db= DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
 disable_warnings;
@@ -86,6 +87,35 @@ connection slave;
 --source include/wait_for_slave_io_to_stop.inc
 let $slave_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1);
 --echo Slave_IO_Running = $slave_io_running (expect No)
+#
+# Bug#42914: The slave I/O thread must stop after trying to read the above
+# event, However there is no Last_IO_Error report.
+#
+let $last_io_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1);
+eval SELECT "$last_io_error" AS Last_IO_Error;
+
+#
+# Bug#42914: On the master, if a binary log event is larger than
+# max_allowed_packet, the error message ER_MASTER_FATAL_ERROR_READING_BINLOG
+# is sent to a slave when it requests a dump from the master, thus leading the
+# I/O thread to stop. However, there is no Last_IO_Error reported.
+#
+source include/master-slave-reset.inc;
+connection master;
+CREATE TABLE t1 (f1 int PRIMARY KEY, f2 LONGTEXT, f3 LONGTEXT) ENGINE=MyISAM;
+sync_slave_with_master;
+
+connection master;
+INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), REPEAT('b', @@global.max_allowed_packet));
+
+connection slave;
+# The slave I/O thread must stop after receiving
+# ER_MASTER_FATAL_ERROR_READING_BINLOG error message from master.
+--source include/wait_for_slave_io_to_stop.inc
+let $slave_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1);
+--echo Slave_IO_Running = $slave_io_running (expect No)
+let $last_io_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1);
+eval SELECT "$last_io_error" AS Last_IO_Error;
 
 --echo ==== clean up ====
 connection master;

=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt	2009-08-07 13:08:32 +0000
+++ b/sql/share/errmsg.txt	2009-09-18 03:52:37 +0000
@@ -4702,7 +4702,7 @@ ER_NOT_SUPPORTED_YET 42000 
         swe "Denna version av MySQL kan �u inte utf�'%s'"
 ER_MASTER_FATAL_ERROR_READING_BINLOG  
         nla "Kreeg fatale fout %d: '%-.128s' van master tijdens lezen van data uit binaire log"
-        eng "Got fatal error %d: '%-.128s' from master when reading data from binary log"
+        eng "Got fatal error %d from master when reading data from binary log: '%-.128s'"
         ger "Schwerer Fehler %d: '%-.128s vom Master beim Lesen des bin�n Logs"
         ita "Errore fatale %d: '%-.128s' dal master leggendo i dati dal log binario"
         por "Obteve fatal erro %d: '%-.128s' do master quando lendo dados do binary log"

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2009-08-24 10:37:44 +0000
+++ b/sql/slave.cc	2009-09-18 03:52:37 +0000
@@ -2678,15 +2678,19 @@ Log entry on master is longer than max_a
 slave. If the entry is correct, restart the server with a higher value of \
 max_allowed_packet",
                           thd->variables.max_allowed_packet);
+          mi->report(ERROR_LEVEL, ER_NET_PACKET_TOO_LARGE,
+                     ER(ER_NET_PACKET_TOO_LARGE));
           goto err;
         case ER_MASTER_FATAL_ERROR_READING_BINLOG:
-          sql_print_error(ER(mysql_error_number), mysql_error_number,
-                          mysql_error(mysql));
+          mi->report(ERROR_LEVEL, ER_MASTER_FATAL_ERROR_READING_BINLOG,
+                     ER(ER_MASTER_FATAL_ERROR_READING_BINLOG),
+                     mysql_error_number, mysql_error(mysql));
           goto err;
-        case EE_OUTOFMEMORY:
-        case ER_OUTOFMEMORY:
+        case ER_OUT_OF_RESOURCES:
           sql_print_error("\
 Stopping slave I/O thread due to out-of-memory error from master");
+          mi->report(ERROR_LEVEL, ER_OUT_OF_RESOURCES,
+                     ER(ER_OUT_OF_RESOURCES));
           goto err;
         }
         if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings,

=== modified file 'sql/sql_repl.cc'
--- a/sql/sql_repl.cc	2009-07-24 16:04:55 +0000
+++ b/sql/sql_repl.cc	2009-09-18 03:52:37 +0000
@@ -623,7 +623,7 @@ impossible position";
       */
       {
 	log.error=0;
-	bool read_packet = 0, fatal_error = 0;
+	bool read_packet = 0;
 
 #ifndef DBUG_OFF
 	if (max_binlog_dump_events && !left_events--)
@@ -645,7 +645,7 @@ impossible position";
 	*/
 
 	pthread_mutex_lock(log_lock);
-	switch (Log_event::read_log_event(&log, packet, (pthread_mutex_t*)0)) {
+	switch (error= Log_event::read_log_event(&log, packet, (pthread_mutex_t*) 0)) {
 	case 0:
 	  /* we read successfully, so we'll need to send it to the slave */
 	  pthread_mutex_unlock(log_lock);
@@ -671,8 +671,8 @@ impossible position";
 
 	default:
 	  pthread_mutex_unlock(log_lock);
-	  fatal_error = 1;
-	  break;
+          test_for_non_eof_log_read_errors(error, &errmsg);
+          goto err;
 	}
 
 	if (read_packet)
@@ -701,12 +701,6 @@ impossible position";
 	  */
 	}
 
-	if (fatal_error)
-	{
-	  errmsg = "error reading log entry";
-          my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
-	  goto err;
-	}
 	log.error=0;
       }
     }

Attachment: [text/bzr-bundle] bzr/li-bing.song@sun.com-20090918035237-u97aobhi25nmc4gq.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Li-Bing.Song:3113) Bug#42914Li-Bing.Song18 Sep