List:Internals« Previous MessageNext Message »
From:tomas Date:June 13 2005 7:54pm
Subject:bk commit into 5.1 tree (tomas:1.1958) BUG#11239
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1958 05/06/13 21:53:54 tomas@stripped +6 -0
  Bug #11239  	Partial master update of row that does not exist on slave breaks replication
  - added idempotency handeling for constraint violation during slave SQL thread running ndb transactions

  sql/log_event.cc
    1.208 05/06/13 21:53:49 tomas@stripped +1 -0
    Bug #11239  	Partial master update of row that does not exist on slave breaks replication
    - added idempotency handeling for constraint violation during slave SQL thread running ndb transactions

  sql/ha_ndbcluster.h
    1.100 05/06/13 21:53:49 tomas@stripped +2 -0
    Bug #11239  	Partial master update of row that does not exist on slave breaks replication
    - added idempotency handeling for constraint violation during slave SQL thread running ndb transactions

  sql/ha_ndbcluster.cc
    1.279 05/06/13 21:53:49 tomas@stripped +32 -3
    Bug #11239  	Partial master update of row that does not exist on slave breaks replication
    - added idempotency handeling for constraint violation during slave SQL thread running ndb transactions

  mysql-test/t/rpl_ndb_idempotent.test
    1.8 05/06/13 21:53:49 tomas@stripped +38 -0
    Bug #11239  	Partial master update of row that does not exist on slave breaks replication
    - added idempotency handeling for constraint violation during slave SQL thread running ndb transactions

  mysql-test/r/rpl_ndb_idempotent.result
    1.8 05/06/13 21:53:49 tomas@stripped +18 -0
    Bug #11239  	Partial master update of row that does not exist on slave breaks replication
    - added idempotency handeling for constraint violation during slave SQL thread running ndb transactions

  include/my_base.h
    1.70 05/06/13 21:53:49 tomas@stripped +3 -1
    Bug #11239  	Partial master update of row that does not exist on slave breaks replication
    - added idempotency handeling for constraint violation during slave SQL thread running ndb transactions

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	tomas
# Host:	poseidon.ndb.mysql.com
# Root:	/home/tomas/mysql-5.1-wl2325

--- 1.69/include/my_base.h	2005-04-07 20:17:33 +02:00
+++ 1.70/include/my_base.h	2005-06-13 21:53:49 +02:00
@@ -152,7 +152,9 @@
     other fields intact. When this is off (by default) InnoDB will use memcpy
     to overwrite entire row.
   */
-  HA_EXTRA_KEYREAD_PRESERVE_FIELDS
+  HA_EXTRA_KEYREAD_PRESERVE_FIELDS,
+  HA_EXTRA_IGNORE_NO_KEY,		/* Tuple not found don't rollback everything*/
+  HA_EXTRA_NO_IGNORE_NO_KEY
 };
 
 	/* The following is parameter to ha_panic() */

--- 1.207/sql/log_event.cc	2005-06-10 01:03:48 +02:00
+++ 1.208/sql/log_event.cc	2005-06-13 21:53:49 +02:00
@@ -5624,6 +5624,7 @@
   // idempotency handling
   thd->lex->sql_command= SQLCOM_REPLACE; // needed for innodb and ndbcluster
   table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); // needed for ndbcluster
+  table->file->extra(HA_EXTRA_IGNORE_NO_KEY); // needed for ndbcluster
   // TODO: Ensure that myisam allow write_row() with duplicate key.
  
   // TODO: better if we know how many...

--- 1.278/sql/ha_ndbcluster.cc	2005-06-13 16:50:07 +02:00
+++ 1.279/sql/ha_ndbcluster.cc	2005-06-13 21:53:49 +02:00
@@ -298,6 +298,22 @@
   return error;
 }
 
+int execute_no_commit_ignore_no_key(ha_ndbcluster *h, NdbTransaction *trans)
+{
+  int r= trans->execute(NdbTransaction::NoCommit,
+			NdbTransaction::AO_IgnoreError,
+			h->m_force_send);
+  if (r == 0)
+    return 0;
+
+  const NdbError &err= trans->getNdbError();
+  if (err.classification != NdbError::ConstraintViolation &&
+      err.classification != NdbError::NoDataFound)
+    return r;
+  //err.code= 0; ToDo?
+  return 0;
+}
+
 inline
 int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans)
 {
@@ -306,9 +322,11 @@
   if (m_batch_execute)
     return 0;
 #endif
-  return trans->execute(NdbTransaction::NoCommit,
-                        NdbTransaction::AbortOnError,
-                        h->m_force_send);
+  return h->m_ignore_no_key ?
+    execute_no_commit_ignore_no_key(h,trans) :
+    trans->execute(NdbTransaction::NoCommit,
+		   NdbTransaction::AbortOnError,
+		   h->m_force_send);
 }
 
 inline
@@ -3094,6 +3112,16 @@
     m_use_write= FALSE;
     m_ignore_dup_key= FALSE;
     break;
