Bug #48776 row based replication breaks with spatial / geometry types, cause crashes!
Submitted: 14 Nov 2009 17:58 Modified: 29 Nov 2010 13:55
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.40, 5.1.42 OS:Any
Assigned to: Zhenxing He
Triage: Triaged: D1 (Critical)

[14 Nov 2009 17:58] Shane Bester
Description:
geometry types are not handled properly by row based replication.
the testcase in 'how to repeat' causes this error on slave:

[ERROR] Slave SQL: Table definition on master and slave does not match: Column 1 size mismatch - master has size 65284, test.t0 on slave has size 255. Master's column size should be <= the slave's column size. Error_code: 1535

How to repeat:
#setup a master/slave with --binlog-format=row on master.
#run this on master, then watch the slave error.

drop table if exists `t0`;
create table `t0`(
`col2` multipoint not null ,
`col7` varchar(255))
;

insert ignore into `t0` set 
`col2`=geomfromtext('multipoint(1 1)'),
`col7`='20320';
[14 Nov 2009 18:06] Valerii Kravchuk
Verified just as described:

77-52-1-11:mysql-test openxs$ ./mysql-test-run.pl --suite=rpl rpl_bug48776
Logging: ./mysql-test-run.pl  --suite=rpl rpl_bug48776
091114 20:03:54 [Warning] Setting lower_case_table_names=2 because file system for /var/folders/dX/dXCzvuSlHX4Op1g-o1jIWk+++TI/-Tmp-/RjYve3glE4/ is case insensitive
091114 20:03:54 [Note] Plugin 'FEDERATED' is disabled.
091114 20:03:54 [Note] Plugin 'ndbcluster' is disabled.
MySQL Version 5.1.42
Checking supported features...
 - using ndbcluster when necessary, mysqld supports it
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
 - adding combinations for rpl
vardir: /Users/openxs/dbs/5.1/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/Users/openxs/dbs/5.1/mysql-test/var'...
Installing system database...
Using server port 50077

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
rpl.rpl_bug48776 'row'                   [ fail ]
        Test ended at 2009-11-14 20:04:02

CURRENT_TEST: rpl.rpl_bug48776
=== SHOW MASTER STATUS ===
---- 1. ----
File	slave-bin.000001
Position	325
Binlog_Do_DB	
Binlog_Ignore_DB	
==========================

=== SHOW SLAVE STATUS ===
---- 1. ----
Slave_IO_State	Waiting for master to send event
Master_Host	127.0.0.1
Master_User	root
Master_Port	13000
Connect_Retry	1
Master_Log_File	master-bin.000001
Read_Master_Log_Pos	581
Relay_Log_File	slave-relay-bin.000003
Relay_Log_Pos	471
Relay_Master_Log_File	master-bin.000001
Slave_IO_Running	Yes
Slave_SQL_Running	No
Replicate_Do_DB	
Replicate_Ignore_DB	
Replicate_Do_Table	
Replicate_Ignore_Table	
Replicate_Wild_Do_Table	
Replicate_Wild_Ignore_Table	
Last_Errno	1535
Last_Error	Table definition on master and slave does not match: Column 1 size mismatch - master has size 65284, test.t0 on slave has size 255. Master's column size should be <= the slave's column size.
Skip_Counter	0
Exec_Master_Log_Pos	325
Relay_Log_Space	882
Until_Condition	None
Until_Log_File	
Until_Log_Pos	0
Master_SSL_Allowed	No
Master_SSL_CA_File	
Master_SSL_CA_Path	
Master_SSL_Cert	
Master_SSL_Cipher	
Master_SSL_Key	
Seconds_Behind_Master	
Master_SSL_Verify_Server_Cert	No
Last_IO_Errno	0
Last_IO_Error	
Last_SQL_Errno	1535
Last_SQL_Error	Table definition on master and slave does not match: Column 1 size mismatch - master has size 65284, test.t0 on slave has size 255. Master's column size should be <= the slave's column size.

...

analyze: sync_with_master
mysqltest: At line 16: sync_with_master failed: 'select master_pos_wait('master-bin.000001', 581, 300)' returned NULL indicating slave SQL thread failure

The result from queries just before the failure was:
< snip >
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop table if exists `t0`;
Warnings:
Note	1051	Unknown table 't0'
create table `t0`(
`col2` multipoint not null ,
`col7` varchar(255))
;
insert ignore into `t0` set 
`col2`=geomfromtext('multipoint(1 1)'),
`col7`='20320';
...
[15 Nov 2009 8:25] Shane Bester
Tiny modification to the original testcase - using >255 length varchar in the same table, the slave can crash! (see cutted valgrind output);

