MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Marc Alff Date:July 23 2009 4:01pm
Subject:bzr push into mysql-5.4-perfschema branch (marc.alff:2834 to 2835)
View as plain text  
 2835 Marc Alff	2009-07-23 [merge]
      Merge mysql-azalea --> mysql-azalea-perfschema
      removed:
        mysql-test/suite/rpl/r/rpl_row_stop_middle_update.result
        mysql-test/suite/rpl/t/rpl_row_stop_middle_update-master.opt
        mysql-test/suite/rpl/t/rpl_row_stop_middle_update-slave.opt
      added:
        mysql-test/suite/rpl/r/rpl_stop_middle_group.result
      renamed:
        mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test => mysql-test/suite/rpl/t/rpl_stop_middle_group.test
      modified:
        include/my_base.h
        mysql-test/extra/scripts/monitor_disabled_tests/comments.txt
        mysql-test/r/lock.result
        mysql-test/suite/rpl/r/rpl_innodb.result
        mysql-test/suite/rpl/r/rpl_semi_sync.result
        mysql-test/suite/rpl/t/disabled.def
        mysql-test/suite/rpl/t/rpl_innodb.test
        mysql-test/suite/rpl/t/rpl_semi_sync.test
        mysql-test/t/disabled.def
        mysql-test/t/lock.test
        netware/BUILD/compile-netware-START
        plugin/semisync/semisync_master.cc
        plugin/semisync/semisync_master_plugin.cc
        plugin/semisync/semisync_slave_plugin.cc
        scripts/make_binary_distribution.sh
        sql-bench/README*
        sql/derror.cc
        sql/log.cc
        sql/log_event.cc
        sql/log_event_old.cc
        sql/mysqld.cc
        sql/rpl_rli.cc
        sql/rpl_rli.h
        sql/slave.cc
        support-files/mysql.server.sh
        tests/grant.pl*
        mysql-test/suite/rpl/t/rpl_stop_middle_group.test

 2834 Marc Alff	2009-07-21
      Implemented more review comments
      modified:
        sql/item_func.cc
        sql/mysql_priv.h
        sql/mysqld.cc
        sql/sp_cache.cc
        sql/sql_class.cc
        sql/sql_plugin.cc
        sql/sql_repl.cc
        sql/sql_table.cc
        sql/tztime.cc
        storage/perfschema/ha_perfschema.cc
        storage/perfschema/pfs.cc
        storage/perfschema/pfs_engine_table.cc
        storage/perfschema/pfs_engine_table.h
        storage/perfschema/pfs_events_waits.cc
        storage/perfschema/pfs_instr.cc
        storage/perfschema/pfs_instr_class.cc
        storage/perfschema/pfs_instr_class.h
        storage/perfschema/table_events_waits.cc
        storage/perfschema/table_events_waits_summary.cc
        storage/perfschema/table_file_instances.cc
        storage/perfschema/table_file_summary.cc
        storage/perfschema/table_performance_timers.cc
        storage/perfschema/table_processlist.cc
        storage/perfschema/table_setup_consumers.cc
        storage/perfschema/table_setup_instruments.cc
        storage/perfschema/table_setup_objects.cc
        storage/perfschema/table_setup_timers.cc
        storage/perfschema/table_sync_instances.cc

=== modified file 'include/my_base.h'
--- a/include/my_base.h	2009-04-01 21:36:07 +0000
+++ b/include/my_base.h	2009-07-09 16:30:43 +0000
@@ -274,7 +274,17 @@ enum ha_base_keytype {
                          HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY | \
                          HA_RTREE_INDEX)
 
-#define HA_KEY_HAS_PART_KEY_SEG 65536   /* Key contains partial segments */
+/*
+  Key contains partial segments.
+
+  This flag is internal to the MySQL server by design. It is not supposed
+  neither to be saved in FRM-files, nor to be passed to storage engines.
+  It is intended to pass information into internal static sort_keys(KEY *,
+  KEY *) function.
+
+  This flag can be calculated -- it's based on key lengths comparison.
+*/
+#define HA_KEY_HAS_PART_KEY_SEG 65536
 
 	/* Automatic bits in key-flag */
 

=== modified file 'mysql-test/extra/scripts/monitor_disabled_tests/comments.txt'
--- a/mysql-test/extra/scripts/monitor_disabled_tests/comments.txt	2009-07-11 20:16:40 +0000
+++ b/mysql-test/extra/scripts/monitor_disabled_tests/comments.txt	2009-07-23 10:22:21 +0000
@@ -57165,6 +57165,41 @@ suite/rpl/t/rpl_row_sp012.test:# Create
 suite/rpl/t/rpl_row_sp012.test:# Need to wait for the rights to be applied at the slave
 suite/rpl/t/rpl_row_sp012.test:# Cleanup
 suite/rpl/t/rpl_row_sp012.test:# End of 5.0 test case
+suite/rpl/t/rpl_stop_middle_group.test:# Proving that stopping in the middle of applying a group of events
+suite/rpl/t/rpl_stop_middle_group.test:# does not have immediate effect if a non-transaction table has been changed.
+suite/rpl/t/rpl_stop_middle_group.test:# The slave sql thread has to try to finish applying first.
+suite/rpl/t/rpl_stop_middle_group.test:# The tests rely on simulation of the killed status.
+suite/rpl/t/rpl_stop_middle_group.test:# The matter of testing correlates to some of `rpl_start_stop_slave' that does
+suite/rpl/t/rpl_stop_middle_group.test:# not require `have_debug'.
+suite/rpl/t/rpl_stop_middle_group.test:# slave will catch the killed status but won't shut down immediately
+suite/rpl/t/rpl_stop_middle_group.test:# only after the whole group has done (commit)
+suite/rpl/t/rpl_stop_middle_group.test:# checking: no error and the group is finished
+suite/rpl/t/rpl_stop_middle_group.test:#
+suite/rpl/t/rpl_stop_middle_group.test:# bug#45940 issues around rli->last_event_start_time
+suite/rpl/t/rpl_stop_middle_group.test:# Testing of slave stopped after it had waited (in vain) for
+suite/rpl/t/rpl_stop_middle_group.test:# the group be finished.
+suite/rpl/t/rpl_stop_middle_group.test:# It could not be finished because of simulation of failure to
+suite/rpl/t/rpl_stop_middle_group.test:# receive the terminal part
+suite/rpl/t/rpl_stop_middle_group.test:# The test relay on simulation of the incomplete group in the relay log
+suite/rpl/t/rpl_stop_middle_group.test:# Two cases are verified: a mixed transacton and a mixed multi-table update.
+suite/rpl/t/rpl_stop_middle_group.test:#
+suite/rpl/t/rpl_stop_middle_group.test:# The mixed transacton.
+suite/rpl/t/rpl_stop_middle_group.test:#
+suite/rpl/t/rpl_stop_middle_group.test:#connection slave;
+suite/rpl/t/rpl_stop_middle_group.test:# slave will catch the killed status, won't shut down immediately
+suite/rpl/t/rpl_stop_middle_group.test:# but does it eventually having the whole group unfinished (not committed)
+suite/rpl/t/rpl_stop_middle_group.test:# checking: the error and group unfinished
+suite/rpl/t/rpl_stop_middle_group.test:#
+suite/rpl/t/rpl_stop_middle_group.test:# The mixed multi-table update
+suite/rpl/t/rpl_stop_middle_group.test:#
+suite/rpl/t/rpl_stop_middle_group.test:#connection slave;
+suite/rpl/t/rpl_stop_middle_group.test:# slave will catch the killed status, won't shut down immediately
+suite/rpl/t/rpl_stop_middle_group.test:# but does it eventually having the whole group unfinished (not committed)
+suite/rpl/t/rpl_stop_middle_group.test:# 
+suite/rpl/t/rpl_stop_middle_group.test:# checking: the error and group unfinished 
+suite/rpl/t/rpl_stop_middle_group.test:#
+suite/rpl/t/rpl_stop_middle_group.test:# clean-up
+suite/rpl/t/rpl_stop_middle_group.test:#
 suite/rpl/t/rpl_variables.test:# ==== Purpose ====
 suite/rpl/t/rpl_variables.test:#
 suite/rpl/t/rpl_variables.test:# Test that queries referencing variables are replicated correctly in
@@ -57815,6 +57850,7 @@ suite/rpl/t/rpl_innodb.test:# stay in t1
 suite/rpl/t/rpl_innodb.test:# Must return no rows here
 suite/rpl/t/rpl_innodb.test:# Must return no rows here
 suite/rpl/t/rpl_innodb.test:# t1 has two rows here: the transaction not rolled back since t1 uses MyISAM
+suite/rpl/t/rpl_innodb.test:# Need to wait until RENAME is received
 suite/rpl/t/rpl_stm_log.test:# Requires statement logging
 suite/rpl/t/rpl_stm_log.test:# -- [DISABLED Bug#45238]
 suite/rpl/t/rpl_stm_log.test:# End of 4.1 tests
@@ -58712,6 +58748,16 @@ suite/rpl/t/rpl_backup_shutdown.test:# r
 suite/rpl/t/rpl_backup_shutdown.test:# Stop master server
 suite/rpl/t/rpl_backup_shutdown.test:# Clean up section
 suite/rpl/t/rpl_semi_sync.test:#let $engine_type= MyISAM;
+suite/rpl/t/rpl_semi_sync.test:# BUG#45672 When semi-sync is enabled on master, it would allocate
+suite/rpl/t/rpl_semi_sync.test:# transaction node even without semi-sync slave connected, and would
+suite/rpl/t/rpl_semi_sync.test:# finally result in transaction node allocation error.
+suite/rpl/t/rpl_semi_sync.test:#
+suite/rpl/t/rpl_semi_sync.test:# Semi-sync master will pre-allocate 'max_connections' transaction
+suite/rpl/t/rpl_semi_sync.test:# nodes, so here we do more than that much transactions to check if it
+suite/rpl/t/rpl_semi_sync.test:# will fail or not.
+suite/rpl/t/rpl_semi_sync.test:# select @@global.max_connections + 1;
+suite/rpl/t/rpl_semi_sync.test:# BUG#45673
+suite/rpl/t/rpl_semi_sync.test:# reset master to make sure the following test will start with a clean environment
 suite/rpl/t/rpl_semi_sync.test:# NOTE: Rpl_semi_sync_master_client will only be updated when
 suite/rpl/t/rpl_semi_sync.test:# semi-sync slave has started binlog dump request
 suite/rpl/t/rpl_semi_sync.test:# The first semi-sync check should be on because after slave stop,
