Below is the list of changes that have just been committed into a local
5.0 repository of guilhem. When guilhem 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.1974 05/09/15 15:30:02 guilhem@stripped +5 -0
WL#1012: Fix for BUG#11729 "slave cluster database hangs" (Jeb, please test):
slave SQL thread now makes sure that tables opened by Table_map_log_event::exec_event()
do get closed before the thread dies (hang was that tables stayed open and some other
thread
was waiting for them to close). A test for this bug.
mysql-test/t/rpl_row_stop_middle.test
1.1 05/09/15 15:29:57 guilhem@stripped +44 -0
New BitKeeper file ``mysql-test/t/rpl_row_stop_middle.test''
mysql-test/r/rpl_row_stop_middle.result
1.1 05/09/15 15:29:57 guilhem@stripped +26 -0
New BitKeeper file ``mysql-test/r/rpl_row_stop_middle.result''
sql/slave.cc
1.258 05/09/15 15:29:57 guilhem@stripped +11 -0
Call Table_map_log_event::cleanup() when you have called ::exec_event() and are dying,
to be sure
tables get closed.
sql/log_event.h
1.124 05/09/15 15:29:57 guilhem@stripped +8 -0
new Table_map_log_event::cleanup(). See example usage in slave.cc
sql/log_event.cc
1.203 05/09/15 15:29:57 guilhem@stripped +17 -2
A new Table_map_log_event::cleanup(), to clean up after some
Table_map_log_event::exec_event() has been called
and has opened tables which were not closed (because slave SQL thread is told to
stop).
mysql-test/t/rpl_row_stop_middle.test
1.0 05/09/15 15:29:57 guilhem@stripped +0 -0
BitKeeper file /home/mysql_src/mysql-5.0-wl1012/mysql-test/t/rpl_row_stop_middle.test
mysql-test/r/rpl_row_stop_middle.result
1.0 05/09/15 15:29:57 guilhem@stripped +0 -0
BitKeeper file
/home/mysql_src/mysql-5.0-wl1012/mysql-test/r/rpl_row_stop_middle.result
# 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: guilhem
# Host: gbichot3.local
# Root: /home/mysql_src/mysql-5.0-wl1012
--- 1.202/sql/log_event.cc 2005-09-13 21:24:38 +02:00
+++ 1.203/sql/log_event.cc 2005-09-15 15:29:57 +02:00
@@ -5172,10 +5172,11 @@
the error should be skipped, then we would clear mappings, rollback,
close tables, but the slave SQL thread would not stop and then may
assume the mapping is still available, the tables are still open...
- To fix this we should detect skippability of error in the "if (error)"
- above, and not later. So that we don't delete needed information.
+ So then we should clear mappings/rollback/close here only if this is a
+ TRANS_END_F.
For now we code, knowing that error is not skippable and so slave SQL
thread is certainly going to stop.
+
*/
ha_autocommit_or_rollback(thd, 1);
ha_rollback(thd);
@@ -5610,6 +5611,20 @@
"`%s`.`%s` mapped to number %lu\n",
m_dbnam, m_tblnam, m_table_id);
}
+}
+#endif
+
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+void Table_map_log_event::cleanup(THD *thd)
+{
+ /*
+ Instances of Table_map_log_event, if ::exec_event() was called on them,
+ may have opened tables, which we cannot be sure have been closed (because
+ maybe the Rows_log_event have not been found or will not be, because slave
+ SQL thread is stopping, or relay log has a missing tail etc). So we close
+ all thread's tables.
+ */
+ close_thread_tables(thd);
}
#endif
--- 1.123/sql/log_event.h 2005-09-12 01:11:56 +02:00
+++ 1.124/sql/log_event.h 2005-09-15 15:29:57 +02:00
@@ -1669,6 +1669,14 @@
LAST_EVENT_INFO *last_event_info= 0);
#endif
+ /*
+ When you use ::exec_event(), you have to use ::cleanup() before exiting
+ your main function. Mats: if you have a better place for this function...
+ */
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) &&
defined(HAVE_ROW_BASED_REPLICATION)
+ static void cleanup(THD *thd);
+#endif
+
private:
#ifndef MYSQL_CLIENT
TABLE *m_table;
--- 1.257/sql/slave.cc 2005-09-09 00:13:57 +02:00
+++ 1.258/sql/slave.cc 2005-09-15 15:29:57 +02:00
@@ -3523,6 +3523,17 @@
RPL_LOG_NAME, llstr(rli->group_master_log_pos,llbuff));
err:
+
+#ifdef HAVE_ROW_BASED_REPLICATION
+ /*
+ Some events set some playgrounds, which won't be cleared because thread
+ stops. Stopping of this thread may not be known to these events ("stop"
+ request is detected only by the present function, not by events), so we
+ must "proactively" clear playgrounds:
+ */
+ Table_map_log_event::cleanup(thd);
+#endif
+
VOID(pthread_mutex_lock(&LOCK_thread_count));
/*
Some extra safety, which should not been needed (normally, event deletion
--- New file ---
+++ mysql-test/r/rpl_row_stop_middle.result 05/09/15 15:29:57
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;
stop slave;
create table t1 (a int not null auto_increment primary key, b int, key(b));
INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
start slave;
stop slave;
drop table t1;
drop table t1;
--- New file ---
+++ mysql-test/t/rpl_row_stop_middle.test 05/09/15 15:29:57
# Test for BUG#11729: see if, when STOP SLAVE occurs while the slave
# SQL thread has processed a Table_map_log_event but has not processed
# the last Rows_log_event associated to it, the slave thread does not
# forget to close its tables.
# Can be run with statement-based but no interest (and long test)
source include/have_binlog_format_row.inc;
source include/master-slave.inc;
connection slave;
stop slave;
connection master;
create table t1 (a int not null auto_increment primary key, b int, key(b));
INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
INSERT INTO t1 (a) SELECT null FROM t1;
connection slave;
start slave;
# hope one second is not enough for slave to reach the last
# Rows_log_event, so that test actually tests something.
real_sleep 1;
stop slave;
# see if slave hangs on DROP TABLE
drop table t1;
connection master; # cleanup
drop table t1;
| Thread |
|---|
| • bk commit into 5.0 tree (guilhem:1.1974) BUG#11729 | guilhem | 15 Sep |