drop table if exists `t0`;
create table `t0`(
`col2` multipoint not null ,
`col7` varchar(256))
;

insert ignore into `t0` set 
`col2`=geomfromtext('multipoint(1 1)'),
`col7`='20320';

Thread 12:
Invalid read of size 4
at: Field_blob::unpack (field.cc:7695)
by: unpack_row(rpl_record.cc:242)
by: Rows_log_event::write_row(log_event.h:3549)
by: Write_rows_log_event::do_exec_row (log_event.cc:8641)
by: Rows_log_event::do_apply_event(log_event.cc:7414)
by: apply_event_and_update_pos(log_event.h:1059)
by: handle_slave_sql (slave.cc:2281)
by: start_thread (in /lib/libpthread-2.5.so)
by: clone (in /lib/libc-2.5.so)
 Address 0x741d076 is 0 bytes after a block of size 46 alloc'd
at: malloc (vg_replace_malloc.c:195)
by: my_malloc (my_malloc.c:34)
by: Rows_log_event::Rows_log_event(log_event.cc:7082)
by: Write_rows_log_event::Write_rows_log_event(log_event.cc:8248)
by: Log_event::read_log_event(log_event.cc:1275)
by: Log_event::read_log_event(log_event.cc:1124)
by: handle_slave_sql (slave.cc:4098)
by: start_thread (in /lib/libpthread-2.5.so)
by: clone (in /lib/libc-2.5.so)

Invalid read of size 1
at: Field_varstring::unpack(field.cc:7415)
by: unpack_row (rpl_record.cc:242)
by: Rows_log_event::write_row(log_event.h:3549)
by: Write_rows_log_event::do_exec_row(log_event.cc:8641)
by: Rows_log_event::do_apply_event(log_event.cc:7414)
by: apply_event_and_update_pos(log_event.h:1059)
by: handle_slave_sql (slave.cc:2281)
by: start_thread (in /lib/libpthread-2.5.so)
by: clone (in /lib/libc-2.5.so)
 Address 0x741d07a is 4 bytes after a block of size 46 alloc'd
at: malloc (vg_replace_malloc.c:195)
by: my_malloc (my_malloc.c:34)
by: Rows_log_event::Rows_log_event(log_event.cc:7082)
by: Write_rows_log_event::Write_rows_log_event(log_event.cc:8248)
by: Log_event::read_log_event(log_event.cc:1275)
by: Log_event::read_log_event(log_event.cc:1124)
by: handle_slave_sql (slave.cc:4098)
by: start_thread (in /lib/libpthread-2.5.so)
by: clone (in /lib/libc-2.5.so)
[30 Dec 2009 8: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/95807

3289 He Zhenxing	2009-12-30
      Bug#48776 row based replication breaks with spatial / geometry types, cause crashes!
      
      This bug is the same problem as Bug 49836 for 5.1 versions.
     @ sql/rpl_utility.h
        Add missing case MYSQL_TYPE_GEOMETRY
[30 Dec 2009 9:04] 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/95808

3289 He Zhenxing	2009-12-30
      Bug#48776 row based replication breaks with spatial / geometry types, cause crashes!
      
      This bug is the same problem as Bug 49836 for 5.1 versions.
     @ mysql-test/suite/rpl/r/rpl_geometry.result
        Test case for bug 48776
     @ mysql-test/suite/rpl/t/rpl_geometry.test
        Test case for bug 48776
     @ sql/rpl_utility.h
        Add missing case MYSQL_TYPE_GEOMETRY
[30 Dec 2009 9:06] Zhenxing He
Bug#43784 is marked as duplicate of this bug
[30 Dec 2009 9:14] 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/95809

3289 He Zhenxing	2009-12-30
      Bug#48776 row based replication breaks with spatial / geometry types, cause crashes!
      
      This bug is the same problem as Bug 49836 for 5.1 versions.
     @ mysql-test/suite/rpl/r/rpl_geometry.result
        Test case for bug 48776
     @ mysql-test/suite/rpl/t/rpl_geometry.test
        Test case for bug 48776
     @ sql/rpl_utility.h
        Add missing case MYSQL_TYPE_GEOMETRY
[5 Jan 2010 6:26] 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/95920

3303 He Zhenxing	2010-01-05
      Bug#48776 row based replication breaks with spatial / geometry types, cause crashes!
      
      This bug is the same problem as Bug 49836 for 5.1 versions.
     @ mysql-test/suite/rpl/r/rpl_geometry.result
        Test case for bug 48776
     @ mysql-test/suite/rpl/t/rpl_geometry.test
        Test case for bug 48776
     @ sql/rpl_utility.h
        Add missing case MYSQL_TYPE_GEOMETRY
[7 Jan 2010 9:02] Zhenxing He
see also bug#49836
[15 Jan 2010 8:58] Bugs System
Pushed into 5.1.43 (revid:joro@sun.com-20100115085139-qkh0i0fpohd9u9p5) (version source revid:zhenxing.he@sun.com-20100105062529-yo2ol9f9iwse2tn0) (merge vers: 5.1.42) (pib:16)
[22 Jan 2010 1:33] Paul Dubois
Noted in 5.1.43 changelog.

Spatial data types cause row-based replication to crash.

Setting report to NDI pending push to 5.5.x+.
[5 Feb 2010 11:45] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100204063540-9czpdmpixi3iw2yb) (version source revid:alik@sun.com-20100119163614-172adculixyu26j5) (pib:16)
[5 Feb 2010 11:51] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100205113942-oqovjy0eoqbarn7i) (version source revid:alik@sun.com-20100204064210-ljwanqvrjs83s1gq) (merge vers: 6.0.14-alpha) (pib:16)
[5 Feb 2010 11:57] Bugs System
Pushed into 5.5.2-m2 (revid:alik@sun.com-20100203172258-1n5dsotny40yufxw) (version source revid:alexey.kopytov@sun.com-20100115112653-e3a24041ag1cv6v3) (merge vers: 5.5.1-m2) (pib:16)
[5 Feb 2010 17:03] Paul Dubois
Noted in 5.5.2, 6.0.14 changelogs.

