List:Commits« Previous MessageNext Message »
From:Luis Soares Date:March 12 2012 11:32pm
Subject:bzr push into mysql-5.1 branch (luis.soares:3704 to 3707) Bug#12400313
View as plain text  
 3707 Luis Soares	2012-03-12
      BUG#12400313
      
      Adding missing sync_slave_with_master to the test case.

    modified:
      mysql-test/suite/rpl/t/rpl_stm_relay_ign_space.test
 3706 Luis Soares	2012-03-12 [merge]
      Automerge merge with latest mysql-5.1.

    modified:
      mysql-test/suite/rpl/r/rpl_stm_relay_ign_space.result
      mysql-test/suite/rpl/t/rpl_stm_relay_ign_space.test
 3705 Luis Soares	2012-03-12 [merge]
      BUG#12400313
      
      Automerge with mysql-5.1.

    added:
      mysql-test/suite/rpl/r/rpl_stm_relay_ign_space.result
      mysql-test/suite/rpl/t/rpl_stm_relay_ign_space-slave.opt
      mysql-test/suite/rpl/t/rpl_stm_relay_ign_space.test
    modified:
      sql/log.cc
      sql/rpl_rli.h
      sql/slave.cc
 3704 Annamalai Gurusami	2012-03-09
      Bug #11766634 59783: InnoDB data grows unexpectedly when inserting,
      truncating, inserting the same set of rows. When a table is 
      re-created with the same set of rows, the data file size must
      not grow.  
      
      rb:968
      Approved by Marko. 

    added:
      mysql-test/suite/innodb/r/innodb_bug11766634.result
      mysql-test/suite/innodb/t/innodb_bug11766634.test
      mysql-test/suite/innodb_plugin/r/innodb_bug11766634.result
      mysql-test/suite/innodb_plugin/t/innodb_bug11766634.test
    modified:
      storage/innobase/fsp/fsp0fsp.c
      storage/innodb_plugin/fsp/fsp0fsp.c
=== added file 'mysql-test/suite/rpl/r/rpl_stm_relay_ign_space.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_relay_ign_space.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_relay_ign_space.result	2012-03-12 23:15:01 +0000
@@ -0,0 +1,5 @@
+include/master-slave.inc
+[connection master]
+include/assert.inc [Assert that relay log space is close to the limit]
+include/diff_tables.inc [master:test.t1,slave:test.t1]
+include/rpl_end.inc

=== added file 'mysql-test/suite/rpl/t/rpl_stm_relay_ign_space-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_stm_relay_ign_space-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_relay_ign_space-slave.opt	2012-03-12 12:28:27 +0000
@@ -0,0 +1 @@
+--relay-log-space-limit=8192 --relay-log-purge --max-relay-log-size=4096

=== added file 'mysql-test/suite/rpl/t/rpl_stm_relay_ign_space.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_relay_ign_space.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_relay_ign_space.test	2012-03-12 23:23:40 +0000
@@ -0,0 +1,101 @@
+#
+# BUG#12400313 / BUG#64503 test case
+#
+#
+# Description
+# -----------
+#  
+# This test case starts the slave server with: 
+# --relay-log-space-limit=8192 --relay-log-purge --max-relay-log-size=4096
+# 
+# Then it issues some queries that will cause the slave to reach
+# relay-log-space-limit. We lock the table so that the SQL thread is
+# not able to purge the log and then we issue some more statements.
+#
+# The purpose is to show that the IO thread will honor the limits
+# while the SQL thread is not able to purge the relay logs, which did
+# not happen before this patch. In addition we assert that while
+# ignoring the limit (SQL thread needs to rotate before purging), the
+# IO thread does not do it in an uncontrolled manner.
+
+--source include/have_binlog_format_statement.inc
+--source include/master-slave.inc
+--source include/have_innodb.inc
+
+--disable_query_log
+CREATE TABLE t1 (c1 TEXT) engine=InnoDB;
+
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx!
 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+
