MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:August 13 2009 6:05pm
Subject:bzr commit into mysql-5.1-bugteam branch (alfranio.correia:3059)
Bug#45694
View as plain text  
#At file:///home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-45694/mysql-5.1-bugteam/ based on revid:iggy@stripped

 3059 Alfranio Correia	2009-08-13
      BUG#45694 Deadlock in replicated statement is not retried
      
      If the SQL Thread fails to execute an event due to a temporary error (e.g.
      ER_LOCK_DEADLOCK) and the option "--slave_transaction_retries" is set the SQL
      Thread should not be aborted and the transaction should be restarted from the
      beginning and re-executed.
      
      Unfortunately, a wrong interpretation of the THD::is_fatal_error was preventing
      this behavior. In a nutshell, "this variable is set to TRUE if an execution of a
      compound statement cannot continue. In particular, it is used to disable access
      to the CONTINUE or EXIT handlers of stored routines. So even temporary errors
      may have this variable set.
      
      To fix the bug, we have done what follows:
      
         DBUG_ENTER("has_temporary_error");
      
      -  if (thd->is_fatal_error)
      -    DBUG_RETURN(0);
      -
         DBUG_EXECUTE_IF("all_errors_are_temporary_errors",
                         if (thd->main_da.is_error())
                         {

    added:
      mysql-test/suite/rpl/r/rpl_timeout_retry.result
      mysql-test/suite/rpl/t/rpl_timeout_retry-slave.opt
      mysql-test/suite/rpl/t/rpl_timeout_retry.test
    modified:
      sql/slave.cc
=== added file 'mysql-test/suite/rpl/r/rpl_timeout_retry.result'
--- a/mysql-test/suite/rpl/r/rpl_timeout_retry.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_timeout_retry.result	2009-08-13 18:05:08 +0000
@@ -0,0 +1,38 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+DROP TABLE IF EXISTS timeout1;
+Warnings:
+Note	1051	Unknown table 'timeout1'
+CREATE TABLE timeout1 (
+id int, PRIMARY KEY (id),
+val int
+) ENGINE=InnoDB;
+DROP TABLE IF EXISTS timeout2;
+Warnings:
+Note	1051	Unknown table 'timeout2'
+CREATE TABLE timeout2 (
+val int
+) ENGINE=MyIsam;
+INSERT INTO timeout1 VALUES(1,1);
+INSERT INTO timeout1 VALUES(2,1);
+INSERT INTO timeout1 VALUES(3,1);
+INSERT INTO timeout1 VALUES(4,1);
+INSERT INTO timeout1 VALUES(5,1);
+BEGIN;
+UPDATE timeout1 SET val = 3 where id = 3;
+BEGIN;
+UPDATE timeout1 SET val = 2 where id = 1;
+INSERT INTO timeout2 VALUES(1);
+UPDATE timeout1 SET val = 2 where id = 3;
+COMMIT;
+SELECT sleep(3);
+sleep(3)
+0
+ROLLBACK;
+There is no timeout error as we can see (error = )
+DROP TABLE IF EXISTS timeout1;
+DROP TABLE IF EXISTS timeout2;

=== added file 'mysql-test/suite/rpl/t/rpl_timeout_retry-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_timeout_retry-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_timeout_retry-slave.opt	2009-08-13 18:05:08 +0000
@@ -0,0 +1 @@
+--innodb --slave_transaction_retries=100

=== added file 'mysql-test/suite/rpl/t/rpl_timeout_retry.test'
--- a/mysql-test/suite/rpl/t/rpl_timeout_retry.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_timeout_retry.test	2009-08-13 18:05:08 +0000
@@ -0,0 +1,71 @@
+###############################################################################
+# BUG#45694 Deadlock in replicated statement is not retried
+#
+# This test case verifies if an error due to a temporary failure (e.g. deadlock,
+# timeout) is retried. Specifically, we try to force a timeout on the slave side
+# by holding a locking on an item that later will be updated by the SQL Thread.
+# Note however that may happen that the timeout may not occur but the test case
+# is safe to proceed without failures.
+###############################################################################
+
+###############################################################################
+#                           Configure Environment
+##############################################################################
+--source include/have_innodb.inc
+--source include/master-slave.inc
+
+DROP TABLE IF EXISTS timeout1;
+CREATE TABLE timeout1 (
+  id int, PRIMARY KEY (id),
+  val int
+) ENGINE=InnoDB;
+
+DROP TABLE IF EXISTS timeout2;
+CREATE TABLE timeout2 (
+  val int
+) ENGINE=MyIsam;
+
+INSERT INTO timeout1 VALUES(1,1);
+INSERT INTO timeout1 VALUES(2,1);
+INSERT INTO timeout1 VALUES(3,1);
+INSERT INTO timeout1 VALUES(4,1);
+INSERT INTO timeout1 VALUES(5,1);
+
+sync_slave_with_master;
+
+###############################################################################
+#                                Force a timeout
+##############################################################################
+connection slave;
+BEGIN;
+UPDATE timeout1 SET val = 3 where id = 3;
+
+connection master;
+BEGIN;
+UPDATE timeout1 SET val = 2 where id = 1;
+INSERT INTO timeout2 VALUES(1);
+UPDATE timeout1 SET val = 2 where id = 3;
+COMMIT;
+
+connection slave;
+
+let $count= 1;
+let $table= timeout2;
+--source include/wait_until_rows_count.inc
+
+SELECT sleep(3);
+
+ROLLBACK;
+
+let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
+echo There is no timeout error as we can see (error = $error);
+
+###############################################################################
+#                               Clean up
+##############################################################################
+connection master;
+
+DROP TABLE IF EXISTS timeout1;
+DROP TABLE IF EXISTS timeout2;
+
+sync_slave_with_master;

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2009-07-24 16:04:55 +0000
+++ b/sql/slave.cc	2009-08-13 18:05:08 +0000
@@ -2010,9 +2010,6 @@ static int has_temporary_error(THD *thd)
 {
   DBUG_ENTER("has_temporary_error");
 
-  if (thd->is_fatal_error)
-    DBUG_RETURN(0);
-
   DBUG_EXECUTE_IF("all_errors_are_temporary_errors",
                   if (thd->main_da.is_error())
                   {


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-5.1-bugteam branch (alfranio.correia:3059)Bug#45694Alfranio Correia13 Aug
  • Re: bzr commit into mysql-5.1-bugteam branch (alfranio.correia:3059)Bug#45694He Zhenxing14 Aug