+  case HA_EXTRA_IGNORE_NO_KEY:
+    DBUG_PRINT("info", ("HA_EXTRA_IGNORE_NO_KEY"));
+    DBUG_PRINT("info", ("Turning on AO_IgnoreError at Commit/NoCommit"));
+    m_ignore_no_key= TRUE;
+    break;
+  case HA_EXTRA_NO_IGNORE_NO_KEY:
+    DBUG_PRINT("info", ("HA_EXTRA_NO_IGNORE_NO_KEY"));
+    DBUG_PRINT("info", ("Turning on AO_IgnoreError at Commit/NoCommit"));
+    m_ignore_no_key= FALSE;
+    break;
   }
   
   DBUG_RETURN(0);
@@ -4570,6 +4598,7 @@
   m_use_write(FALSE),
   m_ignore_dup_key(FALSE),
   m_primary_key_update(FALSE),
+  m_ignore_no_key(FALSE),
   m_rows_to_insert((ha_rows) 1),
   m_rows_inserted((ha_rows) 0),
   m_bulk_insert_rows((ha_rows) 1024),

--- 1.99/sql/ha_ndbcluster.h	2005-06-06 09:26:57 +02:00
+++ 1.100/sql/ha_ndbcluster.h	2005-06-13 21:53:49 +02:00
@@ -656,6 +656,7 @@
                            NdbScanOperation* op);
 
   friend int execute_commit(ha_ndbcluster*, NdbTransaction*);
+  friend int execute_no_commit_ignore_no_key(ha_ndbcluster*, NdbTransaction*);
   friend int execute_no_commit(ha_ndbcluster*, NdbTransaction*);
   friend int execute_no_commit_ie(ha_ndbcluster*, NdbTransaction*);
 
@@ -677,6 +678,7 @@
   bool m_ignore_dup_key;
   bool m_primary_key_update;
   bool m_write_op;
+  bool m_ignore_no_key;
   ha_rows m_rows_to_insert;
   ha_rows m_rows_inserted;
   ha_rows m_bulk_insert_rows;

--- 1.7/mysql-test/r/rpl_ndb_idempotent.result	2005-06-01 07:06:57 +02:00
+++ 1.8/mysql-test/r/rpl_ndb_idempotent.result	2005-06-13 21:53:49 +02:00
@@ -52,3 +52,21 @@
 row3	C	3
 row4	D	4
 STOP SLAVE;
+DROP TABLE t1;
+RESET master;
+DROP TABLE t1;
+RESET slave;
+START SLAVE;
+CREATE TABLE t1 (c1 CHAR(15) NOT NULL, c2 CHAR(15) NOT NULL, c3 INT NOT NULL, PRIMARY KEY (c3)) ENGINE = NDB ;
+INSERT INTO t1 VALUES ("row1","remove on slave",1);
+DELETE FROM t1;
+BEGIN;
+UPDATE t1 SET c2="does not exist" WHERE c3=1;
+INSERT INTO t1 VALUES ("row2","new on slave",2);
+COMMIT;
+SELECT * FROM t1;
+c1	c2	c3
+row2	new on slave	2
+SHOW SLAVE STATUS;
+Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
+<Slave_IO_State>	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	<Read_Master_Log_Pos>	<Relay_Log_File>	<Relay_Log_Pos>	master-bin.000001	Yes	Yes				<Replicate_Ignore_Table>			0		0	<Exec_Master_Log_Pos>	<Relay_Log_Space>	None		0	No						<Seconds_Behind_Master>

--- 1.7/mysql-test/t/rpl_ndb_idempotent.test	2005-06-13 16:50:07 +02:00
+++ 1.8/mysql-test/t/rpl_ndb_idempotent.test	2005-06-13 21:53:49 +02:00
@@ -71,3 +71,41 @@
 SELECT * FROM t1 ORDER BY c3;
 
 STOP SLAVE;
+
+#
+# cleanup
+#
+--connection master
+DROP TABLE t1;
+RESET master;
+--connection slave
+DROP TABLE t1;
+RESET slave;
+
+START SLAVE;
+
+#
+# Test that we can handle update of a row that does not exist on the slave
+# will trigger usage of AO_IgnoreError on slave side so that the INSERT
+# still succeeds even if the replication of the UPDATE generates an error.
+#
+--connection master
+CREATE TABLE t1 (c1 CHAR(15) NOT NULL, c2 CHAR(15) NOT NULL, c3 INT NOT NULL, PRIMARY KEY (c3)) ENGINE = NDB ;
+INSERT INTO t1 VALUES ("row1","remove on slave",1);
+
+--sync_slave_with_master
+--connection slave
+DELETE FROM t1;
+
+--connection master
+BEGIN;
+UPDATE t1 SET c2="does not exist" WHERE c3=1;
+INSERT INTO t1 VALUES ("row2","new on slave",2);
+COMMIT;
+
+--sync_slave_with_master
+--connection slave
+SELECT * FROM t1;
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 <Slave_IO_State> 7 <Read_Master_Log_Pos> 8 <Relay_Log_File> 9 <Relay_Log_Pos> 16 <Replicate_Ignore_Table> 22 <Exec_Master_Log_Pos> 23 <Relay_Log_Space> 33 <Seconds_Behind_Master>
+SHOW SLAVE STATUS;
Thread
bk commit into 5.1 tree (tomas:1.1958) BUG#11239tomas13 Jun