+--sync_slave_with_master
+
+# wait for the SQL thread to sleep
+--let $show_statement= SHOW PROCESSLIST
+--let $field= State
+--let $condition= = 'Has read all relay log; waiting for the slave I/O thread to update it'
+--source include/wait_show_condition.inc
+
+# now the io thread has set rli->ignore_space_limit
+# lets lock the table so that once the SQL thread awakes
+# it blocks there and does not set rli->ignore_space_limit
+# back to zero
+LOCK TABLE t1 WRITE;
+
+# now issue more statements that will overflow the 
+# rli->log_space_limit (in this case ~10K)
+--connection master
+
+INSERT INTO t1 VALUES ('xxxxxxxxx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 
+# space before continuing
+--let $show_statement= SHOW PROCESSLIST
+--let $field= State
+--let $condition= LIKE 'Waiting for %'
+# before the patch (IO would have transfered everything)
+#--let $condition= = 'Waiting for master to send event'
+# after the patch (now it waits for space to be freed)
+#--let $condition= = 'Waiting for the slave SQL thread to free enough relay log space'
+--source include/wait_show_condition.inc
+
+# without the patch we can uncomment the following two lines and
+# watch the IO thread synchronize with the master, thus writing 
+# relay logs way over the space limit
+#--connection master
+#--source include/sync_slave_io_with_master.inc
+
+## ASSERT that the IO thread has honored the limit+few bytes required to be able to purge
+--let $relay_log_space_while_sql_is_executing = query_get_value(SHOW SLAVE STATUS, Relay_Log_Space, 1)
+--let $relay_log_space_limit = query_get_value(SHOW VARIABLES LIKE "relay_log_space_limit", Value, 1)
+--let $assert_text= Assert that relay log space is close to the limit
+--let $assert_cond= $relay_log_space_while_sql_is_executing <= $relay_log_space_limit * 1.15
+--source include/assert.inc
+
+# unlock the table and let SQL thread continue applying events
+UNLOCK TABLES;
+
+--connection master
+--sync_slave_with_master
+--let $diff_tables=master:test.t1,slave:test.t1
+--source include/diff_tables.inc
+
+--connection master
+DROP TABLE t1;
+--enable_query_log
+--sync_slave_with_master
+
+--source include/rpl_end.inc

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2011-11-29 14:52:47 +0000
+++ b/sql/log.cc	2012-03-12 12:28:27 +0000
@@ -3194,8 +3194,6 @@ int MYSQL_BIN_LOG::purge_first_log(Relay
   pthread_mutex_lock(&rli->log_space_lock);
   rli->relay_log.purge_logs(to_purge_if_included, included,
                             0, 0, &rli->log_space_total);
-  // Tell the I/O thread to take the relay_log_space_limit into account
-  rli->ignore_log_space_limit= 0;
   pthread_mutex_unlock(&rli->log_space_lock);
 
   /*

=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2012-02-15 16:21:38 +0000
+++ b/sql/rpl_rli.h	2012-03-12 12:28:27 +0000
@@ -190,6 +190,13 @@ public:
   bool ignore_log_space_limit;
 
   /*
+    Used by the SQL thread to instructs the IO thread to rotate 
+    the logs when the SQL thread needs to purge to release some
+    disk space.
+   */
+  bool sql_force_rotate_relay;
+
+  /*
     When it commits, InnoDB internally stores the master log position it has
     processed so far; the position to store is the one of the end of the
     committing event (the COMMIT query event, or the event if in autocommit

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2011-08-26 09:57:29 +0000
+++ b/sql/slave.cc	2012-03-12 12:28:27 +0000
@@ -1450,6 +1450,54 @@ Waiting for the slave SQL thread to free
          !(slave_killed=io_slave_killed(thd,mi)) &&
          !rli->ignore_log_space_limit)
     pthread_cond_wait(&rli->log_space_cond, &rli->log_space_lock);
+
+  /* 
+    Makes the IO thread read only one event at a time
+    until the SQL thread is able to purge the relay 
+    logs, freeing some space.
+
+    Therefore, once the SQL thread processes this next 
+    event, it goes to sleep (no more events in the queue),
+    sets ignore_log_space_limit=true and wakes the IO thread. 
+    However, this event may have been enough already for 
+    the SQL thread to purge some log files, freeing 
+    rli->log_space_total .
+
+    This guarantees that the SQL and IO thread move
+    forward only one event at a time (to avoid deadlocks), 
+    when the relay space limit is reached. It also 
+    guarantees that when the SQL thread is prepared to
+    rotate (to be able to purge some logs), the IO thread
+    will know about it and will rotate.
+
+    NOTE: The ignore_log_space_limit is only set when the SQL
+          thread sleeps waiting for events.
+
+   */
+  if (rli->ignore_log_space_limit)
+  {
+#ifndef DBUG_OFF
+    {
+      char llbuf1[22], llbuf2[22];
+      DBUG_PRINT("info", ("log_space_limit=%s "
+                          "log_space_total=%s "
+                          "ignore_log_space_limit=%d "
+                          "sql_force_rotate_relay=%d", 
+                        llstr(rli->log_space_limit,llbuf1),
+                        llstr(rli->log_space_total,llbuf2),
+                        (int) rli->ignore_log_space_limit,
+                        (int) rli->sql_force_rotate_relay));
+    }
+#endif
+    if (rli->sql_force_rotate_relay)
+    {
+      rotate_relay_log(rli->mi);
+      rli->sql_force_rotate_relay= false;
+    }
+
+    rli->ignore_log_space_limit= false;
+  }
+
   thd->exit_cond(save_proc_info);
   DBUG_RETURN(slave_killed);
 }
@@ -4260,19 +4308,45 @@ static Log_event* next_event(Relay_log_i
           constraint, because we do not want the I/O thread to block because of
           space (it's ok if it blocks for any other reason (e.g. because the
           master does not send anything). Then the I/O thread stops waiting
-          and reads more events.
-          The SQL thread decides when the I/O thread should take log_space_limit
-          into account again : ignore_log_space_limit is reset to 0
-          in purge_first_log (when the SQL thread purges the just-read relay
-          log), and also when the SQL thread starts. We should also reset
-          ignore_log_space_limit to 0 when the user does RESET SLAVE, but in
-          fact, no need as RESET SLAVE requires that the slave
+          and reads one more event and starts honoring log_space_limit again.
+
+          If the SQL thread needs more events to be able to rotate the log (it
+          might need to finish the current group first), then it can ask for one
+          more at a time. Thus we don't outgrow the relay log indefinitely,
+          but rather in a controlled manner, until the next rotate.
+
+          When the SQL thread starts it sets ignore_log_space_limit to false. 
+          We should also reset ignore_log_space_limit to 0 when the user does 
+          RESET SLAVE, but in fact, no need as RESET SLAVE requires that the slave
           be stopped, and the SQL thread sets ignore_log_space_limit to 0 when
           it stops.
         */
         pthread_mutex_lock(&rli->log_space_lock);
-        // prevent the I/O thread from blocking next times
-        rli->ignore_log_space_limit= 1;
+
+        /* 
+          If we have reached the limit of the relay space and we
+          are going to sleep, waiting for more events:
+
+          1. If outside a group, SQL thread asks the IO thread 
+             to force a rotation so that the SQL thread purges 
+             logs next time it processes an event (thus space is
+             freed).
+
+          2. If in a group, SQL thread asks the IO thread to 
+             ignore the limit and queues yet one more event 
+             so that the SQL thread finishes the group and 
+             is are able to rotate and purge sometime soon.
+         */
+        if (rli->log_space_limit && 
+            rli->log_space_limit < rli->log_space_total)
+        {
+          /* force rotation if not in an unfinished group */
+          rli->sql_force_rotate_relay= !rli->is_in_group();
+
+          /* ask for one more event */
+          rli->ignore_log_space_limit= true;
+        }
+
         /*
           If the I/O thread is blocked, unblock it.  Ok to broadcast
           after unlock, because the mutex is only destroyed in

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1 branch (luis.soares:3704 to 3707) Bug#12400313Luis Soares13 Mar