@@ -58721,8 +58767,20 @@ suite/rpl/t/rpl_semi_sync.test:# times o
 suite/rpl/t/rpl_semi_sync.test:# Save the master position for later use.
 suite/rpl/t/rpl_semi_sync.test:# The third semi-sync check should be on again.
 suite/rpl/t/rpl_semi_sync.test:##show status like 'Rpl_semi_sync_master_status';
+suite/rpl/t/rpl_semi_sync.test:# Kill the dump thread on master for previous slave connection and
+suite/rpl/t/rpl_semi_sync.test:# wait for it to exit
+suite/rpl/t/rpl_semi_sync.test:  # After dump thread exit, Rpl_semi_sync_master_clients will be 0
+suite/rpl/t/rpl_semi_sync.test:# Wait for dump thread to start, Rpl_semi_sync_master_clients will be
+suite/rpl/t/rpl_semi_sync.test:# 1 after dump thread started.
+suite/rpl/t/rpl_semi_sync.test:# Kill the dump thread on master for previous slave connection and wait for it to exit
+suite/rpl/t/rpl_semi_sync.test:  # After dump thread exit, Rpl_semi_sync_master_clients will be 0
 suite/rpl/t/rpl_semi_sync.test:# Do not binlog the following statement because it will generate
 suite/rpl/t/rpl_semi_sync.test:# different events for ROW and STATEMENT format
+suite/rpl/t/rpl_semi_sync.test:# Wait for the semi-sync binlog dump thread to start
+suite/rpl/t/rpl_semi_sync.test:# Disable semi-sync on master
+suite/rpl/t/rpl_semi_sync.test:# Kill the dump thread on master for previous slave connection and wait for it to exit
+suite/rpl/t/rpl_semi_sync.test:  # After dump thread exit, Rpl_semi_sync_master_clients will be 0
+suite/rpl/t/rpl_semi_sync.test:# Uninstall semi-sync plugin on master
 suite/rpl/t/rpl000013.test:# This test is to verify that DROP TEMPORARY TABLE
 suite/rpl/t/rpl000013.test:# is automatically binlogged and sent to slave
 suite/rpl/t/rpl000013.test:# when a temp table is dropped by disconnection
@@ -59202,14 +59260,6 @@ suite/rpl/t/rpl_log_pos.test:#
 suite/rpl/t/rpl_log_pos.test:# Testing of setting slave to wrong log position with master_log_pos
 suite/rpl/t/rpl_log_pos.test:#
 suite/rpl/t/rpl_log_pos.test:# Passes with rbr no problem, removed statement include [jbm]
-suite/rpl/t/rpl_row_stop_middle_update.test:# master is asked to create small Rows events: if only one event is
-suite/rpl/t/rpl_row_stop_middle_update.test:# created, stopping slave at the end of that one will show no bug, we
-suite/rpl/t/rpl_row_stop_middle_update.test:# need at least two (and stop after first); in this test we use three.
-suite/rpl/t/rpl_row_stop_middle_update.test:# slave will automatically stop the sql thread thanks to the .opt
-suite/rpl/t/rpl_row_stop_middle_update.test:# file; it will initiate the stop request after the first
-suite/rpl/t/rpl_row_stop_middle_update.test:# Rows_log_event (out of 3) but should wait until the last one is
-suite/rpl/t/rpl_row_stop_middle_update.test:# executed before stopping.
-suite/rpl/t/rpl_row_stop_middle_update.test:# check that we inserted all rows (waited until the last Rows event)
 suite/rpl/t/rpl_auto_increment.test:#####################################
 suite/rpl/t/rpl_auto_increment.test:# Wrapper for rpl_auto_increment.test#
 suite/rpl/t/rpl_auto_increment.test:#####################################

=== modified file 'mysql-test/r/lock.result'
--- a/mysql-test/r/lock.result	2009-03-27 22:06:26 +0000
+++ b/mysql-test/r/lock.result	2009-07-02 14:24:05 +0000
@@ -282,5 +282,27 @@ insert into t1 values (1);
 # Ensure that metadata locks held by the transaction are released.
 drop table t1;
 #
+# Bug#45066 FLUSH TABLES WITH READ LOCK deadlocks against 
+#           LOCK TABLE 
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a INT);
+LOCK TABLE t1 READ;
+FLUSH TABLES;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+LOCK TABLE t1 WRITE;
+FLUSH TABLES;
+#
+# If you allow the next combination, you reintroduce bug Bug#45066
+# 
+LOCK TABLE t1 READ;
+FLUSH TABLES WITH READ LOCK;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+LOCK TABLE t1 WRITE;
+FLUSH TABLES WITH READ LOCK;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+UNLOCK TABLES;
+DROP TABLE t1;
+#
 # End of 6.0 tests.
 #

=== modified file 'mysql-test/suite/rpl/r/rpl_innodb.result'
--- a/mysql-test/suite/rpl/r/rpl_innodb.result	2008-10-29 13:25:03 +0000
+++ b/mysql-test/suite/rpl/r/rpl_innodb.result	2009-07-02 09:40:40 +0000
@@ -82,3 +82,48 @@ FLUSH LOGS;
 FLUSH LOGS;
 DROP DATABASE mysqltest1;
 End of 5.1 tests
+#
+# Bug#39675 rename tables on innodb tables with pending 
+# transactions causes slave data issue.
+#
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+CREATE TABLE t1 (
+id INT PRIMARY KEY auto_increment,
+b INT DEFAULT NULL
+) ENGINE=InnoDB;
+CREATE TABLE t2 (
+id INT PRIMARY KEY auto_increment,
+b INT DEFAULT NULL
+) ENGINE=InnoDB;
+INSERT INTO t1 (b) VALUES (1),(2),(3);
+BEGIN;
+INSERT INTO t1(b) VALUES (4);
+-------- switch to master1 --------
+RENAME TABLE t1 TO t3, t2 TO t1;;
+-------- switch to master --------
+COMMIT;
+-------- switch to master1 --------
+-------- switch to master --------
+SELECT * FROM t1;
+id	b
+SELECT * FROM t3;
+id	b
+1	1
+2	2
+3	3
+4	4
+-------- switch to slave --------
+SELECT * FROM t1;
+id	b
+SELECT * FROM t3;
+id	b
+1	1
+2	2
+3	3
+4	4
+-------- switch to master --------
+DROP TABLE t1;
+DROP TABLE t3;
+End of 6.0 tests

=== removed file 'mysql-test/suite/rpl/r/rpl_row_stop_middle_update.result'
--- a/mysql-test/suite/rpl/r/rpl_row_stop_middle_update.result	2008-07-10 16:09:39 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_stop_middle_update.result	1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-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;
-create table t1 (words varchar(20)) engine=myisam;
-load data infile '../../std_data/words.dat' into table t1 (words);
-select count(*) from t1;
-count(*)
-70
-select count(*) from t1;
-count(*)
-70
-drop table t1;
-include/stop_slave.inc
-drop table t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_semi_sync.result'
--- a/mysql-test/suite/rpl/r/rpl_semi_sync.result	2009-06-17 10:37:04 +0000
+++ b/mysql-test/suite/rpl/r/rpl_semi_sync.result	2009-07-07 02:44:17 +0000
@@ -29,6 +29,33 @@ set global rpl_semi_sync_master_enabled
 show variables like 'rpl_semi_sync_master_enabled';
 Variable_name	Value
 rpl_semi_sync_master_enabled	ON
+[ status of semi-sync on master should be OFF without any semi-sync slaves ]
+show status like 'Rpl_semi_sync_master_clients';
+Variable_name	Value
+Rpl_semi_sync_master_clients	0
+show status like 'Rpl_semi_sync_master_status';
+Variable_name	Value
+Rpl_semi_sync_master_status	OFF
+show status like 'Rpl_semi_sync_master_yes_tx';
+Variable_name	Value
+Rpl_semi_sync_master_yes_tx	0
+#
+# BUG#45672 Semisync repl: ActiveTranx:insert_tranx_node: transaction node allocation failed
+# BUG#45673 Semisynch reports correct operation even if no slave is connected
+#
+[ status of semi-sync on master should be OFF ]
+show status like 'Rpl_semi_sync_master_clients';
+Variable_name	Value
+Rpl_semi_sync_master_clients	0
+show status like 'Rpl_semi_sync_master_status';
+Variable_name	Value
+Rpl_semi_sync_master_status	OFF
+show status like 'Rpl_semi_sync_master_yes_tx';
+Variable_name	Value
+Rpl_semi_sync_master_yes_tx	0
+#
+# INSTALL PLUGIN semi-sync on slave
+#
 [ on slave ]
 [ default state of semi-sync on slave should be OFF ]
 show variables like 'rpl_semi_sync_slave_enabled';
@@ -213,6 +240,7 @@ a
 2
 3
 [ on master ]
+[ master semi-sync status should be ON ]
 show status like 'Rpl_semi_sync_master_status';
 Variable_name	Value
 Rpl_semi_sync_master_status	ON
@@ -225,10 +253,10 @@ Rpl_semi_sync_master_yes_tx	3
 #
 # Start semi-sync replication without SUPER privilege
 #
-reset master;
 include/stop_slave.inc
 reset slave;
 [ on master ]
+reset master;
 set sql_log_bin=0;
 grant replication slave on *.* to rpl@stripped identified by 'rpl';
 flush privileges;
@@ -238,7 +266,14 @@ grant replication slave on *.* to rpl@12
 flush privileges;
 change master to master_user='rpl',master_password='rpl';
 include/start_slave.inc
+show status like 'Rpl_semi_sync_slave_status';
+Variable_name	Value
+Rpl_semi_sync_slave_status	ON
 [ on master ]
+[ master semi-sync should be ON ]
+show status like 'Rpl_semi_sync_master_clients';
+Variable_name	Value
+Rpl_semi_sync_master_clients	1
 show status like 'Rpl_semi_sync_master_status';
 Variable_name	Value
 Rpl_semi_sync_master_status	ON
@@ -250,6 +285,10 @@ Variable_name	Value
 Rpl_semi_sync_master_yes_tx	0
 insert into t1 values (4);
 insert into t1 values (5);
+[ master semi-sync should be ON ]
+show status like 'Rpl_semi_sync_master_clients';
+Variable_name	Value
+Rpl_semi_sync_master_clients	1
 show status like 'Rpl_semi_sync_master_status';
 Variable_name	Value
 Rpl_semi_sync_master_status	ON
@@ -268,6 +307,34 @@ SHOW STATUS LIKE 'Rpl_semi_sync_slave_st
 Variable_name	Value
 Rpl_semi_sync_slave_status	OFF
 [ on master ]
