Bug #69385 Query partially completed on the master
Submitted: 3 Jun 2013 2:45 Modified: 26 Feb 2014 5:55
Reporter: qinglin zhang (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.61 OS:Linux
Assigned to: CPU Architecture:Any
Tags: 1053, completed, master, partially, query

[3 Jun 2013 2:45] qinglin zhang
Description:
stack description:
#0  Query_log_event::write (this=0x7f0ba44f3270, file=0xe89610) at log_event.cc:2404
#1  0x00000000006d2321 in MYSQL_BIN_LOG::write (this=0xe89300, event_info=0x7f0ba44f3270) at log.cc:4517
#2  0x00000000006002bd in THD::binlog_query (this=0xa7e4c60, qtype=THD::ROW_QUERY_TYPE,
    query_arg=0x7f0b84004a00 "insert info2 select id,name from info1", query_len=38, is_trans=false, suppress_use=false, errcode=1053)
    at sql_class.cc:4013
#3  0x00000000006b0d4a in select_insert::write_to_binlog (this=0x7f0b840053f0, is_trans=false, errcode=1053) at sql_insert.cc:3385
#4  0x00000000006b0c2f in select_insert::abort (this=0x7f0b840053f0) at sql_insert.cc:3362
#5  0x000000000067cde1 in handle_select (thd=0xa7e4c60, lex=0xa7e6668, result=0x7f0b840053f0, setup_tables_done_option=1073741824)
    at sql_select.cc:275
#6  0x000000000062052d in mysql_execute_command (thd=0xa7e4c60) at sql_parse.cc:3397
#7  0x0000000000627dd0 in mysql_parse (thd=0xa7e4c60, rawbuf=0x7f0b84004a00 "insert info2 select id,name from info1", length=38,
    found_semicolon=0x7f0ba44f4c90) at sql_parse.cc:6172
#8  0x000000000061b948 in dispatch_command (command=COM_QUERY, thd=0xa7e4c60, packet=0xa7e7611 "insert info2 select id,name from info1",
    packet_length=38) at sql_parse.cc:1299
#9  0x000000000061aaf5 in do_command (thd=0xa7e4c60) at sql_parse.cc:913
#10 0x000000000061922c in handle_one_connection (arg=0xa7e4c60) at sql_connect.cc:1465
#11 0x0000003659e077e1 in start_thread () from /lib64/libpthread.so.0
#12 0x0000003659ae68ed in clone () from /lib64/libc.so.6

Master  Binlog:
#130603 10:16:53 server id 1  end_log_pos 207   Query   thread_id=66    exec_time=5     error_code=1053
use test/*!*/;
SET TIMESTAMP=1370225813/*!*/;
SET @@session.pseudo_thread_id=66/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C gbk *//*!*/;
SET @@session.character_set_client=28,@@session.collation_connection=28,@@session.collation_server=33/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
insert info2 select id,name from info1
/*!*/;

Slave error file:
130602 14:36:58 [ERROR] Slave SQL: Query partially completed on the master (error on master: 1053) and was aborted. There is a chance that your     master is inconsistent at this point. If you are sure that your master is ok, run this query manually on the slave and then restart the slave wi    th SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; . Query: 'insert info2 select id, name from info1', Error_code: 1053                       
624 130602 14:36:58 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We     stopped at log 'mysql-bin.000002' position 354816386

How to repeat:
create table info1(id int, name varchar(30)) enging=myisam;
create table info2(id int, name varchar(30)) enging=myisam;

generate data for test in table info1;

...
insert into info1 values(1,'aa');
insert into info2 values(1,'bb');
...

set binlog_format=statement;
insert info2 select id,name from info1;

kill query(insert info2 select id,name from info1;)

Suggested fix:
Index: sql/sql_insert.cc                                                                                                                            
===================================================================
--- sql/sql_insert.cc   (revision 4074)
+++ sql/sql_insert.cc   (working copy)
@@ -3359,7 +3359,8 @@
         {   
           int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
           /* error of writing binary log is ignored */
-          write_to_binlog(transactional_table, errcode);
+          if(!errcode)
+            write_to_binlog(transactional_table, errcode);
         }   
         if (!thd->current_stmt_binlog_row_based && !can_rollback_data())
           thd->transaction.all.modified_non_trans_table= TRUE;
~
[3 Jun 2013 4:46] liu hickey
MyISAM is not a ACID style storage engine, such as InnoDB. If the query is interrupted on master, it could not be rolled-back, and no matter write the statement to binlog or not fo such case, the master and slave might be in-consistent.
[26 Feb 2014 5:55] MySQL Verification Team
Hello Zhang,

Thank you for the report.
Please see the last comment from Sveta on Bug #34641

Thanks,
Umesh