List:Commits« Previous MessageNext Message »
From:Luis Soares Date:September 20 2010 9:33pm
Subject:bzr commit into mysql-next-mr-bugfixing branch (luis.soares:3295) Bug#38718
View as plain text  
#At file:///home/lsoares/Workspace/bzr/work/bugfixing/38718/mysql-next-mr-bugfixing/ based on revid:alfranio.correia@stripped

 3295 Luis Soares	2010-09-20
      BUG#38718: slave sql thread crashes when reading relay log
      
      Suprisingly, a Slave_log_event would show up in the binary
      log. This event is never used and should not appear in the
      logs. As such, when the slave (or the mysqlbinlog tool) reads the
      event, it will hit an invalid pointer (reference to the
      descriptor event when deserializing the Slave_log_event was
      purposodely set to NULL).
      
      The presence of the Slave_log_event denotes a corrupted log, but
      we cannot tell how the log got corrupted in the first
      place. However, we can make the server cope with such events when
      it reads them - in case of log corruption - and fail gracefully.
      
      This patch makes the server/mysqlbinlog to report that it has
      found an invalid log event when Slave_log_event is read.

    modified:
      sql/log_event.cc
      sql/log_event.h
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-09-01 02:51:08 +0000
+++ b/sql/log_event.cc	2010-09-20 21:33:54 +0000
@@ -1259,7 +1259,7 @@ Log_event* Log_event::read_log_event(con
       break;
 #ifdef HAVE_REPLICATION
     case SLAVE_EVENT: /* can never happen (unused event) */
-      ev = new Slave_log_event(buf, event_len);
+      ev = new Slave_log_event(buf, event_len, description_event);
       break;
 #endif /* HAVE_REPLICATION */
     case CREATE_FILE_EVENT:
@@ -1361,8 +1361,10 @@ Log_event* Log_event::read_log_event(con
     (because constructor is "void") ; so instead we leave the pointer we
     wanted to allocate (e.g. 'query') to 0 and we test it in is_valid().
     Same for Format_description_log_event, member 'post_header_len'.
+
+    SLAVE_EVENT is never used, so it should not be read ever.
   */
-  if (!ev || !ev->is_valid())
+  if (!ev || !ev->is_valid() || (event_type == SLAVE_EVENT))
   {
     DBUG_PRINT("error",("Found invalid event in binary log"));
 
@@ -6151,8 +6153,12 @@ void Slave_log_event::init_from_mem_pool
 
 
 /** This code is not used, so has not been updated to be format-tolerant. */
-Slave_log_event::Slave_log_event(const char* buf, uint event_len)
-  :Log_event(buf,0) /*unused event*/ ,mem_pool(0),master_host(0)
+/* We are using description_event so that slave does not crash on Log_event
+  constructor */
+Slave_log_event::Slave_log_event(const char* buf, 
+                                 uint event_len,
+                                 const Format_description_log_event* description_event)
+  :Log_event(buf,description_event),mem_pool(0),master_host(0)
 {
   if (event_len < LOG_EVENT_HEADER_LEN)
     return;

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2010-09-01 02:51:08 +0000
+++ b/sql/log_event.h	2010-09-20 21:33:54 +0000
@@ -1867,7 +1867,9 @@ public:
   void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 #endif
 
-  Slave_log_event(const char* buf, uint event_len);
+  Slave_log_event(const char* buf,
+                  uint event_len,
+                  const Format_description_log_event *description_event);
   ~Slave_log_event();
   int get_data_size();
   bool is_valid() const { return master_host != 0; }


Attachment: [text/bzr-bundle] bzr/luis.soares@oracle.com-20100920213354-wnfcwqww2f25v97n.bundle
Thread
bzr commit into mysql-next-mr-bugfixing branch (luis.soares:3295) Bug#38718Luis Soares20 Sep