+[ Semi-sync status on master should be ON ]
+show status like 'Rpl_semi_sync_master_clients';
+Variable_name	Value
+Rpl_semi_sync_master_clients	0
+show status like 'Rpl_semi_sync_master_status';
+Variable_name	Value
+Rpl_semi_sync_master_status	OFF
+set global rpl_semi_sync_master_enabled= 0;
+[ on slave ]
+SHOW VARIABLES LIKE 'rpl_semi_sync_slave_enabled';
+Variable_name	Value
+rpl_semi_sync_slave_enabled	ON
+include/start_slave.inc
+[ on master ]
+insert into t1 values (8);
+[ master semi-sync clients should be 0, status should be OFF ]
+show status like 'Rpl_semi_sync_master_clients';
+Variable_name	Value
+Rpl_semi_sync_master_clients	0
+show status like 'Rpl_semi_sync_master_status';
+Variable_name	Value
+Rpl_semi_sync_master_status	OFF
+[ on slave ]
+show status like 'Rpl_semi_sync_slave_status';
+Variable_name	Value
+Rpl_semi_sync_slave_status	OFF
+include/stop_slave.inc
+[ on master ]
 set sql_log_bin=0;
 UNINSTALL PLUGIN rpl_semi_sync_master;
 set sql_log_bin=1;

=== added file 'mysql-test/suite/rpl/r/rpl_stop_middle_group.result'
--- a/mysql-test/suite/rpl/r/rpl_stop_middle_group.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stop_middle_group.result	2009-07-08 12:34:52 +0000
@@ -0,0 +1,61 @@
+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;
+create table tm (a int auto_increment primary key) engine=myisam;
+create table ti (a int auto_increment primary key) engine=innodb;
+set @@global.debug="+d,stop_slave_middle_group";
+begin;
+insert into ti set a=null;
+insert into tm set a=null;
+commit;
+SELECT "NO" AS Last_SQL_Error, @check as `true`;
+Last_SQL_Error	true
+NO	1
+select count(*) as one from tm;
+one
+1
+select count(*) as one from ti;
+one
+1
+set @@global.debug="-d";
+include/start_slave.inc
+truncate table tm;
+truncate table ti;
+set @@global.debug="+d,stop_slave_middle_group";
+set @@global.debug="+d,incomplete_group_in_relay_log";
+begin;
+insert into ti set a=null;
+insert into tm set a=null;
+commit;
+SELECT "Fatal error: ... The slave SQL is stopped, leaving the current group of events unfinished with a non-transaction table changed. If the group consists solely of Row-based events, you can try restarting the slave with --slave-exec-mode=IDEMPOTENT, which ignores duplicate key, key not found, and similar errors (see documentation for details)." AS Last_SQL_Error, @check as `true`;
+Last_SQL_Error	true
+Fatal error: ... The slave SQL is stopped, leaving the current group of events unfinished with a non-transaction table changed. If the group consists solely of Row-based events, you can try restarting the slave with --slave-exec-mode=IDEMPOTENT, which ignores duplicate key, key not found, and similar errors (see documentation for details).	1
+select count(*) as one  from tm;
+one
+1
+select count(*) as zero from ti;
+zero
+0
+set @@global.debug="-d";
+stop slave;
+truncate table tm;
+include/start_slave.inc
+set @@global.debug="+d,stop_slave_middle_group";
+set @@global.debug="+d,incomplete_group_in_relay_log";
+update tm as t1, ti as t2 set t1.a=t1.a * 2, t2.a=t2.a * 2;
+SELECT "Fatal error: ... The slave SQL is stopped, leaving the current group of events unfinished with a non-transaction table changed. If the group consists solely of Row-based events, you can try restarting the slave with --slave-exec-mode=IDEMPOTENT, which ignores duplicate key, key not found, and similar errors (see documentation for details)." AS Last_SQL_Error, @check as `true`;
+Last_SQL_Error	true
+Fatal error: ... The slave SQL is stopped, leaving the current group of events unfinished with a non-transaction table changed. If the group consists solely of Row-based events, you can try restarting the slave with --slave-exec-mode=IDEMPOTENT, which ignores duplicate key, key not found, and similar errors (see documentation for details).	1
+select max(a) as two from tm;
+two
+2
+select max(a) as one from ti;
+one
+1
+set @@global.debug="-d";
+drop table tm, ti;
+include/stop_slave.inc
+drop table tm, ti;

=== modified file 'mysql-test/suite/rpl/t/disabled.def'
--- a/mysql-test/suite/rpl/t/disabled.def	2009-07-06 22:29:09 +0000
+++ b/mysql-test/suite/rpl/t/disabled.def	2009-07-23 10:22:21 +0000
@@ -17,5 +17,5 @@ rpl_heartbeat_basic        : Bug#43828 S
 rpl_heartbeat_2slaves      : Bug#43828 Sporadic failures (Serge.Kozlov@stripped)
 rpl_failed_optimize        : WL#4284: Can't optimize table used by a pending transaction (there is metadata lock on the table).
 rpl_read_only              : WL#4284: Setting Read only won't succeed until all metadata locks are released.
-rpl_init_slave         : Bug#44920 2009-07006 pcrews MTR2 is not processing master.opt input properly on Windows.  *Must be done this way due to the nature of the bug*
+rpl_init_slave             : Bug#43005
 

=== modified file 'mysql-test/suite/rpl/t/rpl_innodb.test'
--- a/mysql-test/suite/rpl/t/rpl_innodb.test	2008-10-29 13:25:03 +0000
+++ b/mysql-test/suite/rpl/t/rpl_innodb.test	2009-07-02 09:40:40 +0000
@@ -120,6 +120,71 @@ connection master;
 FLUSH LOGS;
 
 DROP DATABASE mysqltest1;
--- source include/master-slave-end.inc
 
 --echo End of 5.1 tests
+
+--echo #
+--echo # Bug#39675 rename tables on innodb tables with pending 
+--echo # transactions causes slave data issue.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+--enable_warnings
+
+CREATE TABLE t1 (
+  id INT PRIMARY KEY auto_increment,
+  b INT DEFAULT NULL
+) ENGINE=InnoDB;
+
+CREATE TABLE t2 (
+  id INT PRIMARY KEY auto_increment,
+  b INT DEFAULT NULL
+) ENGINE=InnoDB;
+
+INSERT INTO t1 (b) VALUES (1),(2),(3);
+
+BEGIN;
+INSERT INTO t1(b) VALUES (4);
+
+--echo -------- switch to master1 --------
+connection master1;
+--send RENAME TABLE t1 TO t3, t2 TO t1;
+
+--echo -------- switch to master --------
+connection master;
+# Need to wait until RENAME is received
+let $wait_condition=
+  SELECT COUNT(*) = 1 FROM information_schema.processlist
+  WHERE info = "RENAME TABLE t1 TO t3, t2 TO t1" and
+  state = "Waiting for table";
+--source include/wait_condition.inc
+
+COMMIT;
+
+--echo -------- switch to master1 --------
+connection master1;
+--reap
+
+--echo -------- switch to master --------
+connection master;
+SELECT * FROM t1;
+SELECT * FROM t3;
+
+sync_slave_with_master;
+
+--echo -------- switch to slave --------
+connection slave;
+SELECT * FROM t1;
+SELECT * FROM t3;
+
+--echo -------- switch to master --------
+connection master;
+DROP TABLE t1;
+DROP TABLE t3;
+
+--echo End of 6.0 tests
+
+--source include/master-slave-end.inc

=== removed file 'mysql-test/suite/rpl/t/rpl_row_stop_middle_update-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_row_stop_middle_update-master.opt	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_stop_middle_update-master.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---loose-binlog-row-event-max-size=256

=== removed file 'mysql-test/suite/rpl/t/rpl_row_stop_middle_update-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_row_stop_middle_update-slave.opt	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_stop_middle_update-slave.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---loose-debug=d,STOP_SLAVE_after_first_Rows_event

=== modified file 'mysql-test/suite/rpl/t/rpl_semi_sync.test'
--- a/mysql-test/suite/rpl/t/rpl_semi_sync.test	2009-06-17 10:37:04 +0000
+++ b/mysql-test/suite/rpl/t/rpl_semi_sync.test	2009-07-07 02:44:17 +0000
@@ -58,6 +58,50 @@ echo [ enable semi-sync on master ];
 set global rpl_semi_sync_master_enabled = 1;
 show variables like 'rpl_semi_sync_master_enabled';
 
+echo [ status of semi-sync on master should be OFF without any semi-sync slaves ];
+show status like 'Rpl_semi_sync_master_clients';
+show status like 'Rpl_semi_sync_master_status';
+show status like 'Rpl_semi_sync_master_yes_tx';
+
+--echo #
+--echo # BUG#45672 Semisync repl: ActiveTranx:insert_tranx_node: transaction node allocation failed
+--echo # BUG#45673 Semisynch reports correct operation even if no slave is connected
+--echo #
+
+# BUG#45672 When semi-sync is enabled on master, it would allocate
+# transaction node even without semi-sync slave connected, and would
+# finally result in transaction node allocation error.
+#
+# Semi-sync master will pre-allocate 'max_connections' transaction
+# nodes, so here we do more than that much transactions to check if it
+# will fail or not.
+# select @@global.max_connections + 1;
+let $i= `select @@global.max_connections + 1`;
+disable_query_log;
+eval create table t1 (a int) engine=$engine_type;
+while ($i)
+{
+  eval insert into t1 values ($i);
+  dec $i;
+}
+drop table t1;
+enable_query_log;
+
+# BUG#45673
+echo [ status of semi-sync on master should be OFF ];
+show status like 'Rpl_semi_sync_master_clients';
+show status like 'Rpl_semi_sync_master_status';
+show status like 'Rpl_semi_sync_master_yes_tx';
+
+disable_query_log;
+# reset master to make sure the following test will start with a clean environment
+reset master;
+enable_query_log;
+
+--echo #
+--echo # INSTALL PLUGIN semi-sync on slave
+--echo #
+
 connection slave;
 echo [ on slave ];
 
@@ -237,11 +281,35 @@ echo [ on slave ];
 
 source include/stop_slave.inc;
 reset slave;