Setting report to Need Merge pending push to Celosia.
[12 Mar 2010 14:10] Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:26] Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:40] Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)
[12 Mar 2010 16:48] Paul Dubois
Fixed in earlier 5.1.x, 5.5.x.
[10 Nov 2010 8:31] Roel Van de Paar
Possible workaround may be to use STATEMENT or MIXED based replication.
[23 Nov 2010 14:13] 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/124739

3338 Martin Skold	2010-11-23
      Bug#51996 rpl_geometry fails in mysql-5.1-telco-6.3: Patch for bug#48776 was not merge in correctly
      modified:
        mysql-test/suite/rpl/t/disabled.def
        sql/rpl_utility.cc
[23 Nov 2010 14:46] 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/124741

3978 Martin Skold	2010-11-23 [merge]
      Merge
      modified:
        mysql-test/suite/rpl/t/disabled.def
        sql/rpl_utility.cc
[23 Nov 2010 14:58] 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/124742

3968 Martin Skold	2010-11-23 [merge]
      Merge
      modified:
        mysql-test/suite/rpl/t/disabled.def
        sql/rpl_utility.cc
[23 Nov 2010 15:08] 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/124744

3343 Martin Skold	2010-11-23 [merge]
      Merge
      modified:
        mysql-test/suite/rpl/t/disabled.def
        sql/rpl_utility.cc
[23 Nov 2010 15:08] 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/124745

3989 Martin Skold	2010-11-23 [merge]
      Merge
      modified:
        mysql-test/suite/rpl/t/disabled.def
        sql/rpl_utility.cc
[23 Nov 2010 15:09] Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.40 (revid:martin.skold@mysql.com-20101123150732-eof49yrm5oaldu5e) (version source revid:martin.skold@mysql.com-20101123150732-eof49yrm5oaldu5e) (merge vers: 5.1.51-ndb-6.3.40) (pib:21)
[23 Nov 2010 15:09] Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.21 (revid:martin.skold@mysql.com-20101123150644-iiwqfy6gupp41otp) (version source revid:martin.skold@mysql.com-20101123150644-iiwqfy6gupp41otp) (merge vers: 5.1.51-ndb-7.0.21) (pib:21)
[23 Nov 2010 15:13] 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/124748

4014 Martin Skold	2010-11-23 [merge]
      Merge
      modified:
        mysql-test/suite/rpl/t/disabled.def
        sql/rpl_utility.cc
[29 Nov 2010 13:55] Martin Skold
Closing.
Bug was re-opened by mistake (referenced in commit for bug#51996)