List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:October 30 2008 1:33pm
Subject:bzr commit into mysql-5.1 branch (mats:2773) Bug#40360
View as plain text  
#At file:///home/bzr/bugs/b40360-5.1/

 2773 Mats Kindahl	2008-10-30
      Bug #40360: Binlog related errors with binlog off
      
      When statement-based replication is used, and the
      transaction isolation level is READ-COMMITTED or stricter,
      InnoDB will print an error because statement-based
      replication might lead to inconsistency between master
      and slave databases. However, when the binary log is not
      engaged, this is not an issue and an error should
      not be printed.
      
      This patch extends the check in InnoDB to also check if
      the binary log is engaged for the thread, that is, open
      and with SQL_LOG_BIN = 1. 
modified:
  mysql-test/r/innodb.result
  mysql-test/t/innodb.test
  sql/log.cc
  storage/innobase/handler/ha_innodb.cc
  storage/innobase/handler/ha_innodb.h

per-file messages:
  mysql-test/t/innodb.test
    Adding test case for BUG#40260.
  sql/log.cc
    Adding support function to check if binary log is
    engaged for a thread, that is, the binary log is 
    open and SQL_LOG_BIN = 1 for the thread.
  storage/innobase/handler/ha_innodb.cc
    Adding check that binary log is engaged. Otherwise,
    the test is not needed to ensure consistency between
    master and slave databases.
  storage/innobase/handler/ha_innodb.h
    Adding prototype for function to test if binlog is engaged.
=== modified file 'mysql-test/r/innodb.result'
--- a/mysql-test/r/innodb.result	2008-10-03 12:24:19 +0000
+++ b/mysql-test/r/innodb.result	2008-10-30 13:33:14 +0000
@@ -3295,3 +3295,16 @@ info: Records: 5  Duplicates: 0  Warning
 TRUNCATE TABLE t1;
 affected rows: 0
 DROP TABLE t1;
+SET SESSION BINLOG_FORMAT=STATEMENT;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SHOW VARIABLES LIKE 'log_bin';
+Variable_name	Value
+log_bin	OFF
+SELECT @@session.binlog_format;
+@@session.binlog_format
+STATEMENT
+SELECT @@session.tx_isolation;
+@@session.tx_isolation
+READ-COMMITTED
+CREATE TABLE t1 ( a INT ) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(1);

=== modified file 'mysql-test/t/innodb.test'
--- a/mysql-test/t/innodb.test	2008-10-03 12:24:19 +0000
+++ b/mysql-test/t/innodb.test	2008-10-30 13:33:14 +0000
@@ -2490,6 +2490,22 @@ TRUNCATE TABLE t1;
 
 --disable_info
 DROP TABLE t1;
+
+#
+# Bug #40360: Binlog related errors with binlog off
+#
+# This bug is triggered when the binlog format is STATEMENT and the
+# binary log is turned off. In this case, no error should be shown for
+# the statement since there are no replication issues.
+
+SET SESSION BINLOG_FORMAT=STATEMENT;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SHOW VARIABLES LIKE 'log_bin';
+SELECT @@session.binlog_format;
+SELECT @@session.tx_isolation;
+CREATE TABLE t1 ( a INT ) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(1);
+
 #
 #######################################################################
 #                                                                     #

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2008-10-21 12:18:38 +0000
+++ b/sql/log.cc	2008-10-30 13:33:14 +0000
@@ -5519,6 +5519,17 @@ ulonglong mysql_bin_log_file_pos(void)
 {
   return (ulonglong) mysql_bin_log.get_log_file()->pos_in_file;
 }
+/**
+  See if the binary log is engaged for a thread, i.e., open and
+  LOG_BIN is set.
+
+  @return @c true if the binlog is active, @c false otherwise. 
+*/
+extern "C"
+my_bool mysql_bin_log_is_engaged(THD *thd)
+{
+  return mysql_bin_log.is_open() && (thd->options & OPTION_BIN_LOG);
+}
 #endif /* INNODB_COMPATIBILITY_HOOKS */
 
 

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2008-08-20 22:18:33 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2008-10-30 13:33:14 +0000
@@ -6530,7 +6530,7 @@ ha_innobase::external_lock(
 	READ UNCOMMITTED and READ COMMITTED since the necessary
 	locks cannot be taken. In this case, we print an
 	informative error message and return with an error. */
-	if (lock_type == F_WRLCK)
+	if (lock_type == F_WRLCK && mysql_bin_log_is_engaged(thd))
 	{
 		ulong const binlog_format= thd_binlog_format(thd);
 		ulong const tx_isolation = thd_tx_isolation(current_thd);

=== modified file 'storage/innobase/handler/ha_innodb.h'
--- a/storage/innobase/handler/ha_innodb.h	2008-03-27 01:40:45 +0000
+++ b/storage/innobase/handler/ha_innodb.h	2008-10-30 13:33:14 +0000
@@ -220,6 +220,12 @@ const char* mysql_bin_log_file_name(void
  */
 ulonglong mysql_bin_log_file_pos(void);
 
+/** See if the binary log is engaged for a thread, i.e., open and
+    LOG_BIN is set.
+  @return @c true if the binlog is active, @c false otherwise.
+*/
+my_bool mysql_bin_log_is_engaged(const MYSQL_THD thd);
+
 /**
   Check if a user thread is a replication slave thread
   @param thd  user thread

Thread
bzr commit into mysql-5.1 branch (mats:2773) Bug#40360Mats Kindahl30 Oct