+
+# Kill the dump thread on master for previous slave connection and
+# wait for it to exit
+connection master;
+let $_tid= `select id from information_schema.processlist where command = 'Binlog Dump' limit 1`;
+if ($_tid)
+{
+  disable_query_log;
+  eval kill query $_tid;
+  enable_query_log;
+
+  # After dump thread exit, Rpl_semi_sync_master_clients will be 0
+  let $status_var= Rpl_semi_sync_master_clients;
+  let $status_var_value= 0;
+  source include/wait_for_status_var.inc;
+}
+
+connection slave;
 source include/start_slave.inc;
 
 connection master;
 echo [ on master ];
 
+# Wait for dump thread to start, Rpl_semi_sync_master_clients will be
+# 1 after dump thread started.
+let $status_var= Rpl_semi_sync_master_clients;
+let $status_var_value= 1;
+source include/wait_for_status_var.inc;
+
 replace_result $engine_type ENGINE_TYPE;
 eval create table t1 (a int) engine = $engine_type;
 insert into t1 values (1);
@@ -255,6 +323,7 @@ select * from t1;
 connection master;
 echo [ on master ];
 
+echo [ master semi-sync status should be ON ];
 show status like 'Rpl_semi_sync_master_status';
 show status like 'Rpl_semi_sync_master_no_tx';
 show status like 'Rpl_semi_sync_master_yes_tx';
@@ -262,13 +331,27 @@ show status like 'Rpl_semi_sync_master_y
 --echo #
 --echo # Start semi-sync replication without SUPER privilege
 --echo #
-connection master;
-reset master;
-sync_slave_with_master;
+connection slave;
 source include/stop_slave.inc;
 reset slave;
 connection master;
 echo [ on master ];
+reset master;
+
+# Kill the dump thread on master for previous slave connection and wait for it to exit
+let $_tid= `select id from information_schema.processlist where command = 'Binlog Dump' limit 1`;
+if ($_tid)
+{
+  disable_query_log;
+  eval kill query $_tid;
+  enable_query_log;
+
+  # After dump thread exit, Rpl_semi_sync_master_clients will be 0
+  let $status_var= Rpl_semi_sync_master_clients;
+  let $status_var_value= 0;
+  source include/wait_for_status_var.inc;
+}
+
 # Do not binlog the following statement because it will generate
 # different events for ROW and STATEMENT format
 set sql_log_bin=0;
@@ -281,13 +364,23 @@ grant replication slave on *.* to rpl@12
 flush privileges;
 change master to master_user='rpl',master_password='rpl';
 source include/start_slave.inc;
+show status like 'Rpl_semi_sync_slave_status';
 connection master;
 echo [ on master ];
+
+# Wait for the semi-sync binlog dump thread to start
+let $status_var= Rpl_semi_sync_master_clients;
+let $status_var_value= 1;
+source include/wait_for_status_var.inc;
+echo [ master semi-sync should be ON ];
+show status like 'Rpl_semi_sync_master_clients';
 show status like 'Rpl_semi_sync_master_status';
 show status like 'Rpl_semi_sync_master_no_tx';
 show status like 'Rpl_semi_sync_master_yes_tx';
 insert into t1 values (4);
 insert into t1 values (5);
+echo [ master semi-sync should be ON ];
+show status like 'Rpl_semi_sync_master_clients';
 show status like 'Rpl_semi_sync_master_status';
 show status like 'Rpl_semi_sync_master_no_tx';
 show status like 'Rpl_semi_sync_master_yes_tx';
@@ -296,6 +389,7 @@ show status like 'Rpl_semi_sync_master_y
 --echo # Test semi-sync slave connect to non-semi-sync master
 --echo #
 
+# Disable semi-sync on master
 connection slave;
 echo [ on slave ];
 source include/stop_slave.inc;
@@ -303,6 +397,45 @@ SHOW STATUS LIKE 'Rpl_semi_sync_slave_st
 
 connection master;
 echo [ on master ];
+
+# Kill the dump thread on master for previous slave connection and wait for it to exit
+let $_tid= `select id from information_schema.processlist where command = 'Binlog Dump' limit 1`;
+if ($_tid)
+{
+  disable_query_log;
+  eval kill query $_tid;
+  enable_query_log;
+
+  # After dump thread exit, Rpl_semi_sync_master_clients will be 0
+  let $status_var= Rpl_semi_sync_master_clients;
+  let $status_var_value= 0;
+  source include/wait_for_status_var.inc;
+}
+
+echo [ Semi-sync status on master should be ON ];
+show status like 'Rpl_semi_sync_master_clients';
+show status like 'Rpl_semi_sync_master_status';
+set global rpl_semi_sync_master_enabled= 0;
+
+connection slave;
+echo [ on slave ];
+SHOW VARIABLES LIKE 'rpl_semi_sync_slave_enabled';
+source include/start_slave.inc;
+connection master;
+echo [ on master ];
+insert into t1 values (8);
+echo [ master semi-sync clients should be 0, status should be OFF ];
+show status like 'Rpl_semi_sync_master_clients';
+show status like 'Rpl_semi_sync_master_status';
+sync_slave_with_master;
+echo [ on slave ];
+show status like 'Rpl_semi_sync_slave_status';
+
+# Uninstall semi-sync plugin on master
+connection slave;
+source include/stop_slave.inc;
+connection master;
+echo [ on master ];
 set sql_log_bin=0;
 UNINSTALL PLUGIN rpl_semi_sync_master;
 set sql_log_bin=1;

=== renamed file 'mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test' => 'mysql-test/suite/rpl/t/rpl_stop_middle_group.test'
--- a/mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test	2008-08-04 14:30:50 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stop_middle_group.test	2009-07-08 12:34:52 +0000
@@ -1,32 +1,149 @@
--- source include/have_binlog_format_row.inc
 -- source include/have_debug.inc
 -- source include/master-slave.inc
+-- source include/have_innodb.inc
 
-# master is asked to create small Rows events: if only one event is
-# created, stopping slave at the end of that one will show no bug, we
-# need at least two (and stop after first); in this test we use three.
+# Proving that stopping in the middle of applying a group of events
+# does not have immediate effect if a non-transaction table has been changed.
+# The slave sql thread has to try to finish applying first.
+# The tests rely on simulation of the killed status.
+# The matter of testing correlates to some of `rpl_start_stop_slave' that does
+# not require `have_debug'.
 
 connection master;
-create table t1 (words varchar(20)) engine=myisam;
 
-load data infile '../../std_data/words.dat' into table t1 (words);
-select count(*) from t1;
-save_master_pos;
+create table tm (a int auto_increment primary key) engine=myisam;
+create table ti (a int auto_increment primary key) engine=innodb;
+
+sync_slave_with_master;
+set @@global.debug="+d,stop_slave_middle_group";
+
+connection master;
+
+begin;
+insert into ti set a=null;
+insert into tm set a=null; # to simulate killed status on the slave 
+commit;
 
 connection slave;
 
-# slave will automatically stop the sql thread thanks to the .opt
-# file; it will initiate the stop request after the first
-# Rows_log_event (out of 3) but should wait until the last one is
-# executed before stopping.
+# slave will catch the killed status but won't shut down immediately
+# only after the whole group has done (commit)
 
 source include/wait_for_slave_sql_to_stop.inc;
 
-# check that we inserted all rows (waited until the last Rows event)
-select count(*) from t1;
+# checking: no error and the group is finished
+
+let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
+let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
+let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1);
+--disable_query_log
+eval SELECT $read = $exec into @check;
+--enable_query_log
+eval SELECT "NO$error" AS Last_SQL_Error, @check as `true`;
+select count(*) as one from tm;
+select count(*) as one from ti;
+
+set @@global.debug="-d";
+
+#
+# bug#45940 issues around rli->last_event_start_time
+# Testing of slave stopped after it had waited (in vain) for
+# the group be finished.
+# It could not be finished because of simulation of failure to
+# receive the terminal part
+# The test relay on simulation of the incomplete group in the relay log
+
+# Two cases are verified: a mixed transacton and a mixed multi-table update.
+#
+# The mixed transacton.
+#
+source include/start_slave.inc;
 
 connection master;
-drop table t1;
+
+truncate table tm; # cleanup of former tests
+truncate table ti;
+
+#connection slave;
+sync_slave_with_master;
+
+set @@global.debug="+d,stop_slave_middle_group";
+set @@global.debug="+d,incomplete_group_in_relay_log";
+
+connection master;
+
+begin;
+insert into ti set a=null;
+insert into tm set a=null;
+commit;
+
+connection slave;
+
+# slave will catch the killed status, won't shut down immediately
+# but does it eventually having the whole group unfinished (not committed)
+
+source include/wait_for_slave_sql_to_stop.inc;
+
+# checking: the error and group unfinished
+
+let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
+let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
+let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1);
+--disable_query_log
+eval SELECT $read - $exec > 0 into @check;
+--enable_query_log
+eval SELECT "$error" AS Last_SQL_Error, @check as `true`;
+select count(*) as one  from tm;
+select count(*) as zero from ti;
+
+set @@global.debug="-d";
+
+#
+# The mixed multi-table update
+#
+stop slave;
+truncate table tm;
+source include/start_slave.inc;
+
+connection master;
+
+#connection slave;
+sync_slave_with_master;
+set @@global.debug="+d,stop_slave_middle_group";
+set @@global.debug="+d,incomplete_group_in_relay_log";
+
+connection master;
+update tm as t1, ti as t2 set t1.a=t1.a * 2, t2.a=t2.a * 2;
+
+connection slave;
+
+# slave will catch the killed status, won't shut down immediately
+# but does it eventually having the whole group unfinished (not committed)
+# 
+
+source include/wait_for_slave_sql_to_stop.inc;
+
+# checking: the error and group unfinished 
+
+let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
+let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
+let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1);
+--disable_query_log
+eval SELECT $read - $exec > 0 into @check;
+--enable_query_log
+eval SELECT "$error" AS Last_SQL_Error, @check as `true`;
+select max(a) as two from tm;
+select max(a) as one from ti;
+
+set @@global.debug="-d";
+
+#
+# clean-up
+#
+
+connection master;
+drop table tm, ti;
+
 connection slave; # slave SQL thread is stopped
 source include/stop_slave.inc;
-drop table t1;
+drop table tm, ti;

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	2009-07-11 20:13:14 +0000
+++ b/mysql-test/t/disabled.def	2009-07-23 10:22:21 +0000
@@ -14,5 +14,5 @@ innodb_bug39438      : Bug#42383 2009-01
 query_cache_28249    : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
 information_schema   : Bug#42893 2009-03-26 alik main.information_schema times out sporadically
 skip_name_resolve    : Bug#43006 2009-06-25 alik main.skip_name_resolve fails on Windows in PB2
