Bug #53386 HA_ERR_CORRUPT_EVENT or debug assertion with different table on slave
Submitted: 3 May 2010 18:02 Modified: 29 Nov 2010 22:10
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Row Based Replication ( RBR ) Severity:S1 (Critical)
Version:5.1.46 OS:Any
Assigned to: Luis Soares CPU Architecture:Any
Tags: HA_ERR_CORRUPT_EVENT
Triage: Triaged: D1 (Critical)

[3 May 2010 18:02] Shane Bester
Description:
debug server crashes:

Assertion failed: m_curr_row_end <= m_rows_end, file g:\mysql-5.1.46-winbuild\mysql-advanced-gpl-debug-5.1.46-build\sql\log_event.h, line 3591

mysqld-debug.exe!my_sigabrt_handler()[mysqld.cc:2049]
mysqld-debug.exe!raise()[winsig.c:597]
mysqld-debug.exe!abort()[abort.c:78]
mysqld-debug.exe!_wassert()[assert.c:212]
mysqld-debug.exe!Rows_log_event::unpack_current_row()[log_event.h:3591]
mysqld-debug.exe!Rows_log_event::write_row()[log_event.cc:8519]
mysqld-debug.exe!Write_rows_log_event::do_exec_row()[log_event.cc:8707]
mysqld-debug.exe!Rows_log_event::do_apply_event()[log_event.cc:7479]
mysqld-debug.exe!Log_event::apply_event()[log_event.h:1065]
mysqld-debug.exe!apply_event_and_update_pos()[slave.cc:2154]
mysqld-debug.exe!exec_relay_log_event()[slave.cc:2293]
mysqld-debug.exe!handle_slave_sql()[slave.cc:3049]
mysqld-debug.exe!pthread_start()[my_winthread.c:85]
mysqld-debug.exe!_callthreadstart()[thread.c:295]
mysqld-debug.exe!_threadstart()[thread.c:277]
kernel32.dll!BaseThreadStart()

release server gives error:
100503 19:56:01 [ERROR] Slave SQL: Could not execute Write_rows event on table test.t1; Corrupted replication event was detected, Error_code: 1610; handler error HA_ERR_CORRUPT_EVENT; the event's master log xp64-bin.000001, end_log_pos 506, Error_code: 1610
100503 19:56:01 [Warning] Slave: Corrupted replication event was detected Error_code: 1610
100503 19:56:01 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'xp64-bin.000001' position 358

How to repeat:
setup a working rbr between two debug servers.

on master:
----------
drop table if exists `t1`;
create table `t1` (`a1` int not null,`col1` char(255) character set utf8
not null) engine=myisam;

on slave:
---------
drop table if exists `t1`;
create table `t1` (`a1` int) engine=myisam;

on master:
----------
insert into t1 values ();

#slave crashes, or gives error about corruption.
[4 May 2010 5:36] Shane Bester
here's a scenario the crashes both release and debug binaries.  additionally, debug binary is not crashing due to an assert, but rather a true crash.
5.1.46 stack:
mysqld.exe!Field_blob::get_length()[field.cc:7646]
mysqld.exe!table_def::calc_field_size()[rpl_utility.cc:136]
mysqld.exe!unpack_row()[rpl_record.cc:316]
mysqld.exe!Rows_log_event::write_row()[log_event.cc:8519]
mysqld.exe!Write_rows_log_event::do_exec_row()[log_event.cc:8709]
mysqld.exe!Rows_log_event::do_apply_event()[log_event.cc:7484]
mysqld.exe!apply_event_and_update_pos()[slave.cc:2178]
mysqld.exe!exec_relay_log_event()[slave.cc:2300]
mysqld.exe!handle_slave_sql()[slave.cc:3049]
mysqld.exe!pthread_start()[my_winthread.c:85]
mysqld.exe!_callthreadstart()[thread.c:295]
mysqld.exe!_threadstart()[thread.c:275]
kernel32.dll!BaseThreadStart()

master:
---------
drop table if exists `t1`;
create table `t1` (
  `a1` int(10) unsigned not null,
  `col4` longblob not null,
  `col5` char(234) character set utf8 not null
) engine=myisam;

slave:
------
drop table if exists `t1`;
create table `t1`(`a1` int)engine=myisam;

master:
-------
insert `t1` values ();

#slave crashes
[4 May 2010 9:00] Sveta Smirnova
Thank you for the report.

Verified as described.
[4 May 2010 9:11] Luis Soares
Related: BUG#49100.
[4 May 2010 9:22] Luis Soares
See also: BUG#33376.
[20 Oct 2010 14:47] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/121347

3288 Luis Soares	2010-10-20
      BUG#53386: HA_ERR_CORRUPT_EVENT or debug assertion with different
      table on slave
      
      When the number of raw bytes used for a CHAR field exceeds 255
      two bytes are actually used while packing the length of the
      field. CHAR fields can exceed the raw 255 byte length, for
      instance, if using multi-byte character sets.
      
      The problem is that when calculating the raw length of the field,
      at unpacking time, only one byte was assumed to be used
      always. Therefore, the number of bytes used would not add up,
      triggering the assertion.
      
      We fix this, by making the member function that calculates the
      raw byte length for a given field to take into account the actual
      number of bytes used while packing the field length.
     @ mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test
        Extended the test case with one based on the bug report entry.
[29 Oct 2010 7:48] Luis Soares
Related: BUG#37426.
[29 Oct 2010 12:10] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122298

3288 Luis Soares	2010-10-29
      BUG#53386: HA_ERR_CORRUPT_EVENT or debug assertion with different
      table on slave
      
      When the number of raw bytes used for a CHAR field exceeds 255
      two bytes are actually used while packing the length of the
      field. CHAR fields can exceed the raw 255 byte length, for
      instance, if using multi-byte character sets.
      
      The problem is that when calculating the raw length of the field,
      at unpacking time, only one byte was assumed to be used
      always. Therefore, the number of bytes used would not add up,
      triggering the assertion.
      
      We fix this, by making the member function that calculates the
      raw byte length for a given field to take into account the actual
      number of bytes used while packing the field length.
     @ mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test
        Extended the test case with one based on the bug report entry.
     @ sql/rpl_record.cc
        Added assertion so that calc_field_size always matches the
        size returned by field->unpack.
     @ sql/rpl_utility.cc
        Changed calc_field_size so that either one or two bytes are
        taken into account, depending on the maximum field size.
        
        Additionally, fixed one wrong assertion that was deployed
        when calculating the field size of a varchar type.
[29 Oct 2010 12:45] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122303
[5 Nov 2010 7:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122890
[7 Nov 2010 23:47] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/123042

3367 Luis Soares	2010-11-07
      BUG#53386: HA_ERR_CORRUPT_EVENT or debug assertion with different 
      table on slave
      
      Follow-up patch that removes the compilation warning for the
      DBUG_ASSERT.
[13 Nov 2010 16:23] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (merge vers: 5.6.99-m5) (pib:21)
[13 Nov 2010 16:32] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:alexander.nozdrin@oracle.com-20101113152540-gxro4g0v29l27f5x) (pib:21)
[29 Nov 2010 22:10] Jon Stephens
No changelog entry required; closed without further action.