List:Commits« Previous MessageNext Message »
From:Luis Soares Date:April 11 2012 9:56am
Subject:bzr push into mysql-trunk branch (luis.soares:3860 to 3861) Bug#13877432
View as plain text  
 3861 Luis Soares	2012-04-11 [merge]
      BUG#13877432
      
      Automerged approved bzr bundle into latest mysql-trunk.

    added:
      mysql-test/suite/binlog/r/binlog_gtid_cache.result
      mysql-test/suite/binlog/t/binlog_gtid_cache-master.opt
      mysql-test/suite/binlog/t/binlog_gtid_cache.test
    modified:
      sql/binlog.cc
 3860 Yasufumi Kinoshita	2012-04-11
      Fix for Bug#13798956 : fix for flush_neighbors behavior to flush only contiguous pages

    modified:
      storage/innobase/buf/buf0flu.cc
=== added file 'mysql-test/suite/binlog/r/binlog_gtid_cache.result'
--- a/mysql-test/suite/binlog/r/binlog_gtid_cache.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/r/binlog_gtid_cache.result	2012-03-29 16:55:06 +0000
@@ -0,0 +1 @@
+PASS

=== added file 'mysql-test/suite/binlog/t/binlog_gtid_cache-master.opt'
--- a/mysql-test/suite/binlog/t/binlog_gtid_cache-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/binlog_gtid_cache-master.opt	2012-03-29 16:55:06 +0000
@@ -0,0 +1 @@
+--gtid-mode=on --disable-gtid-unsafe-statements --log-slave-updates --debug=d,+allow_gtid_unsafe_non_transactional_updates

=== added file 'mysql-test/suite/binlog/t/binlog_gtid_cache.test'
--- a/mysql-test/suite/binlog/t/binlog_gtid_cache.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/binlog_gtid_cache.test	2012-03-29 16:55:06 +0000
@@ -0,0 +1,28 @@
+--source include/have_gtid.inc
+--source include/have_debug.inc
+--source include/have_binlog_format_row.inc
+
+#
+# Test case for BUG#13738296
+#
+#
+
+--disable_result_log
+--disable_query_log
+CREATE TABLE t (a VARCHAR(1000000)) ENGINE = InnoDB;
+BEGIN;
+ INSERT INTO t VALUES (REPEAT('a', 20000));
+ SAVEPOINT sp;
+ INSERT INTO t VALUES (REPEAT('a', 20000));
+ ROLLBACK TO sp;
+COMMIT;
+
+DROP TABLE t;
+
+# If the bug had not been fixed, this would result in an
+# error stating that the binlog could not be read.
+SHOW BINLOG EVENTS;
+--enable_result_log
+--enable_query_log
+
+--echo PASS

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2012-03-14 01:50:20 +0000
+++ b/sql/binlog.cc	2012-03-29 16:55:06 +0000
@@ -173,6 +173,37 @@ public:
   }
 
   /*
+    Sets the write position to point at the position given. If the
+    cache has swapped to a file, it reinitializes it, so that the
+    proper data is added to the IO_CACHE buffer. Otherwise, it just
+    does a my_b_seek.
+
+    my_b_seek will not work if the cache has swapped, that's why
+    we do this workaround.
+
+    @param[IN]  pos the new write position.
+    @param[IN]  use_reinit if the position should be reset resorting
+                to reset_io_cache (which may issue a flush_io_cache 
+                inside)
+
+    @return The previous write position.
+   */
+  my_off_t reset_write_pos(my_off_t pos, bool use_reinit)
+  {
+    DBUG_ENTER("reset_write_pos");
+    DBUG_ASSERT(cache_log.type == WRITE_CACHE);
+
+    my_off_t oldpos= get_byte_position();
+
+    if (use_reinit)
+      reinit_io_cache(&cache_log, WRITE_CACHE, pos, 0, 0);
+    else
+      my_b_seek(&cache_log, pos);
+
+    DBUG_RETURN(oldpos);
+  }
+
+  /*
     Cache to store data before copying it to the binary log.
   */
   IO_CACHE cache_log;
@@ -648,6 +679,7 @@ static int write_empty_groups_to_cache(T
 int gtid_before_write_cache(THD* thd, binlog_cache_data* cache_data)
 {
   DBUG_ENTER("gtid_before_write_cache");
+  int error= 0;
 
   if (gtid_mode == 0)
     DBUG_RETURN(0);
@@ -666,7 +698,10 @@ int gtid_before_write_cache(THD* thd, bi
     }
   }
   if (write_empty_groups_to_cache(thd, cache_data) != 0)
+  {
+    global_sid_lock.unlock();
     DBUG_RETURN(1);
+  }
 
   global_sid_lock.unlock();
 
@@ -681,21 +716,13 @@ int gtid_before_write_cache(THD* thd, bi
     DBUG_ASSERT(cached_group->spec.type != AUTOMATIC_GROUP);
     Gtid_log_event gtid_ev(thd, cache_data->is_trx_cache(),
                            &cached_group->spec);
-    my_off_t saved_position= cache_data->get_byte_position();
-    IO_CACHE *cache_log= &cache_data->cache_log;
-    flush_io_cache(cache_log);
-    reinit_io_cache(cache_log, WRITE_CACHE, 0, 0, 0);
-    if (gtid_ev.write(cache_log) != 0)
-    {
-      flush_io_cache(cache_log);
-      reinit_io_cache(cache_log, WRITE_CACHE, saved_position, 0, 0);
-      DBUG_RETURN(1);
-    }
-    flush_io_cache(cache_log);
-    reinit_io_cache(cache_log, WRITE_CACHE, saved_position, 0, 0);
+    bool using_file= cache_data->cache_log.pos_in_file > 0;
+    my_off_t saved_position= cache_data->reset_write_pos(0, using_file);
+    error= gtid_ev.write(&cache_data->cache_log);
+    cache_data->reset_write_pos(saved_position, using_file);
   }
 
-  DBUG_RETURN(0);
+  DBUG_RETURN(error);
 }
 
 /**

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (luis.soares:3860 to 3861) Bug#13877432Luis Soares11 Apr