-init_connect         : Bug#44920 2009-07-06 pcrews MTR not processing master.opt input properly on Windows.  *Must be done this way due to the nature of the bug*
+init_connect         : Bug#43005
 mysql_locale_posix   : Bug#46131 2009-07-11 alik main.mysql_locale_posix fais, thus disabled

=== modified file 'mysql-test/t/lock.test'
--- a/mysql-test/t/lock.test	2009-03-27 22:06:26 +0000
+++ b/mysql-test/t/lock.test	2009-07-02 14:24:05 +0000
@@ -345,5 +345,37 @@ connection default;
 drop table t1;
 
 --echo #
+--echo # Bug#45066 FLUSH TABLES WITH READ LOCK deadlocks against 
+--echo #           LOCK TABLE 
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+
+LOCK TABLE t1 READ;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLES;
+
+LOCK TABLE t1 WRITE;
+FLUSH TABLES;
+
+--echo #
+--echo # If you allow the next combination, you reintroduce bug Bug#45066
+--echo # 
+LOCK TABLE t1 READ;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+FLUSH TABLES WITH READ LOCK;
+
+LOCK TABLE t1 WRITE;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+FLUSH TABLES WITH READ LOCK;
+
+UNLOCK TABLES;
+DROP TABLE t1;
+
+--echo #
 --echo # End of 6.0 tests.
 --echo #

=== modified file 'netware/BUILD/compile-netware-START'
--- a/netware/BUILD/compile-netware-START	2006-10-12 16:25:27 +0000
+++ b/netware/BUILD/compile-netware-START	2009-07-20 16:51:21 +0000
@@ -22,6 +22,5 @@ base_configs=" \
 	--enable-local-infile \
 	--with-extra-charsets=all \
 	--prefix=N:/mysql \
-	--without-mysqlmanager \
 	--without-man \
 	"

=== modified file 'plugin/semisync/semisync_master.cc'
--- a/plugin/semisync/semisync_master.cc	2009-07-08 23:52:29 +0000
+++ b/plugin/semisync/semisync_master.cc	2009-07-23 16:00:16 +0000
@@ -90,7 +90,7 @@ ActiveTranx::~ActiveTranx()
 {
   for (int idx = 0; idx < num_transactions_; ++idx)
   {
-    delete node_array_[idx].log_name_;
+    delete [] node_array_[idx].log_name_;
     node_array_[idx].log_name_ = NULL;
   }
 
@@ -138,6 +138,16 @@ ActiveTranx::TranxNode* ActiveTranx::all
     ptr->next_ = NULL;
     ptr->hash_next_ = NULL;
   }
+  else
+  {
+    /*
+      free_pool should never be NULL here, because we have
+      max_connections number of pre-allocated nodes.
+    */
+    sql_print_error("You have encountered a semi-sync bug (free_pool == NULL), "
+                    "please report to http://bugs.mysql.com");
+    assert(free_pool_);
+  }
 
   return ptr;
 }
@@ -440,7 +450,7 @@ int ReplSemiSyncMaster::enableMaster()
     }
     else
     {
-      sql_print_information("Semi-sync replication not able to allocate memory.");
+      sql_print_error("Cannot allocate memory to enable semi-sync on the master.");
       result = -1;
     }
   }
@@ -766,17 +776,11 @@ int ReplSemiSyncMaster::commitTrx(const
 
         if (wait_result != 0)
 	{
-          if (trace_level_ & kTraceGeneral)
-	  {
-            /* This is a real wait timeout. */
-            sql_print_warning("Replication semi-sync not sent binlog to "
-                            "slave within the timeout %lu ms - OFF.",
-                            wait_timeout_);
-            sql_print_warning("          semi-sync up to file %s, position %lu",
+          /* This is a real wait timeout. */
+          sql_print_warning("Timeout waiting for reply of binlog (file: %s, pos: %lu), "
+                            "semi-sync up to file %s, position %lu.",
+                            trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos,
                             reply_file_name_, (unsigned long)reply_file_pos_);
-            sql_print_warning("          transaction needs file %s, position %lu",
-                            trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos);
-          }
           total_wait_timeouts_++;
 
           /* switch semi-sync off */
@@ -823,7 +827,7 @@ int ReplSemiSyncMaster::commitTrx(const
 
   l_end:
     /* Update the status counter. */
-    if (is_on())
+    if (is_on() && rpl_semi_sync_master_clients)
       enabled_transactions_++;
     else
       disabled_transactions_++;
@@ -869,7 +873,7 @@ int ReplSemiSyncMaster::switch_off()
   switched_off_times_++;
   wait_file_name_inited_   = false;
   reply_file_name_inited_  = false;
-  commit_file_name_inited_ = false;
+  sql_print_information("Semi-sync replication switched OFF.");
   cond_broadcast();                            /* wake up all waiting threads */
 
   return function_exit(kWho, result);
@@ -906,11 +910,10 @@ int ReplSemiSyncMaster::try_switch_on(in
     /* Switch semi-sync replication on. */
     state_ = true;
 
-    if (trace_level_ & kTraceGeneral)
-      sql_print_information("%s switch semi-sync ON with server(%d) "
-                            "at (%s, %lu), repl(%d)",
-                            kWho, server_id, log_file_name,
-                            (unsigned long)log_file_pos, (int)is_on());
+    sql_print_information("Semi-sync replication switched ON with slave (server_id: %d) "
+                          "at (%s, %lu)",
+                          server_id, log_file_name,
+                          (unsigned long)log_file_pos);
   }
 
   return function_exit(kWho, 0);
@@ -932,6 +935,9 @@ int ReplSemiSyncMaster::reserveSyncHeade
     /* No enough space for the extra header, disable semi-sync master */
     if (sizeof(kSyncHeader) > size)
     {
+      sql_print_warning("No enough space in the packet "
+                        "for semi-sync extra header, "
+                        "semi-sync replication disabled");
       disableMaster();
       return 0;
     }
@@ -1085,10 +1091,19 @@ int ReplSemiSyncMaster::writeTranxInBinl
     commit_file_name_inited_ = true;
   }
 
-  if (is_on())
+  if (is_on() && rpl_semi_sync_master_clients)
   {
     assert(active_tranxs_ != NULL);
-    result = active_tranxs_->insert_tranx_node(log_file_name, log_file_pos);
+    if(active_tranxs_->insert_tranx_node(log_file_name, log_file_pos))
+    {
+      /*
+        if insert tranx_node failed, print a warning message
+        and turn off semi-sync
+      */
+      sql_print_warning("Semi-sync failed to insert tranx_node for binlog file: %s, position: %ul",
+                        log_file_name, log_file_pos);
+      switch_off();
+    }
   }
 
  l_end:
@@ -1133,7 +1148,7 @@ void ReplSemiSyncMaster::setExportStats(
 {
   lock();
 
-  rpl_semi_sync_master_status           = state_ ? 1 : 0;
+  rpl_semi_sync_master_status           = state_ && rpl_semi_sync_master_clients;
   rpl_semi_sync_master_yes_transactions = enabled_transactions_;
   rpl_semi_sync_master_no_transactions  = disabled_transactions_;
   rpl_semi_sync_master_off_times        = switched_off_times_;

=== modified file 'plugin/semisync/semisync_master_plugin.cc'
--- a/plugin/semisync/semisync_master_plugin.cc	2009-07-08 23:52:29 +0000
+++ b/plugin/semisync/semisync_master_plugin.cc	2009-07-23 16:00:16 +0000
@@ -159,7 +159,7 @@ static MYSQL_SYSVAR_ULONG(timeout, rpl_s
  "The timeout value (in ms) for semi-synchronous replication in the master",
   NULL, 			// check
   fix_rpl_semi_sync_master_timeout,	// update
-  10, 0, ~0L, 1);
+  10000, 0, ~0L, 1);
 
 static MYSQL_SYSVAR_ULONG(trace_level, rpl_semi_sync_master_trace_level,
   PLUGIN_VAR_OPCMDARG,

=== modified file 'plugin/semisync/semisync_slave_plugin.cc'
--- a/plugin/semisync/semisync_slave_plugin.cc	2009-06-17 10:37:04 +0000
+++ b/plugin/semisync/semisync_slave_plugin.cc	2009-07-07 02:44:17 +0000
@@ -63,7 +63,7 @@ int repl_semi_slave_request_dump(Binlog_
   }
 
   row= mysql_fetch_row(res);
-  if (!row)
+  if (!row || strcmp(row[1], "ON"))
   {
     /* Master does not support or not configured semi-sync */
     sql_print_warning("Master server does not support or not configured semi-sync replication, fallback to asynchronous");

=== modified file 'scripts/make_binary_distribution.sh'
--- a/scripts/make_binary_distribution.sh	2009-04-14 21:07:28 +0000
+++ b/scripts/make_binary_distribution.sh	2009-07-21 14:35:04 +0000
@@ -56,6 +56,12 @@ SOURCE=`pwd`
 CP="cp -p"
 MV="mv"
 
+# There are platforms, notably OS X on Intel (x86 + x86_64),
+# for which "uname" does not provide sufficient information.
+# The value of CFLAGS as used during compilation is the most exact info
+# we can get - after all, we care about _what_ we built, not _where_ we did it.
+cflags="@CFLAGS@"
+
 STRIP=1				# Option ignored
 SILENT=0
 PLATFORM=""
@@ -104,7 +110,50 @@ if [ x"$PLATFORM" = x"" ] ; then
   system=`echo $system | sed -e 's/linux-gnu/linux/g'`
   system=`echo $system | sed -e 's/solaris2.\([0-9]*\)/solaris\1/g'`
   system=`echo $system | sed -e 's/sco3.2v\(.*\)/openserver\1/g'`
+fi
+
+# Get the "machine", which really is the CPU architecture (including the size).
+# The precedence is:
+# 1) use an explicit argument, if given;
+# 2) use platform-specific fixes, if there are any (see bug#37808);
+# 3) stay with the default (determined during "configure", using predefined macros).
+
+if [ x"$MACHINE" != x"" ] ; then
+  machine=$MACHINE
+else
+  case $system in
+    osx* )
+      # Extract "XYZ" from CFLAGS "... -arch XYZ ...", or empty!
+      cflag_arch=`echo "$cflags" | sed -n -e 's=.* -arch \([^ ]*\) .*=\1=p'`
+      case "$cflag_arch" in
+        i386 )    case $system in
+                    osx10.4 )  machine=i686 ;; # Used a different naming
+                    * )        machine=x86 ;;
+                  esac ;;
+        x86_64 )  machine=x86_64 ;;
+        ppc )     ;;  # No treatment needed with PPC
+        ppc64 )   ;;
+        * ) # No matching compiler flag? "--platform" is needed
+            if [ x"$PLATFORM" != x"" ] ; then
+              :  # See below: "$PLATFORM" will take precedence anyway
+            elif [ "$system" = "osx10.3" -a -z "$cflag_arch" ] ; then
+              :  # Special case of OS X 10.3, which is PPC-32 only and doesn't use "-arch"
+            else
+              echo "On system '$system' only specific '-arch' values are expected."
+              echo "It is taken from the 'CFLAGS' whose value is:"
+              echo "$cflags"
+              echo "'-arch $cflag_arch' is unexpected, and no '--platform' was given: ABORT"
+              exit 1
+            fi ;;
+      esac  # "$cflag_arch"
+      ;;
+  esac  # $system
+fi
 
