diff options
author | Michael Widenius <monty@askmonty.org> | 2011-09-10 18:01:27 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-09-10 18:01:27 +0300 |
commit | 3fb22ac5e146e1fe34d282c3c3ef6bd50af90ca5 (patch) | |
tree | 4f069ae5398a3e17417f942cb6926c66efe968a6 | |
parent | 3769841d9e706ee018d5273d2901954b9a281c3e (diff) | |
parent | 0db9c26b05439f9d6fc29234966f50d8e393dfe2 (diff) | |
download | mariadb-git-3fb22ac5e146e1fe34d282c3c3ef6bd50af90ca5.tar.gz |
Merge with 5.2
-rw-r--r-- | include/my_sys.h | 1 | ||||
-rw-r--r-- | include/myisamchk.h | 2 | ||||
-rw-r--r-- | mysql-test/r/func_group.result | 9 | ||||
-rw-r--r-- | mysql-test/suite/parts/r/partition_repair_myisam.result | 1 | ||||
-rw-r--r-- | mysql-test/t/func_group.test | 7 | ||||
-rw-r--r-- | mysys/mf_iocache.c | 8 | ||||
-rw-r--r-- | mysys/my_static.c | 3 | ||||
-rw-r--r-- | mysys/thr_mutex.c | 1 | ||||
-rw-r--r-- | sql/handler.cc | 7 | ||||
-rw-r--r-- | sql/log.cc | 3 | ||||
-rw-r--r-- | sql/mysqld.cc | 50 | ||||
-rw-r--r-- | sql/opt_sum.cc | 2 | ||||
-rw-r--r-- | sql/scheduler.cc | 11 | ||||
-rw-r--r-- | sql/slave.cc | 1 | ||||
-rw-r--r-- | sql/sp_head.cc | 9 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 | ||||
-rw-r--r-- | sql/sql_class.cc | 14 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_connect.cc | 3 | ||||
-rw-r--r-- | sql/sql_insert.cc | 17 | ||||
-rw-r--r-- | sql/sql_parse.cc | 17 | ||||
-rw-r--r-- | sql/sql_show.cc | 8 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 1 | ||||
-rw-r--r-- | storage/myisam/mi_check.c | 37 | ||||
-rw-r--r-- | storage/myisam/myisamchk.c | 1 | ||||
-rw-r--r-- | storage/pbxt/src/thread_xt.cc | 2 |
26 files changed, 161 insertions, 60 deletions
diff --git a/include/my_sys.h b/include/my_sys.h index 230991002f4..2bbeec48c88 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -255,6 +255,7 @@ extern ulong my_file_total_opened; extern ulong my_sync_count; extern uint mysys_usage_id; extern my_bool my_init_done; +extern my_bool my_assert_on_error; extern myf my_global_flags; /* Set to MY_WME for more error messages */ /* Point to current my_message() */ extern void (*my_sigtstp_cleanup)(void), diff --git a/include/myisamchk.h b/include/myisamchk.h index 48e4a8d1b9c..f85824e76bb 100644 --- a/include/myisamchk.h +++ b/include/myisamchk.h @@ -144,7 +144,7 @@ typedef struct st_handler_check_param time_t backup_time; /* To sign backup files */ ulong rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY]; double new_rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY]; - uint out_flag, warning_printed, error_printed, verbose; + uint out_flag, warning_printed, error_printed, note_printed, verbose; uint opt_sort_key, total_files, max_level; uint key_cache_block_size, pagecache_block_size; int tmpfile_createflag, err_count; diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 4c81cf63b6e..a24784ace4b 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1811,6 +1811,15 @@ MAX(f1) 2001 DROP TABLE t1; # +# LP BUG#813418 - incorrect optimisation of max/min by index for +# negated BETWEEN +CREATE TABLE t1 (a int, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +SELECT MAX(a) FROM t1 WHERE a NOT BETWEEN 3 AND 9; +MAX(a) +10 +drop table t1; +# End of 5.1 tests # # BUG#46680 - Assertion failed in file item_subselect.cc, diff --git a/mysql-test/suite/parts/r/partition_repair_myisam.result b/mysql-test/suite/parts/r/partition_repair_myisam.result index a34627a91cb..f9dd05c2996 100644 --- a/mysql-test/suite/parts/r/partition_repair_myisam.result +++ b/mysql-test/suite/parts/r/partition_repair_myisam.result @@ -264,6 +264,7 @@ Table Op Msg_type Msg_text test.t1_will_crash analyze status OK OPTIMIZE TABLE t1_will_crash; Table Op Msg_type Msg_text +test.t1_will_crash optimize info Found row block followed by deleted block test.t1_will_crash optimize warning Number of rows changed from 8 to 7 test.t1_will_crash optimize status OK CHECK TABLE t1_will_crash; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 742b0955dca..874b26f7549 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -1139,6 +1139,13 @@ INSERT INTO t1 VALUES (0000),(2001); --disable_metadata DROP TABLE t1; +--echo # +--echo # LP BUG#813418 - incorrect optimisation of max/min by index for +--echo # negated BETWEEN +CREATE TABLE t1 (a int, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +SELECT MAX(a) FROM t1 WHERE a NOT BETWEEN 3 AND 9; +drop table t1; --echo # --echo End of 5.1 tests diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 8add0f9f4cb..ef5d53710d2 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -178,11 +178,9 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize, if ((pos == (my_off_t) -1) && (my_errno == ESPIPE)) { /* - This kind of object doesn't support seek() or tell(). Don't set a - flag that will make us again try to seek() later and fail. - */ - info->seek_not_done= 0; - /* + This kind of object doesn't support seek() or tell(). Don't set a + seek_not_done that will make us again try to seek() later and fail. + Additionally, if we're supposed to start somewhere other than the the beginning of whatever this file is, then somebody made a bad assumption. diff --git a/mysys/my_static.c b/mysys/my_static.c index c33a12c2ca0..a117bed1496 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -32,7 +32,8 @@ char NEAR curr_dir[FN_REFLEN]= {0}, ulong my_stream_opened=0,my_file_opened=0, my_tmp_file_created=0; ulong my_file_total_opened= 0; int NEAR my_umask=0664, NEAR my_umask_dir=0777; -myf my_global_flags; +myf my_global_flags= 0; +my_bool my_assert_on_error= 0; #ifndef THREAD int NEAR my_errno=0; #endif diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index 9421a3b2d98..d284badfef4 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -836,6 +836,7 @@ static void print_deadlock_warning(safe_mutex_t *new_mutex, mutex_root->file, mutex_root->line)); } fflush(stderr); + DBUG_ASSERT(my_assert_on_error == 0); DBUG_VOID_RETURN; } diff --git a/sql/handler.cc b/sql/handler.cc index 751e31fdf9f..905668114dd 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1403,9 +1403,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)); diff --git a/sql/log.cc b/sql/log.cc index d345d0f6102..e53c8d12770 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -5175,7 +5175,8 @@ int query_error_code(THD *thd, bool not_killed) is not set to these errors when specified not_killed by the caller. */ - if (error == ER_SERVER_SHUTDOWN || error == ER_QUERY_INTERRUPTED) + if (error == ER_SERVER_SHUTDOWN || error == ER_QUERY_INTERRUPTED || + error == ER_NEW_ABORTING_CONNECTION) error= 0; } else diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a3417282661..97472777185 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2034,6 +2034,17 @@ void close_connection(THD *thd, uint errcode, bool lock) if (lock) (void) pthread_mutex_lock(&LOCK_thread_count); thd->killed= THD::KILL_CONNECTION; + + if (global_system_variables.log_warnings > 3) + { + Security_context *sctx= &thd->main_security_ctx; + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), + thd->thread_id,(thd->db ? thd->db : "unconnected"), + sctx->user ? sctx->user : "unauthenticated", + sctx->host_or_ip, + (errcode ? ER(errcode) : "CLOSE_CONNECTION")); + } + if ((vio= thd->net.vio) != 0) { if (errcode) @@ -2195,24 +2206,6 @@ void flush_thread_cache() } -#ifdef THREAD_SPECIFIC_SIGPIPE -/** - Aborts a thread nicely. Comes here on SIGPIPE. - - @todo - One should have to fix that thr_alarm know about this thread too. -*/ -extern "C" sig_handler abort_thread(int sig __attribute__((unused))) -{ - THD *thd=current_thd; - DBUG_ENTER("abort_thread"); - if (thd) - thd->killed= THD::KILL_CONNECTION; - DBUG_VOID_RETURN; -} -#endif - - /****************************************************************************** Setup a signal thread with handles all signals. Because Linux doesn't support schemas use a mutex to check that @@ -2747,6 +2740,12 @@ the thread stack. Please read http://dev.mysql.com/doc/mysql/en/linux.html\n\n", case THD::KILL_QUERY: kreason= "KILL_QUERY"; break; + case THD::KILL_SYSTEM_THREAD: + kreason= "KILL_SYSTEM_THREAD"; + break; + case THD::KILL_SERVER: + kreason= "KILL_SERVER"; + break; case THD::KILLED_NO_VALUE: kreason= "KILLED_NO_VALUE"; break; @@ -6142,7 +6141,9 @@ enum options_mysqld OPT_SECURE_FILE_PRIV, OPT_MIN_EXAMINED_ROW_LIMIT, OPT_LOG_SLOW_SLAVE_STATEMENTS, - OPT_DEBUG_CRC, OPT_DEBUG_ON, OPT_DEBUG_ASSERT_IF_CRASHED_TABLE, OPT_OLD_MODE, + OPT_DEBUG_CRC, OPT_DEBUG_ON, OPT_DEBUG_ASSERT_IF_CRASHED_TABLE, + OPT_DEBUG_ASSERT_ON_ERROR, + OPT_OLD_MODE, OPT_TEST_IGNORE_WRONG_OPTIONS, OPT_TEST_RESTART, #if defined(ENABLED_DEBUG_SYNC) OPT_DEBUG_SYNC_TIMEOUT, @@ -6332,6 +6333,10 @@ struct my_option my_long_options[] = "Do an assert in handler::print_error() if we get a crashed table", &debug_assert_if_crashed_table, &debug_assert_if_crashed_table, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-assert-on-error", OPT_DEBUG_ASSERT_ON_ERROR, + "Do an assert in various functions if we get a fatal error", + &my_assert_on_error, &my_assert_on_error, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"default-character-set", OPT_DEFAULT_CHARACTER_SET_OLD, "Set the default character set (deprecated option, use --character-set-server instead).", @@ -9580,14 +9585,17 @@ static int get_options(int *argc,char **argv) my_crc_dbug_check= opt_my_crc_dbug_check; /* - Log mysys errors when we don't have a thd or thd->log_all_errors is set (recovery) to - the log. This is mainly useful for debugging strange system errors. + Log mysys errors when we don't have a thd or thd->log_all_errors is set + (recovery) to the log. This is mainly useful for debugging strange system + errors. */ if (global_system_variables.log_warnings >= 10) my_global_flags= MY_WME | ME_JUST_INFO; /* Log all errors not handled by thd->handle_error() to my_message_sql() */ if (global_system_variables.log_warnings >= 11) my_global_flags|= ME_NOREFRESH; + if (my_assert_on_error) + debug_assert_if_crashed_table= 1; /* long_query_time is in microseconds */ global_system_variables.long_query_time= max_system_variables.long_query_time= diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 43fbe17a25b..dc93548418a 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -671,6 +671,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, case Item_func::GE_FUNC: break; case Item_func::BETWEEN: + if (((Item_func_between*) cond)->negated) + DBUG_RETURN(FALSE); between= 1; break; case Item_func::MULT_EQUAL_FUNC: diff --git a/sql/scheduler.cc b/sql/scheduler.cc index 5b8f834aecc..6dd93640dc5 100644 --- a/sql/scheduler.cc +++ b/sql/scheduler.cc @@ -376,7 +376,9 @@ void libevent_kill_thd_callback(int Fd, short, void*) { THD *thd= (THD*)list->data; list= list_rest(list); - if (thd->killed == THD::KILL_CONNECTION) + if (thd->killed == THD::KILL_CONNECTION || + thd->killed == THD::KILL_SYSTEM_THREAD || + thd->killed == THD::KILL_SERVER) { /* Delete from libevent and add to the processing queue. @@ -531,9 +533,10 @@ static void libevent_connection_close(THD *thd) static bool libevent_should_close_connection(THD* thd) { - return thd->net.error || - thd->net.vio == 0 || - thd->killed == THD::KILL_CONNECTION; + return (thd->net.error || + thd->net.vio == 0 || + thd->killed == THD::KILL_CONNECTION || + thd->killed == THD::KILL_SERVER); } diff --git a/sql/slave.cc b/sql/slave.cc index cfa6c9fdc56..1ab1caecfb5 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -837,6 +837,7 @@ bool is_network_error(uint errorno) errorno == CR_SERVER_GONE_ERROR || errorno == CR_SERVER_LOST || errorno == ER_CON_COUNT_ERROR || + errorno == ER_NEW_ABORTING_CONNECTION || errorno == ER_SERVER_SHUTDOWN) return TRUE; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index bd2dcfd8653..6532e6c56f2 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -374,8 +374,8 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr) thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; thd->abort_on_warning= - thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES); + test(thd->variables.sql_mode & + (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)); thd->transaction.stmt.modified_non_trans_table= FALSE; /* Save the value in the field. Convert the value if needed. */ @@ -1362,7 +1362,10 @@ sp_head::execute(THD *thd) If the DB has changed, the pointer has changed too, but the original thd->db will then have been freed */ - if (cur_db_changed && thd->killed != THD::KILL_CONNECTION) + if (cur_db_changed && + thd->killed != THD::KILL_CONNECTION && + thd->killed != THD::KILL_SERVER && + thd->killed != THD::KILL_SYSTEM_THREAD) { /* Force switching back to the saved current database, because it may be diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 9268fe53167..bca8167f2b9 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8896,7 +8896,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, { if (!in_use->killed) { - in_use->killed= THD::KILL_CONNECTION; + in_use->killed= THD::KILL_SYSTEM_THREAD; pthread_mutex_lock(&in_use->mysys_var->mutex); if (in_use->mysys_var->current_cond) { @@ -9230,7 +9230,7 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) && ! in_use->killed) { - in_use->killed= THD::KILL_CONNECTION; + in_use->killed= THD::KILL_SYSTEM_THREAD; pthread_mutex_lock(&in_use->mysys_var->mutex); if (in_use->mysys_var->current_cond) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 6344ac45574..16165cdedbb 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1273,6 +1273,15 @@ void THD::awake(THD::killed_state state_to_set) THD_CHECK_SENTRY(this); safe_mutex_assert_owner(&LOCK_thd_data); + if (global_system_variables.log_warnings > 3) + { + Security_context *sctx= security_ctx; + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), + thread_id,(db ? db : "unconnected"), + sctx->user ? sctx->user : "unauthenticated", + sctx->host_or_ip, + "KILLED"); + } killed= state_to_set; if (state_to_set != THD::KILL_QUERY) { @@ -3392,7 +3401,10 @@ void THD::restore_backup_open_tables_state(Open_tables_state *backup) extern "C" int thd_killed(const MYSQL_THD thd) { - return(thd->killed); + if (thd->killed == THD::NOT_KILLED || thd->killed == THD::KILL_BAD_DATA || + thd->killed == THD::KILL_SYSTEM_THREAD) + return 0; + return thd->killed; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 3403126a3aa..748c2a4a818 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1978,7 +1978,9 @@ public: NOT_KILLED=0, KILL_BAD_DATA=1, KILL_CONNECTION=ER_SERVER_SHUTDOWN, + KILL_SYSTEM_THREAD=ER_NEW_ABORTING_CONNECTION, /* Kill connection nicely */ KILL_QUERY=ER_QUERY_INTERRUPTED, + KILL_SERVER, /* Placeholder for shortdown */ KILLED_NO_VALUE /* means neither of the states */ }; killed_state volatile killed; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index f6bfe975d51..5b7d392d773 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1181,7 +1181,8 @@ pthread_handler_t handle_one_connection(void *arg) prepare_new_connection_state(thd); while (!net->error && net->vio != 0 && - !(thd->killed == THD::KILL_CONNECTION)) + thd->killed != THD::KILL_CONNECTION && + thd->killed != THD::KILL_SERVER) { if (do_command(thd)) break; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 386650ff99c..b840eebf4cc 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2362,7 +2362,7 @@ void kill_delayed_threads(void) Delayed_insert *di; while ((di= it++)) { - di->thd.killed= THD::KILL_CONNECTION; + di->thd.killed= THD::KILL_SYSTEM_THREAD; pthread_mutex_lock(&di->thd.LOCK_thd_data); if (di->thd.mysys_var) { @@ -2447,7 +2447,8 @@ static void handle_delayed_insert_impl(THD *thd, Delayed_insert *di) for (;;) { - if (thd->killed == THD::KILL_CONNECTION) + if (thd->killed == THD::KILL_CONNECTION || + thd->killed == THD::KILL_SYSTEM_THREAD || thd->killed == THD::KILL_SERVER) { uint lock_count; /* @@ -2495,7 +2496,7 @@ static void handle_delayed_insert_impl(THD *thd, Delayed_insert *di) break; if (error == ETIMEDOUT || error == ETIME) { - thd->killed= THD::KILL_CONNECTION; + thd->killed= THD::KILL_SYSTEM_THREAD; break; } } @@ -2528,7 +2529,7 @@ static void handle_delayed_insert_impl(THD *thd, Delayed_insert *di) { /* Fatal error */ di->dead= 1; - thd->killed= THD::KILL_CONNECTION; + thd->killed= THD::KILL_SYSTEM_THREAD; } pthread_cond_broadcast(&di->cond_client); } @@ -2538,7 +2539,7 @@ static void handle_delayed_insert_impl(THD *thd, Delayed_insert *di) { /* Some fatal error */ di->dead= 1; - thd->killed= THD::KILL_CONNECTION; + thd->killed= THD::KILL_SYSTEM_THREAD; } } di->status=0; @@ -2598,7 +2599,7 @@ pthread_handler_t handle_delayed_insert(void *arg) thd->thread_id= thd->variables.pseudo_thread_id= thread_id++; thd->set_current_time(); threads.append(thd); - thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED; + thd->killed=abort_loop ? THD::KILL_SYSTEM_THREAD : THD::NOT_KILLED; pthread_mutex_unlock(&LOCK_thread_count); /* @@ -2632,7 +2633,7 @@ end: di->table=0; di->dead= 1; // If error - thd->killed= THD::KILL_CONNECTION; // If error + thd->killed= THD::KILL_SYSTEM_THREAD; // If error pthread_mutex_unlock(&di->mutex); close_thread_tables(thd); // Free the table @@ -2711,7 +2712,7 @@ bool Delayed_insert::handle_inserts(void) max_rows= delayed_insert_limit; if (thd.killed || table->needs_reopen_or_name_lock()) { - thd.killed= THD::KILL_CONNECTION; + thd.killed= THD::KILL_SYSTEM_THREAD; max_rows= ULONG_MAX; // Do as much as possible } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f9d9536f11b..f850dc9145f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -792,7 +792,17 @@ int end_trans(THD *thd, enum enum_mysql_completiontype completion) if (res < 0) my_error(thd->killed_errno(), MYF(0)); else if ((res == 0) && do_release) + { thd->killed= THD::KILL_CONNECTION; + if (global_system_variables.log_warnings > 3) + { + Security_context *sctx= &thd->main_security_ctx; + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), + thd->thread_id,(thd->db ? thd->db : "unconnected"), + sctx->user ? sctx->user : "unauthenticated", + sctx->host_or_ip, "RELEASE"); + } + } DBUG_RETURN(res); } @@ -1614,6 +1624,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd_proc_info(thd, 0); thd->packet.shrink(thd->variables.net_buffer_length); // Reclaim some memory free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); + + /* Check that some variables are reset properly */ + DBUG_ASSERT(thd->abort_on_warning == 0); DBUG_RETURN(error); } @@ -7197,6 +7210,10 @@ uint kill_one_thread(THD *thd, ulong id, bool only_kill_query) If user of both killer and killee are non-NULL, proceed with slayage if both are string-equal. + + It's ok to also kill DELAYED threads with KILL_CONNECTION instead of + KILL_SYSTEM_THREAD; The difference is that KILL_CONNECTION may be + faster and do a harder kill than KILL_SYSTEM_THREAD; */ if ((thd->security_ctx->master_access & SUPER_ACL) || diff --git a/sql/sql_show.cc b/sql/sql_show.cc index e4981701025..2a717ba1572 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1943,7 +1943,9 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) pthread_mutex_lock(&tmp->LOCK_thd_data); if ((mysys_var= tmp->mysys_var)) pthread_mutex_lock(&mysys_var->mutex); - thd_info->proc_info= (char*) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0); + thd_info->proc_info= (char*) (tmp->killed != THD::NOT_KILLED && + tmp->killed != THD::KILL_BAD_DATA ? + "Killed" : 0); #ifndef EMBEDDED_LIBRARY thd_info->state_info= (char*) (tmp->net.reading_or_writing ? (tmp->net.reading_or_writing == 2 ? @@ -2082,7 +2084,9 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) if ((mysys_var= tmp->mysys_var)) pthread_mutex_lock(&mysys_var->mutex); /* COMMAND */ - if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0))) + if ((val= (char *) ((tmp->killed != THD::NOT_KILLED && + tmp->killed != THD::KILL_BAD_DATA ? + "Killed" : 0)))) table->field[4]->store(val, strlen(val), cs); else table->field[4]->store(command_name[tmp->command].str, diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 97815205586..e6ad635c885 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -528,6 +528,7 @@ void mi_check_print_info(HA_CHECK *param, const char *fmt,...) va_list args; va_start(args, fmt); mi_check_print_msg(param, "info", fmt, args); + param->note_printed= 1; va_end(args); } diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index d97ae41ecc7..515b506bad4 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -1346,7 +1346,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend) } if (param->testflag & T_INFO) { - if (param->warning_printed || param->error_printed) + if (param->warning_printed || param->error_printed || param->note_printed) puts(""); if (used != 0 && ! param->error_printed) { @@ -1540,8 +1540,7 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info, new_file= -1; sort_param.sort_info=&sort_info; param->retry_repair= 0; - param->warning_printed= 0; - param->error_printed= 0; + param->warning_printed= param->error_printed= param->note_printed= 0; if (!(param->testflag & T_SILENT)) { @@ -2248,8 +2247,7 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ param->retry_repair= 0; - param->warning_printed= 0; - param->error_printed= 0; + param->warning_printed= param->error_printed= param->note_printed= 0; if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) param->testflag|=T_CALC_CHECKSUM; @@ -2577,6 +2575,8 @@ err: param->retry_repair= 0; /* Safety */ } mi_mark_crashed_on_repair(info); + if (killed_ptr(param)) + param->retry_repair= 0; /* No use to retry repair */ } else if (key_map == share->state.key_map) share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS; @@ -3112,6 +3112,8 @@ err: param->retry_repair= 0; /* Safety */ } mi_mark_crashed_on_repair(info); + if (killed_ptr(param)) + param->retry_repair= 0; } else if (key_map == share->state.key_map) share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS; @@ -3147,7 +3149,13 @@ static int sort_key_read(MI_SORT_PARAM *sort_param, void *key) DBUG_ENTER("sort_key_read"); if ((error=sort_get_next_record(sort_param))) + { + DBUG_ASSERT(error < 0 || + sort_info->param->error_printed || + sort_info->param->warning_printed || + sort_info->param->note_printed); DBUG_RETURN(error); + } if (info->state->records == sort_info->max_records) { mi_check_print_error(sort_info->param, @@ -3264,7 +3272,12 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) DBUG_ENTER("sort_get_next_record"); if (killed_ptr(param)) + { + mi_check_print_error(param, "Repair killed by user with cause: %d", + (int) killed_ptr(param)); + param->retry_repair= 0; DBUG_RETURN(1); + } switch (share->data_file_type) { case STATIC_RECORD: @@ -3350,6 +3363,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) } if (searching && ! sort_param->fix_datafile) { + mi_check_print_info(param, + "Datafile is corrupted; Restart repair with option to copy datafile"); param->error_printed=1; param->retry_repair=1; param->testflag|=T_RETRY_WITHOUT_QUICK; @@ -3411,6 +3426,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) } if (error) { + DBUG_ASSERT(param->note_printed); if (found_record) goto try_next; searching=1; @@ -3451,7 +3467,11 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) share->state.split++; } if (found_record) + { + mi_check_print_info(param, + "Found row block followed by deleted block"); goto try_next; + } if (searching) { pos+=MI_DYN_ALIGN_SIZE; @@ -3485,6 +3505,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) mi_check_print_error(param,"Not enough memory for blob at %s (need %lu)", llstr(sort_param->start_recpos,llbuff), (ulong) block_info.rec_len); + DBUG_ASSERT(param->error_printed); DBUG_RETURN(1); } else @@ -3566,8 +3587,6 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if (_mi_rec_unpack(info,sort_param->record,sort_param->rec_buff, sort_param->find_length) != MY_FILE_ERROR) { - if (sort_param->read_cache.error < 0) - DBUG_RETURN(1); if (sort_param->calc_checksum) info->checksum= (*info->s->calc_check_checksum)(info, sort_param->record); @@ -3593,6 +3612,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) sort_param->key+1, llstr(sort_param->start_recpos,llbuff)); try_next: + DBUG_ASSERT(param->error_printed || param->note_printed); pos=(sort_param->start_recpos+=MI_DYN_ALIGN_SIZE); searching=1; } @@ -3664,6 +3684,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) DBUG_ASSERT(0); /* Impossible */ break; } + DBUG_ASSERT(0); /* Impossible */ DBUG_RETURN(1); /* Impossible */ } @@ -3722,7 +3743,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param) if (sort_info->buff_length < reclength) { if (!(sort_info->buff=my_realloc(sort_info->buff, (uint) reclength, - MYF(MY_FREE_ON_ERROR | + MYF(MY_FREE_ON_ERROR | MY_WME | MY_ALLOW_ZERO_PTR)))) DBUG_RETURN(1); sort_info->buff_length=reclength; diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 8c54d7f0411..83a106c7941 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -1757,6 +1757,7 @@ void mi_check_print_info(HA_CHECK *param __attribute__((unused)), { va_list args; + param->note_printed=1; va_start(args,fmt); VOID(vfprintf(stdout, fmt, args)); VOID(fputc('\n',stdout)); diff --git a/storage/pbxt/src/thread_xt.cc b/storage/pbxt/src/thread_xt.cc index eb9941f13fb..16abd96f983 100644 --- a/storage/pbxt/src/thread_xt.cc +++ b/storage/pbxt/src/thread_xt.cc @@ -1178,7 +1178,7 @@ xtPublic XTThreadPtr xt_init_threading(u_int max_threads) #ifdef XT_TRACK_CONNECTIONS if (xt_thr_maximum_threads > XT_TRACK_MAX_CONNS) { xt_log_error(XT_NS_CONTEXT, XT_LOG_FATAL, XT_ERR_TOO_MANY_THREADS, 0, - "XT_TRACK_CONNECTIONS is enabled and xt_thr_maximum_threads > XT_TRACK_MAX_CONNS"); + "XT_TRACK_CONNECTIONS (debugging aid) is enabled and xt_thr_maximum_threads > XT_TRACK_MAX_CONNS. To continue restart with a smaller value for --max-connections"); goto failed; } #endif |