Bug #16559 | Replication Problems with Non transactional tables inside an interrupted trans. | ||
---|---|---|---|
Submitted: | 17 Jan 2006 11:34 | Modified: | 28 Feb 2006 2:39 |
Reporter: | Sebastian Nohn | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | 5.0.18 | OS: | Linux (Linux) |
Assigned to: | Guilhem Bichot | CPU Architecture: | Any |
[17 Jan 2006 11:34]
Sebastian Nohn
[17 Jan 2006 11:35]
Sebastian Nohn
Also happens on 5.0.17-max
[17 Jan 2006 13:29]
Hartmut Holzgraefe
This is expected behavior. As the MyISAM table is not transactional changes applied to it can't be rolled back when the transaction fails or is manually rolled back using the ROLLBACK command. Replication only replicates successfully completed transactions on the other hand, so changes done to non-transactional tables within rolled back transactions will never be seen by the slave.
[17 Jan 2006 13:35]
Sebastian Nohn
Is it also expected that the slaves goes completely out of sync?
[17 Jan 2006 21:17]
Guilhem Bichot
Hello Sebastian, Sorry, after a second look your claims are valid. First, in MySQL, changes to a non-transactional table, if done in a transaction, are replicated properly even though the transaction rolled back. Second, normally in your case, the binlog should look like (output of mysqlbinlog): INSERT into myisam; BEGIN; # this is the place where you started mysqlbinlog UPDATE of innodb; ROLLBACK; and that would be fine (could you please check if you have this output?) [ in fact the BEGIN+UPDATE+ROLLBACK block is not necessary, but due to the presence of the MyISAM insertion *inside* the transaction, well in some more complicated cases it is necessary. ] What's really wrong is that ROLLBACK has 1053 as its error code (this is what causes your slave to stop. The error code should be 0; it's a bug which is not present in MySQL 4.1 and was introduced in MySQL 5.0. We'll fix that one, and then your replication should be fine. Until then, there is the possibly dangerous --slave-skip-errors=1053 which can be used on your slave but that is scary. If you build from source I can send you a patch. Testcase for the replication team: drop table if exists ti,tm; create table ti (a int) engine=innodb; create table tm (a int) engine=myisam; insert into ti values(1); reset master; begin; insert into tm values(2); update ti set a=3 where a=10; # stay connected after that. Run the above, then shutdown mysqld, then restart it and do mysqlbinlog: the "ROLLBACK" event will have error code 1053 (bad) in 5.0 and 0 (good) in 4.1.
[18 Jan 2006 14:09]
Sebastian Nohn
Output is: # mysqlbinlog /usr/local/mysql/data/bladeA2-bin.000001 /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; # at 4 #060118 11:52:03 server id 1001 end_log_pos 98 Start: binlog v 4, server v 5.0.18-standard-log created 060118 11:52:03 at startup ROLLBACK; # at 98 #060118 11:52:03 server id 1001 end_log_pos 193 Query thread_id=1185 exec_time=0 error_code=0 use dms_2_0; SET TIMESTAMP=1137581523; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.sql_mode=0; SET @@session.auto_increment_increment=2, @@session.auto_increment_offset=1; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=31; insert into tm values(2); # at 193 #060118 11:52:05 server id 1001 end_log_pos 269 Query thread_id=1185 exec_time=21 error_code=0 SET TIMESTAMP=1137581525; BEGIN; # at 269 #060118 11:52:05 server id 1001 end_log_pos 99 Query thread_id=1185 exec_time=0 error_code=0 SET TIMESTAMP=1137581525; update ti set a=3 where a=10; # at 368 #060118 11:52:05 server id 1001 end_log_pos 447 Query thread_id=1185 exec_time=21 error_code=1053 SET TIMESTAMP=1137581525; ROLLBACK; # at 447 #060118 11:52:26 server id 1001 end_log_pos 466 Stop # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
[18 Feb 2006 16:20]
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/2850
[18 Feb 2006 16:36]
Guilhem Bichot
ChangeSet 1.2061 06/02/18 17:19:16 guilhem@mysql.com +3 -0 Fix for BUG#16559 "Replication Problems with Non transactional tables inside an interrupted trans.": problem was: when a connection disconnects having an open transaction affecting MyISAM and InnoDB, the ROLLBACK event +stored in the binary log contained a non-zero error code (1053 because of the disconnection), so when slave applied the transaction, slave +complained that its ROLLBACK succeeded (error_code=0) while master's had 1053, so slave stopped. But internally generated binlog events such as this ROLLBACK should always have 0 as error code, as is true in 4.1 and was accidentally broken in 5.0, so that there is no false alarm.
[18 Feb 2006 20:35]
Guilhem Bichot
the fix is in 5.0.19 and 5.1.8
[28 Feb 2006 2:39]
Paul DuBois
Noted in 5.0.19, 5.1.7 changelogs. For a transaction that used <literal>MyISAM</literal> and <literal>InnoDB</literal> tables, interruption of the transaction due to a dropped connection on a master server caused slaves to lose synchrony. (Bug #16559)