+# Combine OS and CPU to the "platform". Again, an explicit argument takes precedence.
+if [ x"$PLATFORM" != x"" ] ; then
+  :  
+else
   PLATFORM="$system-$machine"
 fi
 
@@ -153,10 +202,10 @@ which_1 ()
     do
       for file in $d/$cmd
       do
-	if [ -x $file -a ! -d $file ] ; then
-	  echo $file
-	  exit 0
-	fi
+        if [ -x $file -a ! -d $file ] ; then
+          echo $file
+          exit 0
+        fi
       done
     done
   done
@@ -342,7 +391,6 @@ BIN_FILES="extra/comp_err$BS extra/repla
   storage/myisam/myisamlog$BS storage/myisam/myisam_ftdump$BS \
   sql/mysqld$BS sql/mysqld-debug$BS \
   sql/mysql_tzinfo_to_sql$BS \
-  server-tools/instance-manager/mysqlmanager$BS \
   client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \
   client/mysqlslap$BS \
   client/mysqldump$BS client/mysqlimport$BS \
@@ -460,7 +508,7 @@ rm -f   $BASE/support-files/magic \
         $BASE/support-files/mysql-log-rotate \
         $BASE/support-files/binary-configure \
         $BASE/support-files/build-tags \
-	$BASE/support-files/MySQL-shared-compat.spec \
+        $BASE/support-files/MySQL-shared-compat.spec \
         $BASE/INSTALL-BINARY
 
 # Clean up if we did this from a bk tree

=== modified file 'sql-bench/README' (properties changed: +x to -x)
=== modified file 'sql/derror.cc'
--- a/sql/derror.cc	2009-07-14 00:03:25 +0000
+++ b/sql/derror.cc	2009-07-23 16:00:16 +0000
@@ -108,11 +108,24 @@ bool read_texts(const char *file_name, c
   convert_dirname(lang_path, language, NullS);
   (void) my_load_path(lang_path, lang_path, lc_messages_dir);
   if ((file= mysql_file_open(key_file_ERRMSG,
-                             fn_format(name,file_name,
-                             lang_path, "", 4),
-                             O_RDONLY | O_SHARE | O_BINARY,
+                             fn_format(name, file_name, lang_path, "", 4),
+		             O_RDONLY | O_SHARE | O_BINARY,
                              MYF(0))) < 0)
-    goto err; /* purecov: inspected */
+  {
+    /*
+      Trying pre-5.4 semantics of the --language parameter.
+      It included the language-specific part, e.g.:
+
+      --language=/path/to/english/
+    */
+    if ((file= mysql_file_open(key_file_ERRMSG,
+                               fn_format(name, file_name, lc_messages_dir, "", 4),
+                               O_RDONLY | O_SHARE | O_BINARY,
+                               MYF(0))) < 0)
+      goto err;
+    sql_print_error("An old style --language value with language specific part detected: %s", lc_messages_dir);
+    sql_print_error("Use --lc-messages-dir without language specific part instead.");
+  }
 
   funktpos=1;
   if (mysql_file_read(file,(uchar*) head,32,MYF(MY_NABP))) goto err;

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2009-07-14 00:03:25 +0000
+++ b/sql/log.cc	2009-07-23 16:00:16 +0000
@@ -6059,7 +6059,6 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
         DBUG_EVALUATE_IF("injecting_fault_writing", 1, 0))
       goto err;
 
-    error=0;
     if (file == &log_file) // we are writing to the real log (disk)
     {
       bool synced;
@@ -6068,12 +6067,14 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
 
       if (RUN_HOOK(binlog_storage, after_flush,
                    (thd, log_file_name, file->pos_in_file, synced))) {
+        sql_print_error("Failed to run 'after_flush' hooks");
         goto err;
       }
 
       signal_update();
       rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
     }
+    error=0;
 
 err:
     if (error)
@@ -6477,7 +6478,11 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_C
 
       if (RUN_HOOK(binlog_storage, after_flush,
                    (thd, log_file_name, log_file.pos_in_file, synced)))
+      {
+        sql_print_error("Failed to run 'after_flush' hooks");
+        write_error=1;
         goto err;
+      }
 
       signal_update();
     }

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2009-07-14 00:03:25 +0000
+++ b/sql/log_event.cc	2009-07-23 16:00:16 +0000
@@ -3250,6 +3250,21 @@ Default database: '%s'. Query: '%s'",
     */
   } /* End of if (db_ok(... */
 
+  {/**
+      The following failure injecion works in cooperation with tests 
+      setting @@global.debug= 'd,stop_slave_middle_group'.
+      The sql thread receives the killed status and will proceed 
+      to shutdown trying to finish incomplete events group.
+   */
+    DBUG_EXECUTE_IF("stop_slave_middle_group",
+                    if (strcmp("COMMIT", query) != 0 &&
+                        strcmp("BEGIN", query) != 0)
+                    {
+                      if (thd->transaction.all.modified_non_trans_table)
+                        const_cast<Relay_log_info*>(rli)->abort_slave= 1;
+                    };);
+  }
+
 end:
   mysql_mutex_lock(&LOCK_thread_count);
   /*
@@ -7499,8 +7514,16 @@ int Rows_log_event::do_apply_event(Relay
           thd->transaction.stmt.modified_non_trans_table= TRUE;
     } // row processing loop
 
-    DBUG_EXECUTE_IF("STOP_SLAVE_after_first_Rows_event",
-                    const_cast<Relay_log_info*>(rli)->abort_slave= 1;);
+    {/**
+         The following failure injecion works in cooperation with tests 
+         setting @@global.debug= 'd,stop_slave_middle_group'.
+         The sql thread receives the killed status and will proceed 
+         to shutdown trying to finish incomplete events group.
+     */
+      DBUG_EXECUTE_IF("stop_slave_middle_group",
+                      if (thd->transaction.all.modified_non_trans_table)
+                        const_cast<Relay_log_info*>(rli)->abort_slave= 1;);
+    }
 
     if ((error= do_after_row_operations(rli, error)) &&
         ignored_error_code(convert_handler_error(error, thd, table)))
@@ -7533,32 +7556,6 @@ int Rows_log_event::do_apply_event(Relay
     const_cast<Relay_log_info*>(rli)->cleanup_context(thd, error);
     thd->is_slave_error= 1;
   }
-  /*
-    This code would ideally be placed in do_update_pos() instead, but
-    since we have no access to table there, we do the setting of
-    last_event_start_time here instead.
-  */
-  else if (table && (table->s->primary_key == MAX_KEY) &&
-           !cache_stmt && get_flags(STMT_END_F) == RLE_NO_FLAGS)
-  {
-    /*
-      ------------ Temporary fix until WL#2975 is implemented ---------
-
-      This event is not the last one (no STMT_END_F). If we stop now
-      (in case of terminate_slave_thread()), how will we restart? We
-      have to restart from Table_map_log_event, but as this table is
-      not transactional, the rows already inserted will still be
-      present, and idempotency is not guaranteed (no PK) so we risk
-      that repeating leads to double insert. So we desperately try to
-      continue, hope we'll eventually leave this buggy situation (by
-      executing the final Rows_log_event). If we are in a hopeless
-      wait (reached end of last relay log and nothing gets appended
-      there), we timeout after one minute, and notify DBA about the
-      problem.  When WL#2975 is implemented, just remove the member
-      Relay_log_info::last_event_start_time and all its occurrences.
-    */
-    const_cast<Relay_log_info*>(rli)->last_event_start_time= my_time(0);
-  }
 
   DBUG_RETURN(error);
 }

=== modified file 'sql/log_event_old.cc'
--- a/sql/log_event_old.cc	2009-04-29 16:48:59 +0000
+++ b/sql/log_event_old.cc	2009-07-06 13:46:31 +0000
@@ -224,7 +224,7 @@ Old_rows_log_event::do_apply_event(Old_r
 
       row_start= row_end;
     }
-    DBUG_EXECUTE_IF("STOP_SLAVE_after_first_Rows_event",
+    DBUG_EXECUTE_IF("stop_slave_middle_group",
                     const_cast<Relay_log_info*>(rli)->abort_slave= 1;);
     error= do_after_row_operations(table, error);
     if (!ev->cache_stmt)
@@ -260,34 +260,6 @@ Old_rows_log_event::do_apply_event(Old_r
     DBUG_RETURN(error);
   }
 
-  /*
-    This code would ideally be placed in do_update_pos() instead, but
-    since we have no access to table there, we do the setting of
-    last_event_start_time here instead.
-  */
-  if (table && (table->s->primary_key == MAX_KEY) &&
-      !ev->cache_stmt && 
-      ev->get_flags(Old_rows_log_event::STMT_END_F) == Old_rows_log_event::RLE_NO_FLAGS)
-  {
-    /*
-      ------------ Temporary fix until WL#2975 is implemented ---------
-
-      This event is not the last one (no STMT_END_F). If we stop now
-      (in case of terminate_slave_thread()), how will we restart? We
-      have to restart from Table_map_log_event, but as this table is
-      not transactional, the rows already inserted will still be
-      present, and idempotency is not guaranteed (no PK) so we risk
-      that repeating leads to double insert. So we desperately try to
-      continue, hope we'll eventually leave this buggy situation (by
-      executing the final Old_rows_log_event). If we are in a hopeless
-      wait (reached end of last relay log and nothing gets appended
-      there), we timeout after one minute, and notify DBA about the
-      problem.  When WL#2975 is implemented, just remove the member
-      st_relay_log_info::last_event_start_time and all its occurences.
-    */
-    const_cast<Relay_log_info*>(rli)->last_event_start_time= my_time(0);
-  }
-
   DBUG_RETURN(0);
 }
 #endif
@@ -1743,7 +1715,7 @@ int Old_rows_log_event::do_apply_event(R
  
     } // row processing loop
 
