From 8fb10c24d74cbddbfd6da0b5f4ea9409f8f88e57 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 9 Sep 2011 19:44:07 +0300 Subject: Fixed that automatic killing of delayed insert thread (in flush, alter table etc) will not abort auto-repair of MyISAM table. Give more information when finding an error in a MyISAM table. When killing system thread, use KILL_SYSTEM_THREAD instead of KILL_CONNECTION to make it easier to ignore the signal in sensitive context (like auto-repair) Added new kill level: KILL_SERVER that will in the future to be used to signal killed by shutdown. Add more warnings about killed connections when warning level > 3 include/myisamchk.h: Added counting of printed info/notes mysys/mf_iocache.c: Remove duplicate assignment sql/handler.cc: Added test of KILL_SERVER sql/log.cc: Ignore new 'kill' error ER_NEW_ABORTING_CONNECTION when requesting query error code. sql/mysqld.cc: Add more warnings for killed connections when warning level > 3 sql/scheduler.cc: Added checks for new kill signals sql/slave.cc: Ignore new kill signal ER_NEW_ABORTING_CONNECTION sql/sp_head.cc: Fixed assignment to bool Added testing of new kill signals sql/sql_base.cc: Use KILL_SYSTEM_THREAD to auto-kill system threads sql/sql_class.cc: Add more warnings for killed connections when warning level > 3 thd_killed() now ignores KILL_BAD_DATA and THD::KILL_SYSTEM_THREAD as these should not abort sensitive operations. sql/sql_class.h: Added KILL_SYSTEM_THREAD and KILL_SERVER sql/sql_connect.cc: Added handling of KILL_SERVER sql/sql_insert.cc: Use KILL_SYSTEM_THREAD to auto-kill system threads Added handling of KILL_SERVER sql/sql_parse.cc: Add more warnings for killed connections when warning level > 3 Added checking that thd->abort_on_warning is reset at end of query. sql/sql_show.cc: Update condition for when a query is 'killed' storage/myisam/ha_myisam.cc: Added counting of info/notes printed storage/myisam/mi_check.c: Always print an an error if we find data errors when checking/repairing a MyISAM table. When a repair was killed, don't retry repair. Added assert if sort_get_next_record() returned an error without an error message. Removed nonsence check "if (sort_param->read_cache.error < 0)" in repair. storage/myisam/myisamchk.c: Added counting of notes printed storage/pbxt/src/thread_xt.cc: Better error message. --- sql/handler.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sql/handler.cc') diff --git a/sql/handler.cc b/sql/handler.cc index f5e7de371a4..0e683d38511 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1350,9 +1350,14 @@ int ha_rollback_trans(THD *thd, bool all) slave SQL thread, it would not stop the thread but just be printed in the error log; but we don't want users to wonder why they have this message in the error log, so we don't send it. + + We don't have to test for thd->killed == THD::KILL_SYSTEM_THREAD as + it doesn't matter if a warning is pushed to a system thread or not: + No one will see it... */ if (is_real_trans && thd->transaction.all.modified_non_trans_table && - !thd->slave_thread && thd->killed != THD::KILL_CONNECTION) + !thd->slave_thread && thd->killed != THD::KILL_CONNECTION && + thd->killed != THD::KILL_SERVER) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARNING_NOT_COMPLETE_ROLLBACK, ER(ER_WARNING_NOT_COMPLETE_ROLLBACK)); -- cgit v1.2.1 From 22e793639aa098aac6712256c67f28a49e4b1126 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 23 Sep 2011 01:13:38 +0300 Subject: Added new options to KILL. New syntax is KILL [HARD|SOFT] [CONNECTION|QUERY] [ID | USER user_name] - If USER is given, all threads for that user is signaled - If SOFT is used then the KILL will not be sent to the handler. This can be used to not interrupt critical things in the handler like 'REPAIR'. Internally added more kill signals. This gives us more information of why a query/connection was killed. - KILL_SERVER is used when server is going down. In this case the users gets ER_SHUTDOWN as the reason connection was killed. - Changed signals to number in correct order, which makes it easier to test how the signal should affect the code. - New error message ER_CONNECTION_KILLED if connection was killed by 'KILL CONNECTION'. Before we got error ER_SHUTDOWN. Changed names of not used parameters KILL_QUERY & KILL_CONNCTION to mysql_kill() to not conflict with defines in the server include/mysql.h.pp: Updated file include/mysql_com.h: Changed names of not used parameters KILL_QUERY & KILL_CONNCTION to mysql_kill() to not conflict with defines in the server mysql-test/r/kill.result: Added test of KILL USER mysql-test/suite/rpl/r/rpl_stm_000001.result: Updated error code mysql-test/suite/rpl/t/rpl_stm_000001.test: Updated error codes mysql-test/t/flush_read_lock_kill.test: Updated error codes mysql-test/t/kill.test: Added test of KILL USER plugin/handler_socket/handlersocket/database.cpp: Removed THD:: from KILL sql/debug_sync.cc: Removed THD:: from KILL sql/event_scheduler.cc: Removed THD:: from KILL sql/filesort.cc: Removed THD:: from KILL sql/ha_ndbcluster_binlog.cc: Removed THD:: from KILL sql/handler.cc: Removed THD:: from KILL Simplify code. sql/lex.h: Added new keywords HARD | SOFT sql/log.cc: Removed THD:: from KILL Added testing of new error ER_CONNECTION_KILLED sql/log_event.cc: Removed THD:: from KILL Added testing of new error ER_CONNECTION_KILLED sql/mysql_priv.h: Added new prototypes sql/mysqld.cc: Removed THD:: from KILL Use KILL_SERVER_HARD signal on shutdown. sql/scheduler.cc: Removed THD:: from KILL Simplify test if connection should be killed sql/share/errmsg.txt: New error message ER_CONNECTION_KILLED sql/slave.cc: Removed THD:: from KILL sql/sp_head.cc: Removed THD:: from KILL sql/sql_base.cc: Removed THD:: from KILL sql/sql_cache.cc: Removed THD:: from KILL sql/sql_class.cc: Removed THD:: from KILL Added killed_errno() Only signal kill to storage engine if HARD bit is set. sql/sql_class.h: Move KILL options out from THD to make them easier to use in sql_yacc.yy sql/sql_connect.cc: Removed THD:: from KILL sql/sql_delete.cc: Removed THD:: from KILL sql/sql_error.cc: Removed THD:: from KILL sql/sql_insert.cc: Removed THD:: from KILL Simplifed testing if thread is killed. sql/sql_lex.h: Added kill options to st_lex sql/sql_load.cc: Removed THD:: from KILL sql/sql_parse.cc: Added kill options to st_lex Simplifed and optimzed testing of thd->killed at end of query Added support for KILL USER Extended sql_kill() to allow use of more kill signals. sql/sql_repl.cc: Removed THD:: from KILL sql/sql_show.cc: Removed THD:: from KILL Simplied testing if query/connection was killed sql/sql_table.cc: Removed THD:: from KILL sql/sql_update.cc: Removed THD:: from KILL sql/sql_yacc.yy: Added support for new KILL syntax: KILL [HARD|SOFT] [CONNECTION|QUERY] [ID | USER user_name] storage/archive/ha_archive.cc: Simplify compilation storage/maria/ha_maria.cc: Removed THD:: from KILL --- sql/handler.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sql/handler.cc') diff --git a/sql/handler.cc b/sql/handler.cc index 905668114dd..08d778022dc 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1404,13 +1404,12 @@ int ha_rollback_trans(THD *thd, bool all) the error log; but we don't want users to wonder why they have this message in the error log, so we don't send it. - We don't have to test for thd->killed == THD::KILL_SYSTEM_THREAD as + We don't have to test for thd->killed == KILL_SYSTEM_THREAD as it doesn't matter if a warning is pushed to a system thread or not: No one will see it... */ if (is_real_trans && thd->transaction.all.modified_non_trans_table && - !thd->slave_thread && thd->killed != THD::KILL_CONNECTION && - thd->killed != THD::KILL_SERVER) + !thd->slave_thread && thd->killed < KILL_CONNECTION) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARNING_NOT_COMPLETE_ROLLBACK, ER(ER_WARNING_NOT_COMPLETE_ROLLBACK)); @@ -2564,7 +2563,7 @@ int handler::update_auto_increment() /* first test if the query was aborted due to strict mode constraints */ - if (thd->killed == THD::KILL_BAD_DATA) + if (killed_mask_hard(thd->killed) == KILL_BAD_DATA) DBUG_RETURN(HA_ERR_AUTOINC_ERANGE); /* -- cgit v1.2.1 From 14c767ca48d6a86a3d495476bb6b5999036e00af Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 23 Sep 2011 12:00:52 +0200 Subject: fix typo: binlog_annotate_rows_events -> binlog_annotate_row_events --- sql/handler.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/handler.cc') diff --git a/sql/handler.cc b/sql/handler.cc index 905668114dd..a9f5b6f20b6 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4721,7 +4721,7 @@ static bool check_table_binlog_row_based(THD *thd, TABLE *table) /** @brief Write table maps for all (manually or automatically) locked tables - to the binary log. Also, if binlog_annotate_rows_events is ON, + to the binary log. Also, if binlog_annotate_row_events is ON, write Annotate_rows event before the first table map. SYNOPSIS @@ -4759,7 +4759,7 @@ static int write_locked_table_maps(THD *thd) locks[0]= thd->extra_lock; locks[1]= thd->lock; locks[2]= thd->locked_tables; - my_bool with_annotate= thd->variables.binlog_annotate_rows_events && + my_bool with_annotate= thd->variables.binlog_annotate_row_events && thd->query() && thd->query_length(); for (uint i= 0 ; i < sizeof(locks)/sizeof(*locks) ; ++i ) -- cgit v1.2.1 From 7bc6a83b027aeddbe1d84ceb6647928d5cfb3bca Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 29 Oct 2011 15:36:24 -0700 Subject: Backported the fix and the test case for bug #58816 from mysql-5.6 code line. --- sql/handler.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sql/handler.cc') diff --git a/sql/handler.cc b/sql/handler.cc index 66e22aa40dc..6c5d3a580ec 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4878,6 +4878,9 @@ int handler::ha_reset() /* reset the bitmaps to point to defaults */ table->default_column_bitmaps(); pushed_cond= NULL; + /* Reset information about pushed engine conditions */ + cancel_pushed_idx_cond(); + /* Reset information about pushed index conditions */ DBUG_RETURN(reset()); } -- cgit v1.2.1