From: Luis Soares Date: October 6 2010 11:23am Subject: bzr commit into mysql-5.1-bugteam branch (luis.soares:3523) Bug#38718 List-Archive: http://lists.mysql.com/commits/120098 X-Bug: 38718 Message-Id: <201010061125.o964IGKB017694@rcsinet13.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5080619301014493625==" --===============5080619301014493625== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/lsoares/Workspace/bzr/work/bugfixing/push/mysql-5.1-bugteam/ based on revid:georgi.kodinov@stripped 3523 Luis Soares 2010-10-06 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-07-09 12:00:17 +0000 +++ b/sql/log_event.cc 2010-10-06 11:23:46 +0000 @@ -1225,7 +1225,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: @@ -1313,8 +1313,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")); @@ -5978,8 +5980,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-07-04 04:02:49 +0000 +++ b/sql/log_event.h 2010-10-06 11:23:46 +0000 @@ -1782,7 +1782,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; } --===============5080619301014493625== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/luis.soares@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: luis.soares@stripped # target_branch: file:///home/lsoares/Workspace/bzr/work/bugfixing\ # /push/mysql-5.1-bugteam/ # testament_sha1: 1a9333960ca1fa915d9f65e1c6610fb51aacd5ae # timestamp: 2010-10-06 12:23:58 +0100 # base_revision_id: georgi.kodinov@stripped\ # qqa7a03c3dhnvo9d # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWYH3c7IAArR/gHARAAJ4d/// c8UPgL////RgBwdxvh6JXbvb0u12aBo01JYSiKnmiZMAmVPYkeTUnihtQGTQ2o00yaaCUmkTaAnk TEgNGQNDQaAAAAGqeIaajCk0eoMmhoAAAAAAAlNEEJpqn6GqfoiaaND1APUAaBoAeoDmBMTQYTJk yZGEwTTTIxMAQwCSQRomAQaaJiJ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