-    DBUG_EXECUTE_IF("STOP_SLAVE_after_first_Rows_event",
+    DBUG_EXECUTE_IF("stop_slave_middle_group",
                     const_cast<Relay_log_info*>(rli)->abort_slave= 1;);
     error= do_after_row_operations(rli, error);
     if (!cache_stmt)
@@ -1779,33 +1751,6 @@ int Old_rows_log_event::do_apply_event(R
     DBUG_RETURN(error);
   }
 
-  /*
-    This code would ideally be placed in do_update_pos() instead, but
-    since we have no access to table there, we do the setting of
-    last_event_start_time here instead.
-  */
-  if (table && (table->s->primary_key == MAX_KEY) &&
-      !cache_stmt && get_flags(STMT_END_F) == RLE_NO_FLAGS)
-  {
-    /*
-      ------------ Temporary fix until WL#2975 is implemented ---------
-
-      This event is not the last one (no STMT_END_F). If we stop now
-      (in case of terminate_slave_thread()), how will we restart? We
-      have to restart from Table_map_log_event, but as this table is
-      not transactional, the rows already inserted will still be
-      present, and idempotency is not guaranteed (no PK) so we risk
-      that repeating leads to double insert. So we desperately try to
-      continue, hope we'll eventually leave this buggy situation (by
-      executing the final Old_rows_log_event). If we are in a hopeless
-      wait (reached end of last relay log and nothing gets appended
-      there), we timeout after one minute, and notify DBA about the
-      problem.  When WL#2975 is implemented, just remove the member
-      Relay_log_info::last_event_start_time and all its occurrences.
-    */
-    const_cast<Relay_log_info*>(rli)->last_event_start_time= my_time(0);
-  }
-
   DBUG_RETURN(0);
 }
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-07-21 21:55:48 +0000
+++ b/sql/mysqld.cc	2009-07-23 16:00:16 +0000
@@ -4217,6 +4217,10 @@ will be ignored as the --log-bin option
     }
   }
 
