From 381fb617d398cb9588d5c95a0ec94b1351c4eb1e Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Sun, 15 Jun 2008 18:01:07 +0500 Subject: [PATCH 01/11] Bug #35934 mysql_upgrade calls mysqlcheck with insufficient parameters. Parameters added to the mysqlcheck call to fix table/database names. client/mysql_upgrade.c: Bug #35934 mysql_upgrade calls mysqlcheck with insufficient parameters. --fix-db-names and --fix-table-names added to the mysqlcheck call --- client/mysql_upgrade.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 6c5ca039a41..088115ec3ac 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -652,6 +652,8 @@ static int run_mysqlcheck_upgrade(void) "--check-upgrade", "--all-databases", "--auto-repair", + "--fix-db-names", + "--fix-table-names", NULL); } From 1c9df573c9c0903e4daaac90b7defd52a52ed337 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 12 Nov 2008 13:36:53 +0100 Subject: [PATCH 02/11] Bug#38784: Mysql server crash if table is altered with partition changes. Occurred with EXTRA_DEBUG on windows. Problem was insufficient length of a local variable that stored path names. Solution was to use the correct length. CMakeLists.txt: Bug#38784: Mysql server crash if table is altered with partition changes. Added support for EXTRA_DEBUG sql/sql_partition.cc: Bug#38784: Mysql server crash if table is altered with partition changes. Changed from FN_LEN to FN_REFLEN since the variable was use for paths, not filenames without path. win/configure.js: Bug#38784: Mysql server crash if table is altered with partition changes. Added support for EXTRA_DEBUG --- CMakeLists.txt | 4 ++++ sql/sql_partition.cc | 22 +++++++++++----------- win/configure.js | 1 + 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7107a112f19..2f6e1236542 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,10 @@ IF(CYBOZU) ADD_DEFINITIONS(-DCYBOZU) ENDIF(CYBOZU) +IF(EXTRA_DEBUG) + ADD_DEFINITIONS(-D EXTRA_DEBUG) +ENDIF(EXTRA_DEBUG) + # in some places we use DBUG_OFF SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 5ed64ea8fd5..8eabded623c 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -5304,8 +5304,8 @@ static bool write_log_changed_partitions(ALTER_PARTITION_PARAM_TYPE *lpt, DDL_LOG_ENTRY ddl_log_entry; partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; - char tmp_path[FN_LEN]; - char normal_path[FN_LEN]; + char tmp_path[FN_REFLEN]; + char normal_path[FN_REFLEN]; List_iterator part_it(part_info->partitions); uint temp_partitions= part_info->temp_partitions.elements; uint no_elements= part_info->partitions.elements; @@ -5516,7 +5516,7 @@ static bool write_log_drop_shadow_frm(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= NULL; - char shadow_path[FN_LEN]; + char shadow_path[FN_REFLEN]; DBUG_ENTER("write_log_drop_shadow_frm"); build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt); @@ -5559,8 +5559,8 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry; - char path[FN_LEN]; - char shadow_path[FN_LEN]; + char path[FN_REFLEN]; + char shadow_path[FN_REFLEN]; DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry; DBUG_ENTER("write_log_rename_frm"); @@ -5610,8 +5610,8 @@ static bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry; - char tmp_path[FN_LEN]; - char path[FN_LEN]; + char tmp_path[FN_REFLEN]; + char path[FN_REFLEN]; uint next_entry= 0; DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry; DBUG_ENTER("write_log_drop_partition"); @@ -5669,8 +5669,8 @@ static bool write_log_add_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= NULL; - char tmp_path[FN_LEN]; - char path[FN_LEN]; + char tmp_path[FN_REFLEN]; + char path[FN_REFLEN]; uint next_entry= 0; DBUG_ENTER("write_log_add_change_partition"); @@ -5723,8 +5723,8 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry; - char path[FN_LEN]; - char shadow_path[FN_LEN]; + char path[FN_REFLEN]; + char shadow_path[FN_REFLEN]; DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry; uint next_entry= 0; DBUG_ENTER("write_log_final_change_partition"); diff --git a/win/configure.js b/win/configure.js index c86ec0cf47c..ac51b15b9f0 100644 --- a/win/configure.js +++ b/win/configure.js @@ -48,6 +48,7 @@ try case "__NT__": case "CYBOZU": case "EMBED_MANIFESTS": + case "EXTRA_DEBUG": case "WITH_EMBEDDED_SERVER": configfile.WriteLine("SET (" + args.Item(i) + " TRUE)"); break; From ab4d8812f46374061d314b35f1358525b279de4d Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Sat, 29 Nov 2008 15:36:17 +0200 Subject: [PATCH 03/11] Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of requested column When the storage engine uses secondary keys clustered with the primary key MySQL was adding the primary key parts to each secondary key. In doing so it was not checking whether the index was on full columns and this resulted in the secondary keys being added to the list of covering keys even if they have partial columns. Fixed by not adding a primary key part to the list of columns that can be used for index read of the secondary keys when the primary key part is a partial key part. mysql-test/r/innodb_mysql.result: Bug #37742: test case mysql-test/t/innodb_mysql.test: Bug #37742: test case sql/table.cc: Bug #37742: don't add the primary key part to the list of covering key parts of a secondary key if it's a partial key part. --- mysql-test/r/innodb_mysql.result | 84 ++++++++++++++++++++++++++++++++ mysql-test/t/innodb_mysql.test | 36 ++++++++++++++ sql/table.cc | 4 +- 3 files changed, 123 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 2c14b1f2385..a348c63ec81 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1677,3 +1677,87 @@ select @@session.sql_log_bin, @@session.binlog_format, @@session.tx_isolation; CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); DROP TABLE t1; +CREATE TABLE foo (a int, b int, c char(10), +PRIMARY KEY (c(3)), +KEY b (b) +) engine=innodb; +CREATE TABLE foo2 (a int, b int, c char(10), +PRIMARY KEY (c), +KEY b (b) +) engine=innodb; +CREATE TABLE bar (a int, b int, c char(10), +PRIMARY KEY (c(3)), +KEY b (b) +) engine=myisam; +INSERT INTO foo VALUES +(1,2,'abcdefghij'), (2,3,''), (3,4,'klmnopqrst'), +(4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe'); +INSERT INTO bar SELECT * FROM foo; +INSERT INTO foo2 SELECT * FROM foo; +EXPLAIN SELECT c FROM bar WHERE b>2;; +id 1 +select_type SIMPLE +table bar +type ALL +possible_keys b +key NULL +key_len NULL +ref NULL +rows 6 +Extra Using where +EXPLAIN SELECT c FROM foo WHERE b>2;; +id 1 +select_type SIMPLE +table foo +type ALL +possible_keys b +key NULL +key_len NULL +ref NULL +rows 6 +Extra Using where +EXPLAIN SELECT c FROM foo2 WHERE b>2;; +id 1 +select_type SIMPLE +table foo2 +type range +possible_keys b +key b +key_len 5 +ref NULL +rows 3 +Extra Using where; Using index +EXPLAIN SELECT c FROM bar WHERE c>2;; +id 1 +select_type SIMPLE +table bar +type ALL +possible_keys PRIMARY +key NULL +key_len NULL +ref NULL +rows 6 +Extra Using where +EXPLAIN SELECT c FROM foo WHERE c>2;; +id 1 +select_type SIMPLE +table foo +type ALL +possible_keys PRIMARY +key NULL +key_len NULL +ref NULL +rows 6 +Extra Using where +EXPLAIN SELECT c FROM foo2 WHERE c>2;; +id 1 +select_type SIMPLE +table foo2 +type index +possible_keys PRIMARY +key b +key_len 5 +ref NULL +rows 6 +Extra Using where; Using index +DROP TABLE foo, bar, foo2; diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index ed8de208474..06ebb079a1b 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -43,3 +43,39 @@ CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); DROP TABLE t1; +# +# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of +# requested column +# + +CREATE TABLE foo (a int, b int, c char(10), + PRIMARY KEY (c(3)), + KEY b (b) +) engine=innodb; + +CREATE TABLE foo2 (a int, b int, c char(10), + PRIMARY KEY (c), + KEY b (b) +) engine=innodb; + +CREATE TABLE bar (a int, b int, c char(10), + PRIMARY KEY (c(3)), + KEY b (b) +) engine=myisam; + +INSERT INTO foo VALUES + (1,2,'abcdefghij'), (2,3,''), (3,4,'klmnopqrst'), + (4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe'); + +INSERT INTO bar SELECT * FROM foo; +INSERT INTO foo2 SELECT * FROM foo; + +--query_vertical EXPLAIN SELECT c FROM bar WHERE b>2; +--query_vertical EXPLAIN SELECT c FROM foo WHERE b>2; +--query_vertical EXPLAIN SELECT c FROM foo2 WHERE b>2; + +--query_vertical EXPLAIN SELECT c FROM bar WHERE c>2; +--query_vertical EXPLAIN SELECT c FROM foo WHERE c>2; +--query_vertical EXPLAIN SELECT c FROM foo2 WHERE c>2; + +DROP TABLE foo, bar, foo2; diff --git a/sql/table.cc b/sql/table.cc index 89714e4e47e..1de47a48513 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1416,7 +1416,9 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, */ if (ha_option & HA_PRIMARY_KEY_IN_READ_INDEX) { - field->part_of_key= share->keys_in_use; + if (field->key_length() == key_part->length && + !(field->flags & BLOB_FLAG)) + field->part_of_key= share->keys_in_use; if (field->part_of_sortkey.is_set(key)) field->part_of_sortkey= share->keys_in_use; } From 71dbb4987f719e04ee49b30522fab2d8aa646dc6 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 2 Dec 2008 14:50:40 +0200 Subject: [PATCH 04/11] moved the version to 5.0-main --- .bzr-mysql/default.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 557df1b1ffe..f79c1cd6319 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,4 +1,4 @@ [MYSQL] post_commit_to = "commits@lists.mysql.com" post_push_to = "commits@lists.mysql.com" -tree_name = "mysql-5.0-bugteam" +tree_name = "mysql-5.0" From 7391280c15fda6337c24be789cc0b1a1d5b25d69 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Dec 2008 01:09:05 +0100 Subject: [PATCH 05/11] Raise version number after cloning 5.0.74 --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 83220a879f0..2d942bc7e85 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.74) +AM_INIT_AUTOMAKE(mysql, 5.0.76) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 @@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=74 +NDB_VERSION_BUILD=76 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? From 91f0c94c23eb9b48421d9590662666de9e4c75d5 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 3 Dec 2008 19:15:39 +0300 Subject: [PATCH 06/11] Fix for bug #27483: Casting 'scientific notation type' to 'unsigned bigint' fails on windows. Visual Studio does not take into account some x86 hardware limitations which leads to incorrect results when converting large DOUBLE values to BIGINT UNSIGNED ones. Fixed by adding a workaround for double->ulonglong conversion on Windows. include/config-win.h: Added double2ulonglong(double) function implementing a workaround for broken double->ulonglong conversion on Windows/x86. include/my_global.h: Define double2ulonglong() as a simple typecast for anything but Windows. mysql-test/r/type_float.result: Added a test case for bug #27483. mysql-test/t/type_float.test: Added a test case for bug #27483. --- include/config-win.h | 9 +++++++++ include/my_global.h | 3 +++ mysql-test/r/type_float.result | 13 +++++++++++++ mysql-test/t/type_float.test | 17 +++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/include/config-win.h b/include/config-win.h index 2628095a181..eba699159c7 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -245,6 +245,15 @@ inline double ulonglong2double(ulonglong value) #define my_off_t2double(A) ulonglong2double(A) #endif /* _WIN64 */ +inline ulonglong double2ulonglong(double d) +{ + double t= d - (double) 0x8000000000000000ULL; + + if (t >= 0) + return ((ulonglong) t) + 0x8000000000000000ULL; + return (ulonglong) d; +} + #if SIZEOF_OFF_T > 4 #define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C)) #define tell(A) _telli64(A) diff --git a/include/my_global.h b/include/my_global.h index e474b620d27..845ae042a42 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -713,6 +713,9 @@ typedef SOCKET_SIZE_TYPE size_socket; #define ulonglong2double(A) ((double) (ulonglong) (A)) #define my_off_t2double(A) ((double) (my_off_t) (A)) #endif +#ifndef double2ulonglong +#define double2ulonglong(A) ((ulonglong) (double) (A)) +#endif #endif #ifndef offsetof diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index f1075604ca9..e7f17bd75a7 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -392,4 +392,17 @@ f1 + 0e0 1.0000000150475e+30 -1.0000000150475e+30 drop table t1; +create table t1(d double, u bigint unsigned); +insert into t1(d) values (9.2233720368547777e+18), +(9.223372036854779e18), +(9.22337203685479e18), +(1.84e19); +update t1 set u = d; +select * from t1; +d u +9.22337203685478e+18 9223372036854775808 +9.22337203685478e+18 9223372036854779904 +9.22337203685479e+18 9223372036854790144 +1.84e+19 18400000000000000000 +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 9aa8c00d24a..b23755b44fb 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -252,4 +252,21 @@ insert into t1 values (2e30), (-2e30); select f1 + 0e0 from t1; drop table t1; +# +# Bug #27483: Casting 'scientific notation type' to 'unsigned bigint' fails on +# windows. +# + +create table t1(d double, u bigint unsigned); + +insert into t1(d) values (9.2233720368547777e+18), + (9.223372036854779e18), + (9.22337203685479e18), + (1.84e19); + +update t1 set u = d; +select * from t1; + +drop table t1; + --echo End of 5.0 tests From 43e9d5b3d561e980b41e7ebea1fc09b3ad700c74 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Wed, 3 Dec 2008 20:55:49 +0100 Subject: [PATCH 07/11] Bug #40116: Uncommited changes are replicated and stay on slave after rollback on master When starting a transaction with a statement containing changes to both transactional tables and non-transactional tables, the statement is considered as non-transactional and is therefore written directly to the binary log. This behaviour was present in 5.0, and has propagated to 5.1. If a trigger containing a change of a non-transactional table is added to a transactional table, any changes to the transactional table is "tainted" as non-transactional. This patch solves the problem by removing the existing "hack" that allows non-transactional statements appearing first in a transaction to be written directly to the binary log. Instead, anything inside a transaction is treaded as part of the transaction and not written to the binary log until the transaction is committed. mysql-test/suite/rpl/t/rpl_row_create_table.test: Removing positions from SHOW BINLOG EVENTS and using reset_master_and_slave to start on a fresh binary log each time. mysql-test/suite/rpl/t/rpl_slave_skip.test: Adding explicit commit in AUTOCOMMIT=0 to make test work correctly. mysql-test/suite/rpl/t/rpl_trigger.test: Adding test case for BUG#40116. sql/log.cc: Changing commit logic in binlog_commit() to only commit when committing a real transaction or committing a punch transaction. --- .../r/binlog_row_mix_innodb_myisam.result | 24 ++--- .../suite/rpl/r/rpl_row_create_table.result | 95 ++++++++++++------- mysql-test/suite/rpl/r/rpl_slave_skip.result | 1 + mysql-test/suite/rpl/r/rpl_trigger.result | 26 +++++ .../suite/rpl/t/rpl_row_create_table.test | 28 ++++-- mysql-test/suite/rpl/t/rpl_slave_skip.test | 1 + mysql-test/suite/rpl/t/rpl_trigger.test | 42 ++++++-- sql/log.cc | 61 +----------- 8 files changed, 152 insertions(+), 126 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result index 7106480663f..0b33d71b6f1 100644 --- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result @@ -133,10 +133,6 @@ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT insert into t1 values(11); commit; show binlog events from ; @@ -148,8 +144,6 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ @@ -278,10 +272,6 @@ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT master-bin.000001 # Query # # use `test`; drop table t1,t2 master-bin.000001 # Query # # use `test`; create table t0 (n int) master-bin.000001 # Query # # use `test`; BEGIN @@ -382,7 +372,7 @@ master-bin.000001 # Query # # use `test`; DROP TABLE if exists t2 master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # use `test`; ROLLBACK master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t2 master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb master-bin.000001 # Query # # use `test`; BEGIN @@ -395,12 +385,16 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE t2 master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; ROLLBACK master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F @@ -408,11 +402,7 @@ master-bin.000001 # Query # # use `test`; COMMIT master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # use `test`; ROLLBACK master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; TRUNCATE table t2 master-bin.000001 # Query # # use `test`; COMMIT diff --git a/mysql-test/suite/rpl/r/rpl_row_create_table.result b/mysql-test/suite/rpl/r/rpl_row_create_table.result index ad659c37b7f..5d6587a5fce 100644 --- a/mysql-test/suite/rpl/r/rpl_row_create_table.result +++ b/mysql-test/suite/rpl/r/rpl_row_create_table.result @@ -4,34 +4,39 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; +**** Resetting master and slave **** +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; CREATE TABLE t1 (a INT, b INT); CREATE TABLE t2 (a INT, b INT) ENGINE=Merge; CREATE TABLE t3 (a INT, b INT) CHARSET=utf8; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8; -SHOW BINLOG EVENTS FROM 216; +SHOW BINLOG EVENTS FROM 106; Log_name # -Pos 216 +Pos 106 Event_type Query Server_id # -End_log_pos 309 +End_log_pos 199 Info use `test`; CREATE TABLE t1 (a INT, b INT) Log_name # -Pos 309 +Pos 199 Event_type Query Server_id # -End_log_pos 415 +End_log_pos 305 Info use `test`; CREATE TABLE t2 (a INT, b INT) ENGINE=Merge Log_name # -Pos 415 +Pos 305 Event_type Query Server_id # -End_log_pos 521 +End_log_pos 411 Info use `test`; CREATE TABLE t3 (a INT, b INT) CHARSET=utf8 Log_name # -Pos 521 +Pos 411 Event_type Query Server_id # -End_log_pos 640 +End_log_pos 530 Info use `test`; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8 **** On Master **** SHOW CREATE TABLE t1; @@ -125,9 +130,14 @@ NULL 3 6 NULL 4 2 NULL 5 10 NULL 6 12 +**** Resetting master and slave **** +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; ERROR 23000: Duplicate entry '2' for key 'b' -SHOW BINLOG EVENTS FROM 1374; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info CREATE TABLE t7 (a INT, b INT UNIQUE); INSERT INTO t7 SELECT a,b FROM tt3; @@ -137,18 +147,23 @@ a b 1 2 2 4 3 6 -SHOW BINLOG EVENTS FROM 1374; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 1374 Query # 1474 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) -# 1474 Query # 1542 use `test`; BEGIN -# 1542 Table_map # 1584 table_id: # (test.t7) -# 1584 Write_rows # 1640 table_id: # flags: STMT_END_F -# 1640 Query # 1711 use `test`; ROLLBACK +# 106 Query # 206 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) +# 206 Query # 274 use `test`; BEGIN +# 274 Table_map # 316 table_id: # (test.t7) +# 316 Write_rows # 372 table_id: # flags: STMT_END_F +# 372 Query # 443 use `test`; ROLLBACK SELECT * FROM t7 ORDER BY a,b; a b 1 2 2 4 3 6 +**** Resetting master and slave **** +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; CREATE TEMPORARY TABLE tt4 (a INT, b INT); INSERT INTO tt4 VALUES (4,8), (5,10), (6,12); BEGIN; @@ -156,12 +171,12 @@ INSERT INTO t7 SELECT a,b FROM tt4; ROLLBACK; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back -SHOW BINLOG EVENTS FROM 1711; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 1711 Query # 1779 use `test`; BEGIN -# 1779 Table_map # 1821 table_id: # (test.t7) -# 1821 Write_rows # 1877 table_id: # flags: STMT_END_F -# 1877 Query # 1946 use `test`; COMMIT +# 106 Query # 174 use `test`; BEGIN +# 174 Table_map # 216 table_id: # (test.t7) +# 216 Write_rows # 272 table_id: # flags: STMT_END_F +# 272 Query # 343 use `test`; ROLLBACK SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -178,6 +193,11 @@ a b 4 8 5 10 6 12 +**** Resetting master and slave **** +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; CREATE TABLE t8 LIKE t4; CREATE TABLE t9 LIKE tt4; CREATE TEMPORARY TABLE tt5 LIKE t4; @@ -196,10 +216,10 @@ Create Table CREATE TABLE `t9` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -SHOW BINLOG EVENTS FROM 1946; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 1946 Query # 2032 use `test`; CREATE TABLE t8 LIKE t4 -# 2032 Query # 2171 use `test`; CREATE TABLE `t9` ( +# 106 Query # 192 use `test`; CREATE TABLE t8 LIKE t4 +# 192 Query # 331 use `test`; CREATE TABLE `t9` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL ) @@ -276,9 +296,8 @@ a 1 2 3 -SHOW BINLOG EVENTS; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 4 Format_desc # 106 Server ver: #, Binlog ver: # # 106 Query # 192 use `test`; CREATE TABLE t1 (a INT) # 192 Query # 260 use `test`; BEGIN # 260 Table_map # 301 table_id: # (test.t1) @@ -308,7 +327,7 @@ Log_name Pos Event_type Server_id End_log_pos Info # 1329 Query # 1397 use `test`; BEGIN # 1397 Table_map # 1438 table_id: # (test.t1) # 1438 Write_rows # 1482 table_id: # flags: STMT_END_F -# 1482 Query # 1551 use `test`; COMMIT +# 1482 Query # 1553 use `test`; ROLLBACK SHOW TABLES; Tables_in_test t1 @@ -371,9 +390,8 @@ a 4 6 9 -SHOW BINLOG EVENTS; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 4 Format_desc # 106 Server ver: #, Binlog ver: # # 106 Query # 192 use `test`; CREATE TABLE t1 (a INT) # 192 Query # 260 use `test`; BEGIN # 260 Table_map # 301 table_id: # (test.t1) @@ -394,6 +412,11 @@ a 6 9 TRUNCATE TABLE t2; +**** Resetting master and slave **** +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; BEGIN; INSERT INTO t2 SELECT a*a FROM t1; CREATE TEMPORARY TABLE tt2 @@ -406,14 +429,14 @@ Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back SELECT * FROM t2 ORDER BY a; a -SHOW BINLOG EVENTS FROM 949; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 949 Query # 1017 use `test`; BEGIN -# 1017 Table_map # 1058 table_id: # (test.t2) -# 1058 Write_rows # 1102 table_id: # flags: STMT_END_F -# 1102 Table_map # 1143 table_id: # (test.t2) -# 1143 Write_rows # 1182 table_id: # flags: STMT_END_F -# 1182 Query # 1253 use `test`; ROLLBACK +# 106 Query # 174 use `test`; BEGIN +# 174 Table_map # 215 table_id: # (test.t2) +# 215 Write_rows # 259 table_id: # flags: STMT_END_F +# 259 Table_map # 300 table_id: # (test.t2) +# 300 Write_rows # 339 table_id: # flags: STMT_END_F +# 339 Query # 410 use `test`; ROLLBACK SELECT * FROM t2 ORDER BY a; a DROP TABLE t1,t2; diff --git a/mysql-test/suite/rpl/r/rpl_slave_skip.result b/mysql-test/suite/rpl/r/rpl_slave_skip.result index bb03c3b6cca..9784d6372d2 100644 --- a/mysql-test/suite/rpl/r/rpl_slave_skip.result +++ b/mysql-test/suite/rpl/r/rpl_slave_skip.result @@ -174,6 +174,7 @@ DROP TRIGGER tr2; INSERT INTO t1 VALUES (3,'master/slave'); INSERT INTO t2 VALUES (3,'master/slave'); INSERT INTO t3 VALUES (3,'master/slave'); +COMMIT; SELECT * FROM t1 ORDER BY a; a b 2 master only diff --git a/mysql-test/suite/rpl/r/rpl_trigger.result b/mysql-test/suite/rpl/r/rpl_trigger.result index 68c82ed037f..5cc75013bf7 100644 --- a/mysql-test/suite/rpl/r/rpl_trigger.result +++ b/mysql-test/suite/rpl/r/rpl_trigger.result @@ -975,3 +975,29 @@ a b 2 b 3 c drop table t1; +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 ( f int ) engine = innodb; +create table log ( r int ) engine = myisam; +create trigger tr +after insert on t1 +for each row insert into log values ( new.f ); +set autocommit = 0; +insert into t1 values ( 1 ); +select * from t1; +f +1 +select * from t1; +f +rollback; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +select * from t1; +f +select * from t1; +f +drop table t1, log; diff --git a/mysql-test/suite/rpl/t/rpl_row_create_table.test b/mysql-test/suite/rpl/t/rpl_row_create_table.test index 3fb5aa8e1f2..d74eb873270 100644 --- a/mysql-test/suite/rpl/t/rpl_row_create_table.test +++ b/mysql-test/suite/rpl/t/rpl_row_create_table.test @@ -29,6 +29,8 @@ SET GLOBAL storage_engine=memory; START SLAVE; --enable_query_log +--source include/reset_master_and_slave.inc + connection master; CREATE TABLE t1 (a INT, b INT); CREATE TABLE t2 (a INT, b INT) ENGINE=Merge; @@ -36,7 +38,7 @@ CREATE TABLE t3 (a INT, b INT) CHARSET=utf8; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8; --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ ---query_vertical SHOW BINLOG EVENTS FROM 216 +--query_vertical SHOW BINLOG EVENTS FROM 106 --echo **** On Master **** --query_vertical SHOW CREATE TABLE t1 --query_vertical SHOW CREATE TABLE t2 @@ -65,6 +67,8 @@ SELECT * FROM t5 ORDER BY a,b,c; --query_vertical SHOW CREATE TABLE t6 SELECT * FROM t6 ORDER BY a,b,c; +--source include/reset_master_and_slave.inc + connection master; # Test for erroneous constructions --error ER_DUP_ENTRY @@ -72,7 +76,7 @@ CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; # Shouldn't be written to the binary log --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1374; +SHOW BINLOG EVENTS FROM 106; # Test that INSERT-SELECT works the same way as for SBR. CREATE TABLE t7 (a INT, b INT UNIQUE); @@ -82,10 +86,12 @@ SELECT * FROM t7 ORDER BY a,b; # Should be written to the binary log --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1374; +SHOW BINLOG EVENTS FROM 106; sync_slave_with_master; SELECT * FROM t7 ORDER BY a,b; +--source include/reset_master_and_slave.inc + connection master; CREATE TEMPORARY TABLE tt4 (a INT, b INT); INSERT INTO tt4 VALUES (4,8), (5,10), (6,12); @@ -94,11 +100,13 @@ INSERT INTO t7 SELECT a,b FROM tt4; ROLLBACK; --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1711; +SHOW BINLOG EVENTS FROM 106; SELECT * FROM t7 ORDER BY a,b; sync_slave_with_master; SELECT * FROM t7 ORDER BY a,b; +--source include/reset_master_and_slave.inc + connection master; CREATE TABLE t8 LIKE t4; CREATE TABLE t9 LIKE tt4; @@ -110,7 +118,7 @@ CREATE TEMPORARY TABLE tt7 SELECT 1; --query_vertical SHOW CREATE TABLE t9 --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1946; +SHOW BINLOG EVENTS FROM 106; sync_slave_with_master; --echo **** On Slave **** --query_vertical SHOW CREATE TABLE t8 @@ -162,7 +170,7 @@ SELECT * FROM t3 ORDER BY a; SELECT * FROM t4 ORDER BY a; --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS; +SHOW BINLOG EVENTS FROM 106; sync_slave_with_master; SHOW TABLES; SELECT TABLE_NAME,ENGINE @@ -208,13 +216,17 @@ COMMIT; SELECT * FROM t2 ORDER BY a; --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS; +SHOW BINLOG EVENTS FROM 106; sync_slave_with_master; SELECT * FROM t2 ORDER BY a; connection master; TRUNCATE TABLE t2; +sync_slave_with_master; +--source include/reset_master_and_slave.inc + +connection master; BEGIN; INSERT INTO t2 SELECT a*a FROM t1; CREATE TEMPORARY TABLE tt2 @@ -227,7 +239,7 @@ ROLLBACK; SELECT * FROM t2 ORDER BY a; --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 949; +SHOW BINLOG EVENTS FROM 106; sync_slave_with_master; SELECT * FROM t2 ORDER BY a; diff --git a/mysql-test/suite/rpl/t/rpl_slave_skip.test b/mysql-test/suite/rpl/t/rpl_slave_skip.test index 8a5b1ae0ae4..da25e5631c0 100644 --- a/mysql-test/suite/rpl/t/rpl_slave_skip.test +++ b/mysql-test/suite/rpl/t/rpl_slave_skip.test @@ -121,6 +121,7 @@ DROP TRIGGER tr2; INSERT INTO t1 VALUES (3,'master/slave'); INSERT INTO t2 VALUES (3,'master/slave'); INSERT INTO t3 VALUES (3,'master/slave'); +COMMIT; SELECT * FROM t1 ORDER BY a; SELECT * FROM t2 ORDER BY a; diff --git a/mysql-test/suite/rpl/t/rpl_trigger.test b/mysql-test/suite/rpl/t/rpl_trigger.test index 911110d17dc..8e911178dcc 100644 --- a/mysql-test/suite/rpl/t/rpl_trigger.test +++ b/mysql-test/suite/rpl/t/rpl_trigger.test @@ -467,20 +467,46 @@ drop trigger if exists t1_bi; insert into t1 values (3, "c"); select * from t1; - -save_master_pos; -connection slave; -sync_with_master; - +sync_slave_with_master; select * from t1; connection master; drop table t1; +sync_slave_with_master; + +# +# Bug#40116: Uncommited changes are replicated and stay on slave after +# rollback on master +# + +source include/master-slave-reset.inc; +source include/have_innodb.inc; + +connection master; +create table t1 ( f int ) engine = innodb; +create table log ( r int ) engine = myisam; +create trigger tr + after insert on t1 + for each row insert into log values ( new.f ); + +set autocommit = 0; +insert into t1 values ( 1 ); + +select * from t1; +sync_slave_with_master; +select * from t1; + +connection master; +rollback; +select * from t1; +sync_slave_with_master; +select * from t1; + +connection master; +drop table t1, log; +sync_slave_with_master; # # End of tests # -save_master_pos; -connection slave; -sync_with_master; diff --git a/sql/log.cc b/sql/log.cc index fb8669a5731..3ebf2a7c03e 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1478,60 +1478,11 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) } /* - Decision table for committing a transaction. The top part, the - *conditions* represent different cases that can occur, and hte - bottom part, the *actions*, represent what should be done in that - particular case. + We commit the transaction if: - Real transaction 'all' was true + - We are not in a transaction and committing a statement, or - Statement in cache There were at least one statement in the - transaction cache - - In transaction We are inside a transaction - - Stmt modified non-trans The statement being committed modified a - non-transactional table - - All modified non-trans Some statement before this one in the - transaction modified a non-transactional - table - - - ============================= = = = = = = = = = = = = = = = = - Real transaction N N N N N N N N N N N N N N N N - Statement in cache N N N N N N N N Y Y Y Y Y Y Y Y - In transaction N N N N Y Y Y Y N N N N Y Y Y Y - Stmt modified non-trans N N Y Y N N Y Y N N Y Y N N Y Y - All modified non-trans N Y N Y N Y N Y N Y N Y N Y N Y - - Action: (C)ommit/(A)ccumulate C C - C A C - C - - - - A A - A - ============================= = = = = = = = = = = = = = = = = - - - ============================= = = = = = = = = = = = = = = = = - Real transaction Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y - Statement in cache N N N N N N N N Y Y Y Y Y Y Y Y - In transaction N N N N Y Y Y Y N N N N Y Y Y Y - Stmt modified non-trans N N Y Y N N Y Y N N Y Y N N Y Y - All modified non-trans N Y N Y N Y N Y N Y N Y N Y N Y - - (C)ommit/(A)ccumulate/(-) - - - - C C - C - - - - C C - C - ============================= = = = = = = = = = = = = = = = = - - In other words, we commit the transaction if and only if both of - the following are true: - - We are not in a transaction and committing a statement - - - We are in a transaction and one (or more) of the following are - true: - - - A full transaction is committed - - OR - - - A non-transactional statement is committed and there is - no statement cached + - We are in a transaction and a full transaction is committed Otherwise, we accumulate the statement */ @@ -1544,11 +1495,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) YESNO(in_transaction), YESNO(thd->transaction.all.modified_non_trans_table), YESNO(thd->transaction.stmt.modified_non_trans_table))); - if (in_transaction && - (all || - (!trx_data->at_least_one_stmt && - thd->transaction.stmt.modified_non_trans_table)) || - !in_transaction && !all) + if (!in_transaction || all) { Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE); qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE) From 6d717c21e7588e38812537ce11e636d3e4a5cd6b Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Thu, 4 Dec 2008 18:36:45 +0200 Subject: [PATCH 08/11] Bug #33420 Test 'rpl_packet' fails randomly with changed "Exec_Master_Log_Pos" Bug #41173 rpl_packet fails sporadically on pushbuild: query 'DROP TABLE t1' failed The both issues appeared to be a race between the SQL thread executing CREATE table t1 and the IO thread that is expected to stop at the consequent big size event. The two events need serialization which is implemented. The early bug required back-porting a part fixes for bug#38350 exclusively for 5.0 version. mysql-test/r/rpl_packet.result: results changed due to bug#33420, bug#41173. mysql-test/t/rpl_packet.test: adding synchronization for sql and io thread (bug#41173 problem). simplifying the output to show only a relevant info (5.0 sole problem bug#33420). --- mysql-test/r/rpl_packet.result | 40 +++++----------------------------- mysql-test/t/rpl_packet.test | 22 ++++++++++++++----- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/mysql-test/r/rpl_packet.result b/mysql-test/r/rpl_packet.result index 88c63994fff..f84ce18810e 100644 --- a/mysql-test/r/rpl_packet.result +++ b/mysql-test/r/rpl_packet.result @@ -23,39 +23,9 @@ SET @@global.max_allowed_packet=4096; SET @@global.net_buffer_length=4096; STOP SLAVE; START SLAVE; -CREATE TABLe `t1` (`f1` LONGTEXT) ENGINE=MyISAM; +CREATE TABLE `t1` (`f1` LONGTEXT) ENGINE=MyISAM; INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048'); -show slave status; -Slave_IO_State # -Master_Host 127.0.0.1 -Master_User root -Master_Port MASTER_MYPORT -Connect_Retry 1 -Master_Log_File master-bin.000001 -Read_Master_Log_Pos 2138 -Relay_Log_File # -Relay_Log_Pos # -Relay_Master_Log_File master-bin.000001 -Slave_IO_Running No -Slave_SQL_Running # -Replicate_Do_DB -Replicate_Ignore_DB -Replicate_Do_Table -Replicate_Ignore_Table -Replicate_Wild_Do_Table -Replicate_Wild_Ignore_Table -Last_Errno 0 -Last_Error -Skip_Counter 0 -Exec_Master_Log_Pos 2138 -Relay_Log_Space # -Until_Condition None -Until_Log_File -Until_Log_Pos 0 -Master_SSL_Allowed No -Master_SSL_CA_File -Master_SSL_CA_Path -Master_SSL_Cert -Master_SSL_Cipher -Master_SSL_Key -Seconds_Behind_Master # +Slave_IO_Running = No (expect No) +==== clean up ==== +DROP TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/t/rpl_packet.test b/mysql-test/t/rpl_packet.test index a3efdf24bce..f7066c93b30 100644 --- a/mysql-test/t/rpl_packet.test +++ b/mysql-test/t/rpl_packet.test @@ -73,16 +73,26 @@ disconnect master; connect (master, localhost, root); connection master; -CREATE TABLe `t1` (`f1` LONGTEXT) ENGINE=MyISAM; +CREATE TABLE `t1` (`f1` LONGTEXT) ENGINE=MyISAM; + +sync_slave_with_master; + +connection master; INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048'); # The slave I/O thread must stop after trying to read the above event connection slave; ---source include/wait_for_slave_io_to_stop.inc ---replace_result $MASTER_MYPORT MASTER_MYPORT -# import is only the 11th column Slave_IO_Running ---replace_column 1 # 8 # 9 # 12 # 23 # 33 # -query_vertical show slave status; +--source include/wait_for_slave_io_to_stop.inc +let $slave_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1); +--echo Slave_IO_Running = $slave_io_running (expect No) + + +--echo ==== clean up ==== +connection master; +DROP TABLE t1; +# slave is stopped +connection slave; +DROP TABLE t1; # End of tests From 8f500c522b5b38b55204031a90977c2c087ffd5c Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 4 Dec 2008 19:41:53 +0100 Subject: [PATCH 09/11] Bug#38522: 5 seconds delay when closing application using embedded server The problem here is that embedded server starts handle_thread manager thread on mysql_library_init() does not stop it on mysql_library_end(). At shutdown, my_thread_global_end() waits for thread count to become 0, but since we did not stop the thread it will give up after 5 seconds. Solution is to move shutdown for handle_manager thread from kill_server() (mysqld specific) to clean_up() that is used by both embedded and mysqld. This patch also contains some refactorings - to avoid duplicate code, start_handle_manager() and stop_handle_manager() functions are introduced. Unused variables are eliminated. handle_manager does not rely on global variable abort_loop anymore to stop (abort_loop is not set for embedded). Note: Specifically on Windows and when using DBUG version of libmysqld, the complete solution requires removing obsolete code my_thread_init() from my_thread_var(). This has a side effect that a DBUG statement after my_thread_end() can cause thread counter to be incremented, and embedded will hang for some seconds. Or worse, my_thread_init() will crash if critical sections have been deleted by the global cleanup routine that runs in a different thread. This patch also fixes and revert prior changes for Bug#38293 "Libmysqld crash in mysql_library_init if language file missing". Root cause of the crash observed in Bug#38293 was bug in my_thread_init() described above client/mysql.cc: sql_protocol_typelib is not exported from libmysqld (does not make sense either) thus excluded from embedded client dbug/dbug.c: revert changes for Bug#38293 include/my_dbug.h: revert changes for Bug#38293 libmysql/libmysql.c: Removed DBUG_POP call, because when called after my_end(), will access THR_key_mysys that is already deleted. The result of pthread_get_specific is not predictable in this case and hence DBUG_POP can crash. libmysqld/examples/CMakeLists.txt: Revert changes for Bug#38293. libmysqld/lib_sql.cc: code to start handle manager is factored out into start_handle_manager() function libmysqld/libmysqld.def: Revert changes for Bug #38293 Remove excessive exports from libmysqld, export what API documents. mysys/my_thr_init.c: Remove windows-DLL-specific workaround for something (old code, no documentation for what specifically). The problem is that even after my_thread_end() is finished, DBUG statement can initiate my_thread_init(). This does not happen anywhere else and should not happen on Windows either. sql/mysql_priv.h: - new functions start_handle_manager() and stop_handle_manager() - move manager_thread_in_use variable to sql_manager.cc and made it static - remove manager_status, as it is unused sql/mysqld.cc: Code to start/stop handle_manager thread is factored out into start_handle_manager() --- client/mysql.cc | 2 + dbug/dbug.c | 17 +--- include/my_dbug.h | 16 ---- libmysql/libmysql.c | 4 +- libmysqld/examples/CMakeLists.txt | 6 +- libmysqld/lib_sql.cc | 8 +- libmysqld/libmysqld.def | 126 ------------------------------ mysys/my_thr_init.c | 12 +-- sql/mysql_priv.h | 7 +- sql/mysqld.cc | 24 +----- sql/sql_manager.cc | 54 ++++++++++--- 11 files changed, 56 insertions(+), 220 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 024194d81f6..ff53d623d07 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1627,8 +1627,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_nopager= 1; break; case OPT_MYSQL_PROTOCOL: +#ifndef EMBEDDED_LIBRARY opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, opt->name); +#endif break; case OPT_SERVER_ARG: #ifdef EMBEDDED_LIBRARY diff --git a/dbug/dbug.c b/dbug/dbug.c index bbd1abb9598..baf080f5e27 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -1851,13 +1851,7 @@ static void DBUGOpenFile(CODE_STATE *cs, else { newfile= !EXISTS(name); - if (!(fp= fopen(name, -#if defined(MSDOS) || defined(__WIN__) - append ? "a+c" : "wc" -#else - append ? "a+" : "w" -#endif - ))) + if (!(fp= fopen(name, append ? "a+" : "w"))) { (void) fprintf(stderr, ERR_OPEN, cs->process, name); perror(""); @@ -2407,13 +2401,4 @@ int i_am_a_dummy_function() { return 0; } -#ifdef __WIN__ -char _db_doprnt_; -char _db_enter_; -char _db_pargs_; -char _db_process_; -char _db_push_; -char _db_return_; -#endif /*__WIN__*/ - #endif diff --git a/include/my_dbug.h b/include/my_dbug.h index fa7941faf1c..a77e439b5db 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -108,22 +108,6 @@ extern FILE *_db_fp_(void); #define DBUG_EXPLAIN(buf,len) #define DBUG_EXPLAIN_INITIAL(buf,len) #define IF_DBUG(A) - -#ifdef __WIN__ -/* - On windows all the dll export has to be declared in the *.def file - so as we export these symbols in DEBUG mode we have to export - these in the RELEASE mode also. So below are the dummy symbols - for the RELEASE export -*/ -extern char _db_doprnt_; -extern char _db_enter_; -extern char _db_pargs_; -extern char _db_process_; -extern char _db_push_; -extern char _db_return_; -#endif /*__WIN__*/ - #endif #ifdef __cplusplus } diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 1eab4199deb..ca329eadf0f 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -207,9 +207,7 @@ void STDCALL mysql_server_end() /* If library called my_init(), free memory allocated by it */ if (!org_my_init_done) { - my_end(MY_DONT_FREE_DBUG); - /* Remove TRACING, if enabled by mysql_debug() */ - DBUG_POP(); + my_end(0); } else { diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index 137dd11d28e..346278425a7 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -29,13 +29,13 @@ ADD_DEFINITIONS(-DEMBEDDED_LIBRARY) ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc ../../client/mysql.cc ../../client/readline.cc ../../client/sql_string.cc) -TARGET_LINK_LIBRARIES(mysql_embedded wsock32) +TARGET_LINK_LIBRARIES(mysql_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32) ADD_DEPENDENCIES(mysql_embedded libmysqld) ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.c) -TARGET_LINK_LIBRARIES(mysqltest_embedded wsock32) +TARGET_LINK_LIBRARIES(mysqltest_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32) ADD_DEPENDENCIES(mysqltest_embedded libmysqld) ADD_EXECUTABLE(mysql_client_test_embedded ../../tests/mysql_client_test.c) -TARGET_LINK_LIBRARIES(mysql_client_test_embedded wsock32) +TARGET_LINK_LIBRARIES(mysql_client_test_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32) ADD_DEPENDENCIES(mysql_client_test_embedded libmysqld) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index e78c656d565..23572ad4929 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -386,6 +386,7 @@ static void emb_free_embedded_thd(MYSQL *mysql) thd->store_globals(); thd->unlink(); delete thd; + my_pthread_setspecific_ptr(THR_THD, 0); mysql->thd=0; } @@ -539,12 +540,7 @@ int init_embedded_server(int argc, char **argv, char **groups) (void) thr_setconcurrency(concurrency); // 10 by default - if (flush_time && flush_time != ~(ulong) 0L) - { - pthread_t hThread; - if (pthread_create(&hThread,&connection_attrib,handle_manager,0)) - sql_print_error("Warning: Can't create thread to manage maintenance"); - } + start_handle_manager(); // FIXME initialize binlog_filter and rpl_filter if not already done // corresponding delete is in clean_up() diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def index 865475cb56c..047cfe0fe57 100644 --- a/libmysqld/libmysqld.def +++ b/libmysqld/libmysqld.def @@ -2,94 +2,6 @@ LIBRARY LIBMYSQLD DESCRIPTION 'MySQL 5.1 Embedded Server Library' VERSION 5.1 EXPORTS - _db_process_ - _db_enter_ - _db_return_ - _db_push_ - _db_doprnt_ - _db_pargs_ - strnmov - get_charset - my_memmem - my_snprintf - pthread_exit - pthread_cond_signal - dynstr_append_mem - init_dynamic_string - dynstr_free - my_hash_free - my_vsnprintf - dynstr_append - my_close - my_open - dynstr_set - dynstr_append_os_quoted - my_delete - my_seek - my_write - create_temp_file - fn_format - dirname_part - my_hash_insert - my_hash_search - test_if_hard_path - my_copy - my_mkdir - my_sleep - my_strtod - pthread_cond_wait - my_strnncoll_simple - get_dynamic - my_regerror - init_dynamic_array2 - pthread_create - pthread_cond_init - my_regcomp - my_regexec - my_regex_end - my_regfree - longlong2str - my_set_exception_pointers - my_print_stacktrace - my_thread_stack_size - my_safe_print_str - my_stat - _my_hash_init - pthread_attr_setstacksize - pthread_attr_init - my_dirend - wild_compare - my_dir - my_micro_time - find_type_or_exit - _dig_vec_upper - _dig_vec_lower - bmove_upp - delete_dynamic - free_defaults - getopt_compare_strings - getopt_ull_limit_value - handle_options - init_dynamic_array - insert_dynamic - int2str - is_prefix - list_add - list_delete - load_defaults - max_allowed_packet - my_cgets - my_end - my_getopt_print_errors - my_init - my_malloc - my_memdup - my_no_flags_free - my_path - my_print_help - my_print_variables - my_realloc - my_strdup mysql_thread_end mysql_thread_init myodbc_remove_escape @@ -162,47 +74,13 @@ EXPORTS mysql_thread_safe mysql_use_result mysql_warning_count - set_dynamic - strcend - strcont - strdup_root - strfill - strinstr - strmake - strmov - strxmov mysql_server_end mysql_server_init get_tty_password - sql_protocol_typelib mysql_get_server_version mysql_set_character_set mysql_sqlstate - charsets_dir - disabled_my_option - my_charset_latin1 - init_alloc_root - my_progname - get_charset_name - get_charset_by_csname - print_defaults - find_type - strxnmov - strend - my_fopen - my_fclose - unpack_filename - str2int - int10_to_str - longlong10_to_str - my_snprintf_8bit - alloc_root - free_root - my_read - llstr mysql_get_parameters - mysql_thread_init - mysql_thread_end mysql_stmt_bind_param mysql_stmt_bind_result mysql_stmt_execute @@ -230,7 +108,3 @@ EXPORTS mysql_stmt_attr_get mysql_stmt_attr_set mysql_stmt_field_count - get_defaults_options - my_charset_bin - my_charset_same - modify_defaults_file diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 933674fa007..2278c467f32 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -368,17 +368,7 @@ void my_thread_end(void) struct st_my_thread_var *_my_thread_var(void) { - struct st_my_thread_var *tmp= - my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); -#if defined(USE_TLS) - /* This can only happen in a .DLL */ - if (!tmp) - { - my_thread_init(); - tmp=my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); - } -#endif - return tmp; + return my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 1d5c08c7c56..0d276cce177 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1768,10 +1768,9 @@ int mysql_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, int write_record(THD *thd, TABLE *table, COPY_INFO *info); /* sql_manager.cc */ -extern ulong volatile manager_status; -extern bool volatile manager_thread_in_use, mqh_used; -extern pthread_t manager_thread; -pthread_handler_t handle_manager(void *arg); +extern bool volatile mqh_used; +void start_handle_manager(); +void stop_handle_manager(); bool mysql_manager_submit(void (*action)()); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e6980318a66..7ff2b9e7dff 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -784,16 +784,6 @@ static void close_connections(void) kill_cached_threads++; flush_thread_cache(); - /* kill flush thread */ - (void) pthread_mutex_lock(&LOCK_manager); - if (manager_thread_in_use) - { - DBUG_PRINT("quit", ("killing manager thread: 0x%lx", - (ulong)manager_thread)); - (void) pthread_cond_signal(&COND_manager); - } - (void) pthread_mutex_unlock(&LOCK_manager); - /* kill connection thread */ #if !defined(__WIN__) && !defined(__NETWARE__) DBUG_PRINT("quit", ("waiting for select thread: 0x%lx", @@ -1196,6 +1186,7 @@ void clean_up(bool print_message) if (cleanup_done++) return; /* purecov: inspected */ + stop_handle_manager(); release_ddl_log(); /* @@ -4038,17 +4029,6 @@ server."); #ifndef EMBEDDED_LIBRARY -static void create_maintenance_thread() -{ - if (flush_time && flush_time != ~(ulong) 0L) - { - pthread_t hThread; - if (pthread_create(&hThread,&connection_attrib,handle_manager,0)) - sql_print_warning("Can't create thread to manage maintenance"); - } -} - - static void create_shutdown_thread() { #ifdef __WIN__ @@ -4363,7 +4343,7 @@ we force server id to 2, but this MySQL server will not act as a slave."); execute_ddl_log_recovery(); create_shutdown_thread(); - create_maintenance_thread(); + start_handle_manager(); if (Events::init(opt_noacl)) unireg_abort(1); diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc index 171ab55145a..b082f65bfb9 100644 --- a/sql/sql_manager.cc +++ b/sql/sql_manager.cc @@ -23,8 +23,9 @@ #include "mysql_priv.h" -ulong volatile manager_status; -bool volatile manager_thread_in_use; + +static bool volatile manager_thread_in_use; +static bool abort_manager; pthread_t manager_thread; pthread_mutex_t LOCK_manager; @@ -63,7 +64,6 @@ bool mysql_manager_submit(void (*action)()) pthread_handler_t handle_manager(void *arg __attribute__((unused))) { int error = 0; - ulong status; struct timespec abstime; bool reset_flush_time = TRUE; struct handler_cb *cb= NULL; @@ -72,7 +72,6 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused))) pthread_detach_this_thread(); manager_thread = pthread_self(); - manager_status = 0; manager_thread_in_use = 1; for (;;) @@ -87,16 +86,14 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused))) set_timespec(abstime, flush_time); reset_flush_time = FALSE; } - while (!manager_status && (!error || error == EINTR) && !abort_loop) + while ((!error || error == EINTR) && !abort_manager) error= pthread_cond_timedwait(&COND_manager, &LOCK_manager, &abstime); } else { - while (!manager_status && (!error || error == EINTR) && !abort_loop) + while ((!error || error == EINTR) && !abort_manager) error= pthread_cond_wait(&COND_manager, &LOCK_manager); } - status = manager_status; - manager_status = 0; if (cb == NULL) { cb= cb_list; @@ -104,7 +101,7 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused))) } pthread_mutex_unlock(&LOCK_manager); - if (abort_loop) + if (abort_manager) break; if (error == ETIMEDOUT || error == ETIME) @@ -121,11 +118,42 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused))) my_free((uchar*)cb, MYF(0)); cb= next; } - - if (status) - DBUG_PRINT("error", ("manager did not handle something: %lx", status)); } manager_thread_in_use = 0; + DBUG_LEAVE; // Can't use DBUG_RETURN after my_thread_end my_thread_end(); - DBUG_RETURN(NULL); + return (NULL); } + + +/* Start handle manager thread */ +void start_handle_manager() +{ + DBUG_ENTER("start_handle_manager"); + abort_manager = false; + if (flush_time && flush_time != ~(ulong) 0L) + { + pthread_t hThread; + if (pthread_create(&hThread,&connection_attrib,handle_manager,0)) + sql_print_warning("Can't create handle_manager thread"); + } + DBUG_VOID_RETURN; +} + + +/* Initiate shutdown of handle manager thread */ +void stop_handle_manager() +{ + DBUG_ENTER("stop_handle_manager"); + abort_manager = true; + pthread_mutex_lock(&LOCK_manager); + if (manager_thread_in_use) + { + DBUG_PRINT("quit", ("initiate shutdown of handle manager thread: 0x%lx", + (ulong)manager_thread)); + pthread_cond_signal(&COND_manager); + } + pthread_mutex_unlock(&LOCK_manager); + DBUG_VOID_RETURN; +} + From 832770842e85048bb56b99a1dd448dbda59593a8 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Fri, 5 Dec 2008 10:23:27 +0100 Subject: [PATCH 10/11] Bug #40116: Uncommited changes are replicated and stay on slave after rollback on master Making test slightly more generic and robust. mysql-test/suite/rpl/t/rpl_trigger.test: Adding code to check that InnoDB is available on slave as well. Making code slightly more generic. --- mysql-test/suite/rpl/r/rpl_trigger.result | 11 ++--------- mysql-test/suite/rpl/t/rpl_trigger.test | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_trigger.result b/mysql-test/suite/rpl/r/rpl_trigger.result index 5cc75013bf7..b68af8f4afe 100644 --- a/mysql-test/suite/rpl/r/rpl_trigger.result +++ b/mysql-test/suite/rpl/r/rpl_trigger.result @@ -988,16 +988,9 @@ after insert on t1 for each row insert into log values ( new.f ); set autocommit = 0; insert into t1 values ( 1 ); -select * from t1; -f -1 -select * from t1; -f rollback; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back -select * from t1; -f -select * from t1; -f +Comparing tables master:test.t1 and slave:test.t1 +Comparing tables master:test.log and slave:test.log drop table t1, log; diff --git a/mysql-test/suite/rpl/t/rpl_trigger.test b/mysql-test/suite/rpl/t/rpl_trigger.test index 8e911178dcc..d63eafe56a7 100644 --- a/mysql-test/suite/rpl/t/rpl_trigger.test +++ b/mysql-test/suite/rpl/t/rpl_trigger.test @@ -480,8 +480,11 @@ sync_slave_with_master; # rollback on master # +connection master; source include/master-slave-reset.inc; source include/have_innodb.inc; +connection slave; +source include/have_innodb.inc; connection master; create table t1 ( f int ) engine = innodb; @@ -492,16 +495,15 @@ create trigger tr set autocommit = 0; insert into t1 values ( 1 ); - -select * from t1; -sync_slave_with_master; -select * from t1; - -connection master; rollback; -select * from t1; -sync_slave_with_master; -select * from t1; + +let $diff_table_1=master:test.t1; +let $diff_table_2=slave:test.t1; +--source include/diff_tables.inc + +let $diff_table_1=master:test.log; +let $diff_table_2=slave:test.log; +--source include/diff_tables.inc connection master; drop table t1, log; From 1bb6a0ba9f64ec5869d6d75a6e747379cd0842fe Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 5 Dec 2008 13:24:19 +0200 Subject: [PATCH 11/11] Disable wait_timeout_func and report bug #41255. --- mysql-test/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index c01bb4b9e44..5de0a435ba5 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -12,3 +12,4 @@ federated_transactions : Bug#29523 Transactions do not work log_tables.test : Bug #37798: main.log_tables fails randomly on powermacg5 and windows slow_query_log_func.test : Bug #37962: *_func tests containing sleeps/race conditions +wait_timeout_func : Bug #41225 joro wait_timeout_func fails