+  /* if the errmsg.sys is not loaded, terminate to maintain behaviour */
+  if (!DEFAULT_ERRMSGS[0][0])
+    unireg_abort(1);
+  
   /* We have to initialize the storage engines before CSV logging */
   if (ha_init())
   {
@@ -6483,6 +6487,11 @@ Disable with --skip-large-pages.",
   {"init-slave", OPT_INIT_SLAVE, "Command(s) that are executed when a slave connects to this master",
    (uchar**) &opt_init_slave, (uchar**) &opt_init_slave, 0, GET_STR_ALLOC,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"language", 'L',
+   "Client error messages in given language. May be given as a full path. "
+   "Deprecated. Use --lc-messages-dir instead.",
+   (uchar**) &lc_messages_dir_ptr, (uchar**) &lc_messages_dir_ptr, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"lc-messages-dir", 'L',
    "Directory where error messages are.", (uchar**) &lc_messages_dir_ptr,
    (uchar**) &lc_messages_dir_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -8182,10 +8191,7 @@ SHOW_VAR status_vars[]= {
 static void print_version(void)
 {
   set_server_version();
-  /*
-    Note: the instance manager keys off the string 'Ver' so it can find the
-    version from the output of 'mysqld --version', so don't change it!
-  */
+
   printf("%s  Ver %s for %s on %s (%s)\n",my_progname,
 	 server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT);
 }

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2009-07-14 00:03:25 +0000
+++ b/sql/rpl_rli.cc	2009-07-23 16:00:16 +0000
@@ -932,7 +932,6 @@ void Relay_log_info::cleanup_context(THD
   */
   thd->options&= ~OPTION_NO_FOREIGN_KEY_CHECKS;
   thd->options&= ~OPTION_RELAXED_UNIQUE_CHECKS;
-  last_event_start_time= 0;
   DBUG_VOID_RETURN;
 }
 

=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2009-07-08 23:52:29 +0000
+++ b/sql/rpl_rli.h	2009-07-23 16:00:16 +0000
@@ -316,12 +316,10 @@ public:
   void clear_tables_to_lock();
 
   /*
-    Used by row-based replication to detect that it should not stop at
-    this event, but give it a chance to send more events. The time
-    where the last event inside a group started is stored here. If the
-    variable is zero, we are not in a group (but may be in a
-    transaction).
-   */
+    Used to defer stopping the SQL thread to give it a chance
+    to finish up the current group of events.
+    The timestamp is set and reset in @c sql_slave_killed().
+  */
   time_t last_event_start_time;
 
   /**

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2009-07-14 00:03:25 +0000
+++ b/sql/slave.cc	2009-07-23 16:00:16 +0000
@@ -52,6 +52,10 @@
 #define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
 
 #define MAX_SLAVE_RETRY_PAUSE 5
+/*
+  a parameter of sql_slave_killed() to defer the killed status
+*/
+#define SLAVE_WAIT_GROUP_DONE 60
 bool use_slave_mask = 0;
 MY_BITMAP slave_error_mask;
 char slave_skip_error_names[SHOW_VAR_FUNC_BUFF_SIZE];
@@ -905,44 +909,92 @@ static bool io_slave_killed(THD* thd, Ma
   DBUG_RETURN(mi->abort_slave || abort_loop || thd->killed);
 }
 
+/**
+   The function analyzes a possible killed status and makes
+   a decision whether to accept it or not.
+   Normally upon accepting the sql thread goes to shutdown.
+   In the event of deffering decision @rli->last_event_start_time waiting
+   timer is set to force the killed status be accepted upon its expiration.
 
+   @param thd   pointer to a THD instance
+   @param rli   pointer to Relay_log_info instance
+
+   @return TRUE the killed status is recognized, FALSE a possible killed
+           status is deferred.
+*/
 static bool sql_slave_killed(THD* thd, Relay_log_info* rli)
 {
+  bool ret= FALSE;
   DBUG_ENTER("sql_slave_killed");
 
   DBUG_ASSERT(rli->info_thd == thd);
   DBUG_ASSERT(rli->slave_running == 1);// tracking buffer overrun
   if (abort_loop || thd->killed || rli->abort_slave)
   {
-    if (rli->abort_slave && rli->is_in_group() &&
-        thd->transaction.all.modified_non_trans_table)
-      DBUG_RETURN(0);
-    /*
-      If we are in an unsafe situation (stopping could corrupt replication),
-      we give one minute to the slave SQL thread of grace before really
-      terminating, in the hope that it will be able to read more events and
-      the unsafe situation will soon be left. Note that this one minute starts
-      from the last time anything happened in the slave SQL thread. So it's
-      really one minute of idleness, we don't timeout if the slave SQL thread
-      is actively working.
-    */
-    if (rli->last_event_start_time == 0)
-      DBUG_RETURN(1);
-    DBUG_PRINT("info", ("Slave SQL thread is in an unsafe situation, giving "
-                        "it some grace period"));
-    if (difftime(time(0), rli->last_event_start_time) > 60)
-    {
-      rli->report(ERROR_LEVEL, 0,
-                  "SQL thread had to stop in an unsafe situation, in "
-                  "the middle of applying updates to a "
-                  "non-transactional table without any primary key. "
-                  "There is a risk of duplicate updates when the slave "
-                  "SQL thread is restarted. Please check your tables' "
-                  "contents after restart.");
-      DBUG_RETURN(1);
+    if (thd->transaction.all.modified_non_trans_table && rli->is_in_group())
+    {
+      char msg_stopped[]=
+        "... The slave SQL is stopped, leaving the current group "
+        "of events unfinished with a non-transaction table changed. "
+        "If the group consists solely of Row-based events, you can try "
+        "restarting the slave with --slave-exec-mode=IDEMPOTENT, which "
+        "ignores duplicate key, key not found, and similar errors (see "
+        "documentation for details).";
+
+      if (rli->abort_slave)
+      {
+        DBUG_PRINT("info", ("Slave SQL thread is being stopped in the middle of"
+                            " a group having updated a non-trans table, giving"
+                            " it some grace period"));
+
+        /*
+          Slave sql thread shutdown in face of unfinished group modified 
+          Non-trans table is handled via a timer. The slave may eventually
+          give out to complete the current group and in that case there
+          might be issues at consequent slave restart, see the error message.
+          WL#2975 offers a robust solution requiring to store the last exectuted
+          event's coordinates along with the group's coordianates
+          instead of waiting with @c last_event_start_time the timer.
+        */
+
+        if (rli->last_event_start_time == 0)
+          rli->last_event_start_time= my_time(0);
+        ret= difftime(my_time(0), rli->last_event_start_time) <=
+          SLAVE_WAIT_GROUP_DONE ? FALSE : TRUE;
+
+        DBUG_EXECUTE_IF("stop_slave_middle_group", 
+                        DBUG_EXECUTE_IF("incomplete_group_in_relay_log",
+                                        ret= TRUE;);); // time is over
+
+        if (ret == 0)
+        {
+          rli->report(WARNING_LEVEL, 0,
+                      "slave SQL thread is being stopped in the middle "
+                      "of applying of a group having updated a non-transaction "
+                      "table; waiting for the group completion ... ");
+        }
+        else
+        {
+          rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+                      ER(ER_SLAVE_FATAL_ERROR), msg_stopped);
+        }
+      }
+      else
+      {
+        ret= TRUE;
+        rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, ER(ER_SLAVE_FATAL_ERROR),
+                    msg_stopped);
+      }
+    }
+    else
+    {
+      ret= TRUE;
     }
   }
-  DBUG_RETURN(0);
+  if (ret)
+    rli->last_event_start_time= 0;
+  
+  DBUG_RETURN(ret);
 }
 
 
@@ -2326,6 +2378,27 @@ static int exec_relay_log_event(THD* thd
       delete ev;
       DBUG_RETURN(1);
     }
+
+    { /**
+         The following failure injecion works in cooperation with tests 
+         setting @@global.debug= 'd,incomplete_group_in_relay_log'.
+         Xid or Commit events are not executed to force the slave sql
+         read hanging if the realy log does not have any more events.
+      */
+      DBUG_EXECUTE_IF("incomplete_group_in_relay_log",
+                      if ((ev->get_type_code() == XID_EVENT) ||
+                          ((ev->get_type_code() == QUERY_EVENT) &&
+                           strcmp("COMMIT", ((Query_log_event *) ev)->query) == 0))
+                      {
+                        DBUG_ASSERT(thd->transaction.all.modified_non_trans_table);
+                        rli->abort_slave= 1;
+                        mysql_mutex_unlock(&rli->data_lock);
+                        delete ev;
+                        rli->inc_event_relay_log_pos();
+                        DBUG_RETURN(0);
+                      };);
+    }
+
     exec_res= apply_event_and_update_pos(ev, thd, rli, TRUE);
 
     /*
@@ -3756,7 +3829,7 @@ static int queue_event(Master_info* mi,c
     goto skip_relay_logging;
   }
   break;
-    
+
   default:
     inc_pos= event_len;
     break;

=== modified file 'support-files/mysql.server.sh'
--- a/support-files/mysql.server.sh	2008-03-26 16:40:41 +0000
+++ b/support-files/mysql.server.sh	2009-07-21 14:57:51 +0000
@@ -53,13 +53,14 @@ datadir=
 # Negative numbers mean to wait indefinitely
 service_startup_timeout=900
 
+# Lock directory for RedHat / SuSE.
+lockdir='/var/lock/subsys'
+lock_file_path="$lockdir/mysql"
+
 # The following variables are only set for letting mysql.server find things.
 
 # Set some defaults
-pid_file=
-server_pid_file=
-use_mysqld_safe=1
-user=@MYSQLD_USER@
+mysqld_pid_file_path=
 if test -z "$basedir"
 then
   basedir=@prefix@
@@ -101,11 +102,14 @@ else
   }
 fi
 
-PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
+PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin"
 export PATH
 
 mode=$1    # start or stop
-shift
+
+[ $# -ge 1 ] && shift
+
+
 other_args="$*"   # uncommon, but needed when called from an RPM upgrade action
            # Expected: "--skip-networking --skip-grant-tables"
            # They are not checked here, intentionally, as it is the resposibility
@@ -131,59 +135,50 @@ parse_server_arguments() {
       --datadir=*)  datadir=`echo "$arg" | sed -e 's/^[^=]*=//'`
 		    datadir_set=1
 	;;
-      --user=*)  user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
-      --pid-file=*) server_pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
+      --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
       --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
-      --use-mysqld_safe) use_mysqld_safe=1;;
-      --use-manager)     use_mysqld_safe=0;;
-    esac
-  done
-}
-
-parse_manager_arguments() {
-  for arg do
-    case "$arg" in
-      --pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
-      --user=*)  user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
     esac
   done
 }
 
 wait_for_pid () {
-  verb="$1"
-  manager_pid="$2"  # process ID of the program operating on the pid-file
+  verb="$1"           # created | removed
+  pid="$2"            # process ID of the program operating on the pid-file
+  pid_file_path="$3" # path to the PID file.
+
   i=0
   avoid_race_condition="by checking again"
+
   while test $i -ne $service_startup_timeout ; do
 
     case "$verb" in
       'created')
         # wait for a PID-file to pop into existence.
-        test -s $pid_file && i='' && break
+        test -s "$pid_file_path" && i='' && break
         ;;
       'removed')
         # wait for this PID-file to disappear
-        test ! -s $pid_file && i='' && break
+        test ! -s "$pid_file_path" && i='' && break
         ;;
       *)
-        echo "wait_for_pid () usage: wait_for_pid created|removed manager_pid"
+        echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
         exit 1
         ;;
     esac
 
-    # if manager isn't running, then pid-file will never be updated
-    if test -n "$manager_pid"; then
-      if kill -0 "$manager_pid" 2>/dev/null; then
-        :  # the manager still runs
+    # if server isn't running, then pid-file will never be updated
+    if test -n "$pid"; then
+      if kill -0 "$pid" 2>/dev/null; then
+        :  # the server still runs
       else
-        # The manager may have exited between the last pid-file check and now.  
+        # The server may have exited between the last pid-file check and now.  
         if test -n "$avoid_race_condition"; then
           avoid_race_condition=""
           continue  # Check again.
         fi
 
         # there's nothing that will affect the file.
-        log_failure_msg "Manager of pid-file quit without updating file."
+        log_failure_msg "The server quit without updating PID file ($pid_file_path)."
         return 1  # not waiting any more.
       fi
     fi
@@ -191,6 +186,7 @@ wait_for_pid () {
     echo $echo_n ".$echo_c"
     i=`expr $i + 1`
     sleep 1
+
   done
 
   if test -z "$i" ; then
@@ -259,28 +255,16 @@ fi
 
 parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
 
-# Look for the pidfile 
-parse_manager_arguments `$print_defaults $extra_args manager`
-
 #
 # Set pid file if not given
 #
-if test -z "$pid_file"
-then
-  pid_file=$datadir/mysqlmanager-`@HOSTNAME@`.pid
-else
-  case "$pid_file" in
-    /* ) ;;
-    * )  pid_file="$datadir/$pid_file" ;;
-  esac
-fi
-if test -z "$server_pid_file"
+if test -z "$mysqld_pid_file_path"
 then
-  server_pid_file=$datadir/`@HOSTNAME@`.pid
+  mysqld_pid_file_path=$datadir/`@HOSTNAME@`.pid
 else
-  case "$server_pid_file" in
+  case "$mysqld_pid_file_path" in
     /* ) ;;
-    * )  server_pid_file="$datadir/$server_pid_file" ;;
+    * )  mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;;
   esac
 fi
 
@@ -291,53 +275,23 @@ case "$mode" in
     # Safeguard (relative paths, core dumps..)
     cd $basedir
 
-    manager=$bindir/mysqlmanager
-    if test -x $libexecdir/mysqlmanager
-    then
-      manager=$libexecdir/mysqlmanager
-    elif test -x $sbindir/mysqlmanager
-    then
-      manager=$sbindir/mysqlmanager
-    fi
-
     echo $echo_n "Starting MySQL"
-    if test -x $manager -a "$use_mysqld_safe" = "0"
-    then
-      if test -n "$other_args"
-      then
-        log_failure_msg "MySQL manager does not support options '$other_args'"
-        exit 1
-      fi
-      # Give extra arguments to mysqld with the my.cnf file. This script may
-      # be overwritten at next upgrade.
-      "$manager" \
-        --mysqld-safe-compatible \
-        --user="$user" \
-        --pid-file="$pid_file" >/dev/null 2>&1 &
-      wait_for_pid created $!; return_value=$?
-
-      # Make lock for RedHat / SuSE
-      if test -w /var/lock/subsys
-      then
-        touch /var/lock/subsys/mysqlmanager
-      fi
-      exit $return_value
-    elif test -x $bindir/mysqld_safe
+    if test -x $bindir/mysqld_safe
     then
       # Give extra arguments to mysqld with the my.cnf file. This script
       # may be overwritten at next upgrade.
-      pid_file=$server_pid_file
-      $bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
-      wait_for_pid created $!; return_value=$?
+      $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
+      wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
 
       # Make lock for RedHat / SuSE
-      if test -w /var/lock/subsys
+      if test -w "$lockdir"
       then
-        touch /var/lock/subsys/mysql
+        touch "$lock_file_path"
       fi
+
       exit $return_value
     else
-      log_failure_msg "Couldn't find MySQL manager ($manager) or server ($bindir/mysqld_safe)"
+      log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
     fi
     ;;
 
@@ -345,32 +299,22 @@ case "$mode" in
     # Stop daemon. We use a signal here to avoid having to know the
     # root password.
 
-    # The RedHat / SuSE lock directory to remove
-    lock_dir=/var/lock/subsys/mysqlmanager
-
-    # If the manager pid_file doesn't exist, try the server's
-    if test ! -s "$pid_file"
+    if test -s "$mysqld_pid_file_path"
     then
-      pid_file=$server_pid_file
-      lock_dir=/var/lock/subsys/mysql
-    fi
-
-    if test -s "$pid_file"
-    then
-      mysqlmanager_pid=`cat $pid_file`
+      mysqld_pid=`cat "$mysqld_pid_file_path"`
       echo $echo_n "Shutting down MySQL"
-      kill $mysqlmanager_pid
-      # mysqlmanager should remove the pid_file when it exits, so wait for it.
-      wait_for_pid removed "$mysqlmanager_pid"; return_value=$?
+      kill $mysqld_pid
+      # mysqld should remove the pid file when it exits, so wait for it.
+      wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
 
-      # delete lock for RedHat / SuSE
-      if test -f $lock_dir
+      # Delete lock for RedHat / SuSE
+      if test -f "$lock_file_path"
       then
-        rm -f $lock_dir
+        rm -f "$lock_file_path"
       fi
       exit $return_value
     else
-      log_failure_msg "MySQL manager or server PID file could not be found!"
+      log_failure_msg "MySQL server PID file could not be found!"
     fi
     ;;
 
@@ -386,10 +330,10 @@ case "$mode" in
     ;;
 
   'reload'|'force-reload')
-    if test -s "$server_pid_file" ; then
-      read mysqld_pid <  $server_pid_file
+    if test -s "$mysqld_pid_file_path" ; then
+      read mysqld_pid <  "$mysqld_pid_file_path"
       kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
-      touch $server_pid_file
+      touch "$mysqld_pid_file_path"
     else
       log_failure_msg "MySQL PID file could not be found!"
       exit 1
@@ -397,8 +341,8 @@ case "$mode" in
     ;;
   'status')
     # First, check to see if pid file exists
-    if test -s "$server_pid_file" ; then 
-      read mysqld_pid < $server_pid_file
+    if test -s "$mysqld_pid_file_path" ; then 
+      read mysqld_pid < "$mysqld_pid_file_path"
       if kill -0 $mysqld_pid 2>/dev/null ; then 
         log_success_msg "MySQL running ($mysqld_pid)"
         exit 0
@@ -410,13 +354,8 @@ case "$mode" in
       # Try to find appropriate mysqld process
       mysqld_pid=`pidof $libexecdir/mysqld`
       if test -z $mysqld_pid ; then 
-        if test "$use_mysqld_safe" = "0" ; then 
-          lockfile=/var/lock/subsys/mysqlmanager
-        else
-          lockfile=/var/lock/subsys/mysql
-        fi 
-        if test -f $lockfile ; then 
-          log_failure_msg "MySQL is not running, but lock exists"
+        if test -f "$lock_file_path" ; then 
+          log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists"
           exit 2
         fi 
         log_failure_msg "MySQL is not running"
@@ -429,7 +368,8 @@ case "$mode" in
     ;;
     *)
       # usage
-      echo "Usage: $0  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]"
+      basename=`basename "$0"`
+      echo "Usage: $basename  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]"
       exit 1
     ;;
 esac

=== modified file 'tests/grant.pl' (properties changed: -x to +x)
Thread
bzr push into mysql-5.4-perfschema branch (marc.alff:2834 to 2835) Marc Alff23 Jul