From b1dcf448ead09e9a70cf035f20ac0e1a168e79a6 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Mon, 7 Jun 2010 16:01:39 +0200 Subject: [PATCH 001/136] WL#5363: Thread Pool Service Interface In order to allow thread schedulers to be dynamically loaded, it is necessary to make the following changes to the server: - Two new service interfaces - Modifications to InnoDB to inform the thread scheduler of state changes. - Changes to the VIO subsystem for checking if data is available on a socket. - Elimination of remains of the old thread pool implementation. The two new service interfaces introduces are: my_thread_scheduler A service interface to register a thread scheduler. thd_wait A service interface to inform thread scheduler that the thread is about to start waiting. In addition, the patch adds code that: - Add a call to thd_wait for table locks in mysys thd_lock.c by introducing a set function that can be used to set a callback to be used when waiting on a lock and resuming from waiting. - Calling the mysys set function from the server to set the callbacks correctly. --- .bzr-mysql/default.conf | 4 +- include/Makefile.am | 2 + include/config-win.h | 7 - include/mysql/plugin.h | 2 +- include/mysql/plugin.h.pp | 21 +++ include/mysql/service_thd_wait.h | 83 +++++++++++ include/mysql/service_thread_scheduler.h | 65 +++++++++ include/mysql/services.h | 2 + include/service_versions.h | 3 +- include/thr_lock.h | 2 + include/violite.h | 1 + libservices/CMakeLists.txt | 6 +- libservices/Makefile.am | 4 +- libservices/my_thread_scheduler_service.c | 21 +++ libservices/thd_wait_service.c | 19 +++ mysys/my_init.c | 2 +- mysys/thr_lock.c | 31 ++++ sql/authors.h | 1 + sql/mysqld.cc | 51 +++---- sql/mysqld.h | 3 +- sql/scheduler.cc | 164 +++++++++++++++++----- sql/scheduler.h | 61 ++++++-- sql/sql_callback.h | 43 ++++++ sql/sql_class.cc | 75 +++++++++- sql/sql_class.h | 7 +- sql/sql_connect.cc | 15 +- sql/sql_connect.h | 4 + sql/sql_plugin_services.h | 16 ++- sql/sql_show.cc | 6 +- sql/sys_vars.cc | 19 +-- storage/innobase/buf/buf0flu.c | 4 + storage/innobase/buf/buf0rea.c | 4 + storage/innobase/srv/srv0srv.c | 6 + vio/vio.c | 10 ++ vio/vio_priv.h | 3 + vio/viosocket.c | 4 + vio/viossl.c | 5 +- 37 files changed, 647 insertions(+), 129 deletions(-) create mode 100644 include/mysql/service_thd_wait.h create mode 100644 include/mysql/service_thread_scheduler.h create mode 100644 libservices/my_thread_scheduler_service.c create mode 100644 libservices/thd_wait_service.c create mode 100644 sql/sql_callback.h diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index fcb3cab2de6..144adb1d68b 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" +# post_commit_to = "commits@lists.mysql.com" +# post_push_to = "commits@lists.mysql.com" tree_name = "mysql-trunk" diff --git a/include/Makefile.am b/include/Makefile.am index 5ede6d7591f..6f53ba8e296 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -24,6 +24,8 @@ HEADERS_ABI = mysql.h mysql_com.h mysql_time.h \ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ my_xml.h mysql_embed.h mysql/services.h \ mysql/service_my_snprintf.h mysql/service_thd_alloc.h \ + mysql/service_thread_scheduler.h \ + mysql/service_thd_wait.h \ my_pthread.h my_no_pthread.h \ mysql/psi/psi.h mysql/psi/mysql_thread.h \ mysql/psi/mysql_file.h \ diff --git a/include/config-win.h b/include/config-win.h index 269ec0e925a..70983c91fc3 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -20,13 +20,6 @@ #define BIG_TABLES -/* - Minimal version of Windows we should be able to run on. - Currently Windows XP. -*/ -#define _WIN32_WINNT 0x0501 - - #if defined(_MSC_VER) && _MSC_VER >= 1400 /* Avoid endless warnings about sprintf() etc. being unsafe. */ #define _CRT_SECURE_NO_DEPRECATE 1 diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 567734c1d5c..ced6983eda0 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -71,7 +71,7 @@ typedef struct st_mysql_xid MYSQL_XID; Plugin API. Common for all plugin types. */ -#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0101 +#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0102 /* The allowable types of plugins diff --git a/include/mysql/plugin.h.pp b/include/mysql/plugin.h.pp index 5dad31bd008..6b7a8f860ed 100644 --- a/include/mysql/plugin.h.pp +++ b/include/mysql/plugin.h.pp @@ -33,6 +33,27 @@ void *thd_memdup(void* thd, const void* str, unsigned int size); MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, const char *str, unsigned int size, int allocate_lex_string); +#include +typedef enum _thd_wait_type_e { + THD_WAIT_MUTEX= 1, + THD_WAIT_DISKIO= 2, + THD_WAIT_ROW_TABLE_LOCK= 3, + THD_WAIT_GLOBAL_LOCK= 4 +} thd_wait_type; +extern struct thd_wait_service_st { + void (*thd_wait_begin_func)(void*, thd_wait_type); + void (*thd_wait_end_func)(void*); +} *thd_wait_service; +void thd_wait_begin(void* thd, thd_wait_type wait_type); +void thd_wait_end(void* thd); +#include +struct scheduler_functions; +extern struct my_thread_scheduler_service { + int (*set)(struct scheduler_functions *scheduler); + int (*reset)(); +} *my_thread_scheduler_service; +int my_thread_scheduler_set(struct scheduler_functions *scheduler); +int my_thread_scheduler_reset(); struct st_mysql_xid { long formatID; long gtrid_length; diff --git a/include/mysql/service_thd_wait.h b/include/mysql/service_thd_wait.h new file mode 100644 index 00000000000..2a8f5e610a3 --- /dev/null +++ b/include/mysql/service_thd_wait.h @@ -0,0 +1,83 @@ +/* Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef MYSQL_SERVICE_THD_WAIT_INCLUDED +#define MYSQL_SERVICE_THD_WAIT_INCLUDED + +/** + @file include/mysql/service_thd_wait.h + This service provides functions for plugins and storage engines to report + when they are going to sleep/stall. + + SYNOPSIS + thd_wait_begin() - call just before a wait begins + thd Thread object + Use NULL if the thd is NOT known. + wait_type Type of wait + 1 -- short wait (e.g. for mutex) + 2 -- medium wait (e.g. for disk io) + 3 -- large wait (e.g. for locked row/table) + NOTES + This is used by the threadpool to have better knowledge of which + threads that currently are actively running on CPUs. When a thread + reports that it's going to sleep/stall, the threadpool scheduler is + free to start another thread in the pool most likely. The expected wait + time is simply an indication of how long the wait is expected to + become, the real wait time could be very different. + + thd_wait_end() called immediately after the wait is complete + + thd_wait_end() MUST be called if thd_wait_begin() was called. + + Using thd_wait_...() service is optional but recommended. Using it will + improve performance as the thread pool will be more active at managing the + thread workload. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum _thd_wait_type_e { + THD_WAIT_MUTEX= 1, + THD_WAIT_DISKIO= 2, + THD_WAIT_ROW_TABLE_LOCK= 3, + THD_WAIT_GLOBAL_LOCK= 4 +} thd_wait_type; + +extern struct thd_wait_service_st { + void (*thd_wait_begin_func)(MYSQL_THD, thd_wait_type); + void (*thd_wait_end_func)(MYSQL_THD); +} *thd_wait_service; + +#ifdef MYSQL_DYNAMIC_PLUGIN + +#define thd_wait_begin(_THD, _WAIT_TYPE) \ + thd_wait_service->thd_wait_begin_func(_THD, _WAIT_TYPE) +#define thd_wait_end(_THD) thd_wait_service->thd_wait_end_func(_THD) + +#else + +void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type); +void thd_wait_end(MYSQL_THD thd); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/mysql/service_thread_scheduler.h b/include/mysql/service_thread_scheduler.h new file mode 100644 index 00000000000..a4396b721bd --- /dev/null +++ b/include/mysql/service_thread_scheduler.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef SERVICE_THREAD_SCHEDULER_INCLUDED +#define SERVICE_THREAD_SCHEDULER_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +struct scheduler_functions; + +extern struct my_thread_scheduler_service { + int (*set)(struct scheduler_functions *scheduler); + int (*reset)(); +} *my_thread_scheduler_service; + +#ifdef MYSQL_DYNAMIC_PLUGIN + +#define my_thread_scheduler_set(F) my_thread_scheduler_service->set((F)) +#define my_thread_scheduler_reset() my_thread_scheduler_service->reset() + +#else + +/** + Set the thread scheduler to use for the server. + + @param scheduler Pointer to scheduler callbacks to use. + @retval 0 Scheduler installed correctly. + @retval 1 Invalid value (NULL) used for scheduler. +*/ +int my_thread_scheduler_set(struct scheduler_functions *scheduler); + +/** + Restore the previous thread scheduler. + + @note If no thread scheduler was installed previously with + thd_set_thread_scheduler, this function will report an error. + + @retval 0 Scheduler installed correctly. + @retval 1 No scheduler installed. +*/ +int my_thread_scheduler_reset(); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* SERVICE_THREAD_SCHEDULER_INCLUDED */ diff --git a/include/mysql/services.h b/include/mysql/services.h index 19003e66b96..6c67a582fb8 100644 --- a/include/mysql/services.h +++ b/include/mysql/services.h @@ -20,6 +20,8 @@ extern "C" { #include #include +#include +#include #ifdef __cplusplus } diff --git a/include/service_versions.h b/include/service_versions.h index 114957cdd86..4fd886c8a83 100644 --- a/include/service_versions.h +++ b/include/service_versions.h @@ -21,4 +21,5 @@ #define VERSION_my_snprintf 0x0100 #define VERSION_thd_alloc 0x0100 - +#define VERSION_thd_wait 0x0100 +#define VERSION_my_thread_scheduler 0x0100 diff --git a/include/thr_lock.h b/include/thr_lock.h index 1f4072ca0c5..32fe353bdb1 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -174,6 +174,8 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *data, enum thr_lock_type new_lock_type); my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data, ulong lock_wait_timeout); +void thr_set_lock_wait_callback(void (*before_wait)(void), + void (*after_wait)(void)); #ifdef __cplusplus } #endif diff --git a/include/violite.h b/include/violite.h index 05ceaa272c1..f4083216894 100644 --- a/include/violite.h +++ b/include/violite.h @@ -217,6 +217,7 @@ struct st_vio void (*timeout)(Vio*, unsigned int which, unsigned int timeout); my_bool (*poll_read)(Vio *vio, uint timeout); my_bool (*is_connected)(Vio*); + my_bool (*has_data) (Vio*); #ifdef HAVE_OPENSSL void *ssl_arg; #endif diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt index da84368b46c..113d15a18e8 100644 --- a/libservices/CMakeLists.txt +++ b/libservices/CMakeLists.txt @@ -15,7 +15,11 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -SET(MYSQLSERVICES_SOURCES my_snprintf_service.c thd_alloc_service.c) +SET(MYSQLSERVICES_SOURCES + my_snprintf_service.c + thd_alloc_service.c + thd_wait_service.c + my_thread_scheduler_service.c) ADD_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES}) INSTALL(TARGETS mysqlservices DESTINATION ${INSTALL_LIBDIR}) diff --git a/libservices/Makefile.am b/libservices/Makefile.am index 642081859c1..d25c5c9680c 100644 --- a/libservices/Makefile.am +++ b/libservices/Makefile.am @@ -15,5 +15,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include pkglib_LIBRARIES = libmysqlservices.a -libmysqlservices_a_SOURCES = my_snprintf_service.c thd_alloc_service.c +libmysqlservices_a_SOURCES = my_snprintf_service.c thd_alloc_service.c \ + thd_wait_service.c \ + my_thread_scheduler_service.c EXTRA_DIST = CMakeLists.txt diff --git a/libservices/my_thread_scheduler_service.c b/libservices/my_thread_scheduler_service.c new file mode 100644 index 00000000000..dc8d40c6713 --- /dev/null +++ b/libservices/my_thread_scheduler_service.c @@ -0,0 +1,21 @@ +/* + Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*/ + +#include +SERVICE_VERSION my_thread_scheduler_service= + (void*)VERSION_my_thread_scheduler; diff --git a/libservices/thd_wait_service.c b/libservices/thd_wait_service.c new file mode 100644 index 00000000000..3c87a2d0d1b --- /dev/null +++ b/libservices/thd_wait_service.c @@ -0,0 +1,19 @@ +/* + Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +SERVICE_VERSION *thd_wait_service= (void*)VERSION_thd_wait; diff --git a/mysys/my_init.c b/mysys/my_init.c index 80f9a493bb0..f6a005dfdbd 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -499,7 +499,7 @@ static my_bool win32_init_tcp_ip() { if (win32_have_tcpip()) { - WORD wVersionRequested = MAKEWORD( 2, 0 ); + WORD wVersionRequested = MAKEWORD( 2, 2 ); WSADATA wsaData; /* Be a good citizen: maybe another lib has already initialised sockets, so dont clobber them unless necessary */ diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 43db0470735..085606843df 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -93,6 +93,16 @@ enum thr_lock_type thr_upgraded_concurrent_insert_lock = TL_WRITE; LIST *thr_lock_thread_list; /* List of threads in use */ ulong max_write_lock_count= ~(ulong) 0L; +static void (*before_lock_wait)(void)= 0; +static void (*after_lock_wait)(void)= 0; + +void thr_set_lock_wait_callback(void (*before_wait)(void), + void (*after_wait)(void)) +{ + before_lock_wait= before_wait; + after_lock_wait= after_wait; +} + static inline mysql_cond_t *get_cond(void) { return &my_thread_var->suspend; @@ -436,6 +446,19 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, old_proc_info= proc_info_hook(NULL, "Table lock", __func__, __FILE__, __LINE__); + /* + Since before_lock_wait potentially can create more threads to + scheduler work for, we don't want to call the before_lock_wait + callback unless it will really start to wait. + + For similar reasons, we do not want to call before_lock_wait and + after_lock_wait for each lap around the loop, so we restrict + ourselves to call it before_lock_wait once before starting to wait + and once after the thread has exited the wait loop. + */ + if ((!thread_var->abort || in_wait_list) && before_lock_wait) + (*before_lock_wait)(); + set_timespec(wait_timeout, lock_wait_timeout); while (!thread_var->abort || in_wait_list) { @@ -467,6 +490,14 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, /* purecov: end */ } } + + /* + We call the after_lock_wait callback once the wait loop has + finished. + */ + if (after_lock_wait) + (*after_lock_wait)(); + DBUG_PRINT("thr_lock", ("aborted: %d in_wait_list: %d", thread_var->abort, in_wait_list)); diff --git a/sql/authors.h b/sql/authors.h index 555fe2ae43a..210141b5e22 100644 --- a/sql/authors.h +++ b/sql/authors.h @@ -92,6 +92,7 @@ struct show_table_authors_st show_table_authors[]= { { "Arjen Lentz", "Brisbane, Australia", "Documentation (2001-2004), Dutch error messages, LOG2()" }, { "Marc Liyanage", "", "Created Mac OS X packages" }, + { "Kelly Long", "Denver, CO, USA", "Pool Of Threads" }, { "Zarko Mocnik", "", "Sorting for Slovenian language" }, { "Per-Erik Martin", "Uppsala, Sweden", "Stored Procedures (5.0)" }, { "Alexis Mikhailov", "", "User-defined functions" }, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b35e2545a18..a61f2ccbc23 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -64,7 +64,9 @@ #include "events.h" #include "sql_audit.h" #include "probes_mysql.h" +#include "scheduler.h" #include "debug_sync.h" +#include "sql_callback.h" #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE #include "../storage/perfschema/pfs_server.h" @@ -504,7 +506,7 @@ ulong slave_trans_retries; uint slave_net_timeout; uint slave_exec_mode_options; ulonglong slave_type_conversions_options; -ulong thread_cache_size=0, thread_pool_size= 0; +ulong thread_cache_size=0; ulong binlog_cache_size=0; ulonglong max_binlog_cache_size=0; ulong query_cache_size=0; @@ -935,8 +937,6 @@ my_bool opt_enable_shared_memory; HANDLE smem_event_connect_request= 0; #endif -scheduler_functions thread_scheduler; - my_bool opt_use_ssl = 0; char *opt_ssl_ca= NULL, *opt_ssl_capath= NULL, *opt_ssl_cert= NULL, *opt_ssl_cipher= NULL, *opt_ssl_key= NULL; @@ -1125,7 +1125,8 @@ static void close_connections(void) continue; tmp->killed= THD::KILL_CONNECTION; - thread_scheduler.post_kill_notification(tmp); + MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (tmp)); + mysql_mutex_lock(&tmp->LOCK_thd_data); if (tmp->mysys_var) { tmp->mysys_var->abort=1; @@ -1138,6 +1139,7 @@ static void close_connections(void) } mysql_mutex_unlock(&tmp->mysys_var->mutex); } + mysql_mutex_unlock(&tmp->LOCK_thd_data); } mysql_mutex_unlock(&LOCK_thread_count); // For unlink from list @@ -1543,7 +1545,7 @@ void clean_up(bool print_message) if (print_message && my_default_lc_messages && server_start_time) sql_print_information(ER_DEFAULT(ER_SHUTDOWN_COMPLETE),my_progname); cleanup_errmsgs(); - thread_scheduler.end(); + MYSQL_CALLBACK(thread_scheduler, end, ()); finish_client_errs(); DBUG_PRINT("quit", ("Error messages freed")); /* Tell main we are ready */ @@ -1823,7 +1825,7 @@ static void network_init(void) DBUG_ENTER("network_init"); LINT_INIT(ret); - if (thread_scheduler.init()) + if (MYSQL_CALLBACK_ELSE(thread_scheduler, init, (), 0)) unireg_abort(1); /* purecov: inspected */ set_ports(); @@ -2071,7 +2073,7 @@ extern "C" sig_handler end_thread_signal(int sig __attribute__((unused))) if (thd && ! thd->bootstrap) { statistic_increment(killed_threads, &LOCK_status); - thread_scheduler.end_thread(thd,0); /* purecov: inspected */ + MYSQL_CALLBACK(thread_scheduler, end_thread, (thd,0)); /* purecov: inspected */ } DBUG_VOID_RETURN; /* purecov: deadcode */ } @@ -2679,7 +2681,7 @@ and this may fail.\n\n"); (ulong) dflt_key_cache->key_cache_mem_size); fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size); fprintf(stderr, "max_used_connections=%lu\n", max_used_connections); - fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads); + fprintf(stderr, "max_threads=%u\n", thread_scheduler->max_threads); fprintf(stderr, "thread_count=%u\n", thread_count); fprintf(stderr, "connection_count=%u\n", connection_count); fprintf(stderr, "It is possible that mysqld could use up to \n\ @@ -2687,7 +2689,7 @@ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\ bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size + (global_system_variables.read_buff_size + global_system_variables.sortbuff_size) * - thread_scheduler.max_threads + + thread_scheduler->max_threads + max_connections * sizeof(THD)) / 1024); fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n"); @@ -2932,7 +2934,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) This should actually be '+ max_number_of_slaves' instead of +10, but the +10 should be quite safe. */ - init_thr_alarm(thread_scheduler.max_threads + + init_thr_alarm(thread_scheduler->max_threads + global_system_variables.max_insert_delayed_threads + 10); if (thd_lib_detected != THD_LIB_LT && (test_flags & TEST_SIGINT)) { @@ -4640,23 +4642,6 @@ int mysqld_main(int argc, char **argv) } #endif -#ifdef __WIN__ - /* - Before performing any socket operation (like retrieving hostname - in init_common_variables we have to call WSAStartup - */ - { - WSADATA WsaData; - if (SOCKET_ERROR == WSAStartup (0x0101, &WsaData)) - { - /* errors are not read yet, so we use english text here */ - my_message(ER_WSAS_FAILED, "WSAStartup Failed", MYF(0)); - /* Not enough initializations for unireg_abort() */ - return 1; - } - } -#endif /* __WIN__ */ - if (init_common_variables()) unireg_abort(1); // Will do exit @@ -5310,7 +5295,7 @@ static void create_new_thread(THD *thd) thread_count++; - thread_scheduler.add_connection(thd); + MYSQL_CALLBACK(thread_scheduler, add_connection, (thd)); DBUG_VOID_RETURN; } @@ -7633,14 +7618,12 @@ static int get_options(int *argc_ptr, char ***argv_ptr) return 1; #ifdef EMBEDDED_LIBRARY - one_thread_scheduler(&thread_scheduler); + one_thread_scheduler(); #else if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION) - one_thread_per_connection_scheduler(&thread_scheduler); - else if (thread_handling == SCHEDULER_NO_THREADS) - one_thread_scheduler(&thread_scheduler); - else - pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */ + one_thread_per_connection_scheduler(); + else /* thread_handling == SCHEDULER_NO_THREADS) */ + one_thread_scheduler(); #endif global_system_variables.engine_condition_pushdown= diff --git a/sql/mysqld.h b/sql/mysqld.h index 2547100d8ff..3ad43df3208 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -177,7 +177,7 @@ extern ulong binlog_cache_size, open_files_limit; extern ulonglong max_binlog_cache_size; extern ulong max_binlog_size, max_relay_log_size; extern ulong opt_binlog_rows_event_max_size; -extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size; +extern ulong rpl_recovery_rank, thread_cache_size; extern ulong back_log; extern char language[FN_REFLEN]; extern ulong server_id, concurrency; @@ -211,7 +211,6 @@ extern int bootstrap_error; extern FILE *stderror_file; extern I_List threads; extern char err_shared_dir[]; -extern scheduler_functions thread_scheduler; extern TYPELIB thread_handling_typelib; extern my_decimal decimal_zero; diff --git a/sql/scheduler.cc b/sql/scheduler.cc index 10009246428..19f8ddc7355 100644 --- a/sql/scheduler.cc +++ b/sql/scheduler.cc @@ -25,30 +25,8 @@ #include "unireg.h" // REQUIRED: for other includes #include "scheduler.h" #include "sql_connect.h" // init_new_connection_handler_thread - -/* - 'Dummy' functions to be used when we don't need any handling for a scheduler - event - */ - -static bool init_dummy(void) {return 0;} -static void post_kill_dummy(THD* thd) {} -static void end_dummy(void) {} -static bool end_thread_dummy(THD *thd, bool cache_thread) { return 0; } - -/* - Initialize default scheduler with dummy functions so that setup functions - only need to declare those that are relvant for their usage -*/ - -scheduler_functions::scheduler_functions() - :init(init_dummy), - init_new_connection_thread(init_new_connection_handler_thread), - add_connection(0), // Must be defined - post_kill_notification(post_kill_dummy), - end_thread(end_thread_dummy), end(end_dummy) -{} - +#include "scheduler.h" +#include "sql_callback.h" /* End connection, in case when we are using 'no-threads' @@ -61,19 +39,84 @@ static bool no_threads_end(THD *thd, bool put_in_cache) return 1; // Abort handle_one_connection } +static scheduler_functions one_thread_scheduler_functions= +{ + 1, // max_threads + NULL, // init + init_new_connection_handler_thread, // init_new_connection_thread + handle_connection_in_main_thread, // add_connection + NULL, // thd_wait_begin + NULL, // thd_wait_end + NULL, // post_kill_notification + no_threads_end, // end_thread + NULL, // end +}; + +static scheduler_functions one_thread_per_connection_scheduler_functions= +{ + 0, // max_threads + NULL, // init + init_new_connection_handler_thread, // init_new_connection_thread + create_thread_to_handle_connection, // add_connection + NULL, // thd_wait_begin + NULL, // thd_wait_end + NULL, // post_kill_notification + one_thread_per_connection_end, // end_thread + NULL, // end +}; + + +scheduler_functions *thread_scheduler= + &one_thread_per_connection_scheduler_functions; + +/** @internal + Helper functions to allow mysys to call the thread scheduler when + waiting for locks. +*/ + +/**@{*/ +static void scheduler_wait_begin(void) { + MYSQL_CALLBACK(thread_scheduler, + thd_wait_begin, (current_thd, THD_WAIT_ROW_TABLE_LOCK)); +} + +static void scheduler_wait_end(void) { + MYSQL_CALLBACK(thread_scheduler, thd_wait_end, (current_thd)); +} +/**@}*/ + +/** + Common scheduler init function. + + The scheduler is either initialized by calling + one_thread_scheduler() or one_thread_per_connection_scheduler() in + mysqld.cc, so this init function will always be called. + */ +static void scheduler_init() { + thr_set_lock_wait_callback(scheduler_wait_begin, scheduler_wait_end); +} + +/* + Initialize scheduler for --thread-handling=one-thread-per-connection +*/ + +#ifndef EMBEDDED_LIBRARY +void one_thread_per_connection_scheduler() +{ + scheduler_init(); + one_thread_per_connection_scheduler_functions.max_threads= max_connections; + thread_scheduler= &one_thread_per_connection_scheduler_functions; +} +#endif /* Initailize scheduler for --thread-handling=no-threads */ -void one_thread_scheduler(scheduler_functions* func) +void one_thread_scheduler() { - func->max_threads= 1; -#ifndef EMBEDDED_LIBRARY - func->add_connection= handle_connection_in_main_thread; -#endif - func->init_new_connection_thread= init_dummy; - func->end_thread= no_threads_end; + scheduler_init(); + thread_scheduler= &one_thread_scheduler_functions; } @@ -81,11 +124,58 @@ void one_thread_scheduler(scheduler_functions* func) Initialize scheduler for --thread-handling=one-thread-per-connection */ -#ifndef EMBEDDED_LIBRARY -void one_thread_per_connection_scheduler(scheduler_functions* func) +/* + thd_scheduler keeps the link between THD and events. + It's embedded in the THD class. +*/ + +thd_scheduler::thd_scheduler() + : m_psi(NULL), data(NULL) { - func->max_threads= max_connections; - func->add_connection= create_thread_to_handle_connection; - func->end_thread= one_thread_per_connection_end; +#ifndef DBUG_OFF + dbug_explain[0]= '\0'; + set_explain= FALSE; +#endif } -#endif /* EMBEDDED_LIBRARY */ + + +thd_scheduler::~thd_scheduler() +{ +} + +static scheduler_functions *saved_thread_scheduler; +static uint saved_thread_handling; + +extern "C" +int my_thread_scheduler_set(scheduler_functions *scheduler) +{ + DBUG_ASSERT(scheduler != 0); + + if (scheduler == NULL) + return 1; + + saved_thread_scheduler= thread_scheduler; + saved_thread_handling= thread_handling; + thread_scheduler= scheduler; + // Scheduler loaded dynamically + thread_handling= SCHEDULER_TYPES_COUNT; + return 0; +} + + +extern "C" +int my_thread_scheduler_reset() +{ + DBUG_ASSERT(saved_thread_scheduler != NULL); + + if (saved_thread_scheduler == NULL) + return 1; + + thread_scheduler= saved_thread_scheduler; + thread_handling= saved_thread_handling; + saved_thread_scheduler= 0; + return 0; +} + + + diff --git a/sql/scheduler.h b/sql/scheduler.h index e7916031a27..40f0e28bc2c 100644 --- a/sql/scheduler.h +++ b/sql/scheduler.h @@ -28,38 +28,77 @@ class THD; /* Functions used when manipulating threads */ -class scheduler_functions +struct scheduler_functions { -public: uint max_threads; bool (*init)(void); bool (*init_new_connection_thread)(void); void (*add_connection)(THD *thd); + void (*thd_wait_begin)(THD *thd, int wait_type); + void (*thd_wait_end)(THD *thd); void (*post_kill_notification)(THD *thd); bool (*end_thread)(THD *thd, bool cache_thread); void (*end)(void); - scheduler_functions(); }; + +/** + Scheduler types enumeration. + + The default of --thread-handling is the first one in the + thread_handling_names array, this array has to be consistent with + the order in this array, so to change default one has to change the + first entry in this enum and the first entry in the + thread_handling_names array. + + @note The last entry of the enumeration is also used to mark the + thread handling as dynamic. In this case the name of the thread + handling is fetched from the name of the plugin that implements it. +*/ enum scheduler_types { SCHEDULER_ONE_THREAD_PER_CONNECTION=0, SCHEDULER_NO_THREADS, - SCHEDULER_POOL_OF_THREADS + SCHEDULER_TYPES_COUNT }; -void one_thread_per_connection_scheduler(scheduler_functions* func); -void one_thread_scheduler(scheduler_functions* func); +void one_thread_per_connection_scheduler(); +void one_thread_scheduler(); enum pool_command_op { NOT_IN_USE_OP= 0, NORMAL_OP= 1, CONNECT_OP, KILL_OP, DIE_OP }; -#define HAVE_POOL_OF_THREADS 0 /* For easyer tests */ -#define pool_of_threads_scheduler(A) one_thread_per_connection_scheduler(A) - +/* + To be used for pool-of-threads (implemeneted differently on various OSs) +*/ class thd_scheduler -{}; +{ +public: + /* + Thread instrumentation for the user job. + This member holds the instrumentation while the user job is not run + by a thread. -#endif /* SCHEDULER_INCLUDED */ + Note that this member is not conditionally declared + (ifdef HAVE_PSI_INTERFACE), because doing so will change the binary + layout of THD, which is exposed to plugin code that may be compiled + differently. + */ + PSI_thread *m_psi; + + void *data; /* scheduler-specific data structure */ + +# ifndef DBUG_OFF + char dbug_explain[512]; + bool set_explain; +# endif + + thd_scheduler(); + ~thd_scheduler(); +}; + +extern scheduler_functions *thread_scheduler; + +#endif diff --git a/sql/sql_callback.h b/sql/sql_callback.h new file mode 100644 index 00000000000..430514d3d7e --- /dev/null +++ b/sql/sql_callback.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef SQL_CALLBACK_INCLUDED +#define SQL_CALLBACK_INCLUDED + +/** + Macro used for an internal callback. + + The macro will check that the object exists and that the function + is defined. If that is the case, it will call the function with the + given parameters. + + If the object or the function is not defined, the callback will be + considered successful (nothing needed to be done) and will + therefore return no error. + */ + +#define MYSQL_CALLBACK(OBJ, FUNC, PARAMS) \ + do { \ + if ((OBJ) && ((OBJ)->FUNC)) \ + (OBJ)->FUNC PARAMS; \ + } while (0) + +#define MYSQL_CALLBACK_ELSE(OBJ, FUNC, PARAMS, ELSE) \ + (((OBJ) && ((OBJ)->FUNC)) ? (OBJ)->FUNC PARAMS : (ELSE)) + + +#endif /* SQL_CALLBACK_INCLUDED */ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index ef6dc6cf209..a47c6046bac 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -58,6 +58,7 @@ #include "transaction.h" #include "debug_sync.h" #include "sql_parse.h" // is_update_query +#include "sql_callback.h" /* The following is used to initialise Table_ident with a internal @@ -1055,6 +1056,7 @@ THD::~THD() DBUG_ENTER("~THD()"); /* Ensure that no one is using THD */ mysql_mutex_lock(&LOCK_thd_data); + mysys_var=0; // Safety (shouldn't be needed) mysql_mutex_unlock(&LOCK_thd_data); add_to_status(&global_status_var, &status_var); @@ -1080,7 +1082,6 @@ THD::~THD() main_security_ctx.destroy(); safeFree(db); free_root(&transaction.mem_root,MYF(0)); - mysys_var=0; // Safety (shouldn't be needed) mysql_mutex_destroy(&LOCK_thd_data); #ifndef DBUG_OFF dbug_sentry= THD_SENTRY_GONE; @@ -1163,7 +1164,7 @@ void THD::awake(THD::killed_state state_to_set) { thr_alarm_kill(thread_id); if (!slave_thread) - thread_scheduler.post_kill_notification(this); + MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (this)); #ifdef SIGNAL_WITH_VIO_CLOSE if (this != current_thd) { @@ -1232,6 +1233,15 @@ bool THD::store_globals() if (my_pthread_setspecific_ptr(THR_THD, this) || my_pthread_setspecific_ptr(THR_MALLOC, &mem_root)) return 1; + /* + mysys_var is concurrently readable by a killer thread. + It is protected by LOCK_thd_data, it is not needed to lock while the + pointer is changing from NULL not non-NULL. If the kill thread reads + NULL it doesn't refer to anything, but if it is non-NULL we need to + ensure that the thread doesn't proceed to assign another thread to + have the mysys_var reference (which in fact refers to the worker + threads local storage with key THR_KEY_mysys. + */ mysys_var=my_thread_var; /* Let mysqld define the thread id (not mysys) @@ -3145,6 +3155,60 @@ extern "C" bool thd_binlog_filter_ok(const MYSQL_THD thd) { return binlog_filter->db_ok(thd->db); } + +#ifndef EMBEDDED_LIBRARY +extern "C" void thd_pool_wait_begin(MYSQL_THD thd, int wait_type); +extern "C" void thd_pool_wait_end(MYSQL_THD thd); + +/* + Interface for MySQL Server, plugins and storage engines to report + when they are going to sleep/stall. + + SYNOPSIS + thd_wait_begin() + thd Thread object + wait_type Type of wait + 1 -- short wait (e.g. for mutex) + 2 -- medium wait (e.g. for disk io) + 3 -- large wait (e.g. for locked row/table) + NOTES + This is used by the threadpool to have better knowledge of which + threads that currently are actively running on CPUs. When a thread + reports that it's going to sleep/stall, the threadpool scheduler is + free to start another thread in the pool most likely. The expected wait + time is simply an indication of how long the wait is expected to + become, the real wait time could be very different. + + thd_wait_end MUST be called immediately after waking up again. +*/ +extern "C" void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type) +{ + MYSQL_CALLBACK(thread_scheduler, thd_wait_begin, (thd, wait_type)); +} + +/** + Interface for MySQL Server, plugins and storage engines to report + when they waking up from a sleep/stall. + + @param thd Thread handle +*/ +extern "C" void thd_wait_end(MYSQL_THD thd) +{ + MYSQL_CALLBACK(thread_scheduler, thd_wait_end, (thd)); +} +#else +extern "C" void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type) +{ + /* do NOTHING for the embedded library */ + return; +} + +extern "C" void thd_wait_end(MYSQL_THD thd) +{ + /* do NOTHING for the embedded library */ + return; +} +#endif #endif // INNODB_COMPATIBILITY_HOOKS */ /**************************************************************************** @@ -3324,6 +3388,13 @@ void THD::set_query_id(query_id_t new_query_id) mysql_mutex_unlock(&LOCK_thd_data); } +/** Assign a new value to thd->mysys_var. */ +void THD::set_mysys_var(struct st_my_thread_var *new_mysys_var) +{ + mysql_mutex_lock(&LOCK_thd_data); + mysys_var= new_mysys_var; + mysql_mutex_unlock(&LOCK_thd_data); +} /** Leave explicit LOCK TABLES or prelocked mode and restore value of diff --git a/sql/sql_class.h b/sql/sql_class.h index 0a098fc8492..50c6855e2c3 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1812,6 +1812,10 @@ public: xid_state.xid.null(); free_root(&mem_root,MYF(MY_KEEP_PREALLOC)); } + my_bool is_active() + { + return (all.ha_list != NULL); + } st_transactions() { bzero((char*)this, sizeof(*this)); @@ -2734,13 +2738,14 @@ public: virtual void set_statement(Statement *stmt); /** - Assign a new value to thd->query and thd->query_id. + Assign a new value to thd->query and thd->query_id and mysys_var. Protected with LOCK_thd_data mutex. */ void set_query(char *query_arg, uint32 query_length_arg); void set_query_and_id(char *query_arg, uint32 query_length_arg, query_id_t new_query_id); void set_query_id(query_id_t new_query_id); + void set_mysys_var(struct st_my_thread_var *new_mysys_var); void enter_locked_tables_mode(enum_locked_tables_mode mode_arg) { DBUG_ASSERT(locked_tables_mode == LTM_NONE); diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index e2d0977def7..00bfe372efd 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -35,6 +35,7 @@ #include "hostname.h" // inc_host_errors, ip_to_hostname, // reset_host_errors #include "sql_acl.h" // acl_getroot, NO_ACCESS, SUPER_ACL +#include "sql_callback.h" #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) /* @@ -958,7 +959,7 @@ bool setup_connection_thread_globals(THD *thd) { close_connection(thd, ER_OUT_OF_RESOURCES, 1); statistic_increment(aborted_connects,&LOCK_status); - thread_scheduler.end_thread(thd, 0); + MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0)); return 1; // Error } return 0; @@ -981,7 +982,7 @@ bool setup_connection_thread_globals(THD *thd) */ -static bool login_connection(THD *thd) +bool login_connection(THD *thd) { NET *net= &thd->net; int error; @@ -1019,7 +1020,7 @@ static bool login_connection(THD *thd) This mainly updates status variables */ -static void end_connection(THD *thd) +void end_connection(THD *thd) { NET *net= &thd->net; plugin_thdvar_cleanup(thd); @@ -1060,7 +1061,7 @@ static void end_connection(THD *thd) Initialize THD to handle queries */ -static void prepare_new_connection_state(THD* thd) +void prepare_new_connection_state(THD* thd) { Security_context *sctx= thd->security_ctx; @@ -1134,11 +1135,11 @@ void do_handle_one_connection(THD *thd_arg) thd->thr_create_utime= my_micro_time(); - if (thread_scheduler.init_new_connection_thread()) + if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0)) { close_connection(thd, ER_OUT_OF_RESOURCES, 1); statistic_increment(aborted_connects,&LOCK_status); - thread_scheduler.end_thread(thd,0); + MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0)); return; } @@ -1192,7 +1193,7 @@ void do_handle_one_connection(THD *thd_arg) end_thread: close_connection(thd, 0, 1); - if (thread_scheduler.end_thread(thd,1)) + if (MYSQL_CALLBACK_ELSE(thread_scheduler, end_thread, (thd, 1), 0)) return; // Probably no-threads /* diff --git a/sql/sql_connect.h b/sql/sql_connect.h index 2334b7303be..bfcc04ba093 100644 --- a/sql/sql_connect.h +++ b/sql/sql_connect.h @@ -40,4 +40,8 @@ int check_user(THD *thd, enum enum_server_command command, const char *passwd, uint passwd_len, const char *db, bool check_count); +bool login_connection(THD *thd); +void prepare_new_connection_state(THD* thd); +void end_connection(THD *thd); + #endif /* SQL_CONNECT_INCLUDED */ diff --git a/sql/sql_plugin_services.h b/sql/sql_plugin_services.h index 7491ddab79d..f39e22f1e21 100644 --- a/sql/sql_plugin_services.h +++ b/sql/sql_plugin_services.h @@ -36,9 +36,23 @@ static struct thd_alloc_service_st thd_alloc_handler= { thd_make_lex_string }; +static struct thd_wait_service_st thd_wait_handler= { + thd_wait_begin, + thd_wait_end +}; + +static struct my_thread_scheduler_service my_thread_scheduler_handler= { + my_thread_scheduler_set, + my_thread_scheduler_reset, +}; + + static struct st_service_ref list_of_services[]= { { "my_snprintf_service", VERSION_my_snprintf, &my_snprintf_handler }, - { "thd_alloc_service", VERSION_thd_alloc, &thd_alloc_handler } + { "thd_alloc_service", VERSION_thd_alloc, &thd_alloc_handler }, + { "thd_wait_service", VERSION_thd_wait, &thd_wait_handler }, + { "my_thread_scheduler_service", + VERSION_my_thread_scheduler, &my_thread_scheduler_handler }, }; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 41117650e4a..217128653c6 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1789,6 +1789,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) if ((thd_info->db=tmp->db)) // Safe test thd_info->db=thd->strdup(thd_info->db); thd_info->command=(int) tmp->command; + mysql_mutex_lock(&tmp->LOCK_thd_data); if ((mysys_var= tmp->mysys_var)) mysql_mutex_lock(&mysys_var->mutex); thd_info->proc_info= (char*) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0); @@ -1796,16 +1797,15 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) if (mysys_var) mysql_mutex_unlock(&mysys_var->mutex); - thd_info->start_time= tmp->start_time; thd_info->query=0; /* Lock THD mutex that protects its data when looking at it. */ - mysql_mutex_lock(&tmp->LOCK_thd_data); if (tmp->query()) { uint length= min(max_query_length, tmp->query_length()); thd_info->query= (char*) thd->strmake(tmp->query(),length); } mysql_mutex_unlock(&tmp->LOCK_thd_data); + thd_info->start_time= tmp->start_time; thread_infos.append(thd_info); } } @@ -1892,6 +1892,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) table->field[3]->set_notnull(); } + mysql_mutex_lock(&tmp->LOCK_thd_data); if ((mysys_var= tmp->mysys_var)) mysql_mutex_lock(&mysys_var->mutex); /* COMMAND */ @@ -1912,6 +1913,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) if (mysys_var) mysql_mutex_unlock(&mysys_var->mutex); + mysql_mutex_unlock(&tmp->LOCK_thd_data); /* INFO */ if (tmp->query()) diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index b5df2ae58c1..e743e994444 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1658,19 +1658,13 @@ static Sys_var_ulong Sys_trans_prealloc_size( static const char *thread_handling_names[]= { - "one-thread-per-connection", "no-threads", -#if HAVE_POOL_OF_THREADS == 1 - "pool-of-threads", -#endif + "one-thread-per-connection", "no-threads", "loaded-dynamically", 0 }; static Sys_var_enum Sys_thread_handling( "thread_handling", "Define threads usage for handling queries, one of " - "one-thread-per-connection, no-threads" -#if HAVE_POOL_OF_THREADS == 1 - ", pool-of-threads" -#endif + "one-thread-per-connection, no-threads, loaded-dynamically" , READ_ONLY GLOBAL_VAR(thread_handling), CMD_LINE(REQUIRED_ARG), thread_handling_names, DEFAULT(0)); @@ -1997,15 +1991,6 @@ static Sys_var_ulong Sys_thread_cache_size( GLOBAL_VAR(thread_cache_size), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 16384), DEFAULT(0), BLOCK_SIZE(1)); -#if HAVE_POOL_OF_THREADS == 1 -static Sys_var_ulong Sys_thread_pool_size( - "thread_pool_size", - "How many threads we should create to handle query requests in " - "case of 'thread_handling=pool-of-threads'", - GLOBAL_VAR(thread_pool_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(1, 16384), DEFAULT(20), BLOCK_SIZE(0)); -#endif - // Can't change the 'next' tx_isolation if we are already in a transaction static bool check_tx_isolation(sys_var *self, THD *thd, set_var *var) { diff --git a/storage/innobase/buf/buf0flu.c b/storage/innobase/buf/buf0flu.c index 8b614ce90e5..a1fea902301 100644 --- a/storage/innobase/buf/buf0flu.c +++ b/storage/innobase/buf/buf0flu.c @@ -43,6 +43,8 @@ Created 11/11/1995 Heikki Tuuri #include "log0log.h" #include "os0file.h" #include "trx0sys.h" +#include "mysql/plugin.h" +#include "mysql/service_thd_wait.h" /********************************************************************** These statistics are generated for heuristics used in estimating the @@ -1165,7 +1167,9 @@ buf_flush_wait_batch_end( { ut_ad((type == BUF_FLUSH_LRU) || (type == BUF_FLUSH_LIST)); + thd_wait_begin(NULL, THD_WAIT_DISKIO); os_event_wait(buf_pool->no_flush[type]); + thd_wait_end(NULL); } /******************************************************************//** diff --git a/storage/innobase/buf/buf0rea.c b/storage/innobase/buf/buf0rea.c index dd98ea17eb5..5a92aa87d0e 100644 --- a/storage/innobase/buf/buf0rea.c +++ b/storage/innobase/buf/buf0rea.c @@ -37,6 +37,8 @@ Created 11/5/1995 Heikki Tuuri #include "os0file.h" #include "srv0start.h" #include "srv0srv.h" +#include "mysql/plugin.h" +#include "mysql/service_thd_wait.h" /** The linear read-ahead area size */ #define BUF_READ_AHEAD_LINEAR_AREA BUF_READ_AHEAD_AREA @@ -135,6 +137,7 @@ buf_read_page_low( ut_ad(buf_page_in_file(bpage)); + thd_wait_begin(NULL, THD_WAIT_DISKIO); if (zip_size) { *err = fil_io(OS_FILE_READ | wake_later, sync, space, zip_size, offset, 0, zip_size, @@ -146,6 +149,7 @@ buf_read_page_low( sync, space, 0, offset, 0, UNIV_PAGE_SIZE, ((buf_block_t*) bpage)->frame, bpage); } + thd_wait_end(NULL); ut_a(*err == DB_SUCCESS); if (sync) { diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index 3b0e29b9b48..ba6a424256f 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -103,6 +103,8 @@ Created 10/8/1995 Heikki Tuuri #include "ha_prototypes.h" #include "trx0i_s.h" #include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */ +#include "mysql/plugin.h" +#include "mysql/service_thd_wait.h" /* This is set to TRUE if the MySQL user has set it in MySQL; currently affects only FOREIGN KEY definition parsing */ @@ -1186,7 +1188,9 @@ retry: trx->op_info = "waiting in InnoDB queue"; + thd_wait_begin(trx->mysql_thd, THD_WAIT_ROW_TABLE_LOCK); os_event_wait(slot->event); + thd_wait_end(trx->mysql_thd); trx->op_info = ""; @@ -1551,7 +1555,9 @@ srv_suspend_mysql_thread( /* Suspend this thread and wait for the event. */ + thd_wait_begin(trx->mysql_thd, THD_WAIT_ROW_TABLE_LOCK); os_event_wait(event); + thd_wait_end(trx->mysql_thd); /* After resuming, reacquire the data dictionary latch if necessary. */ diff --git a/vio/vio.c b/vio/vio.c index 73dd68b938f..210bcdb584b 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -44,6 +44,11 @@ static my_bool no_poll_read(Vio *vio __attribute__((unused)), #endif +static my_bool has_no_data(Vio *vio __attribute__((unused))) +{ + return FALSE; +} + /* * Helper to fill most of the Vio* with defaults. */ @@ -83,6 +88,7 @@ static void vio_init(Vio* vio, enum enum_vio_type type, vio->poll_read =no_poll_read; vio->is_connected =vio_is_connected_pipe; + vio->has_data =has_no_data; vio->timeout=vio_win32_timeout; /* Set default timeout */ @@ -110,6 +116,7 @@ static void vio_init(Vio* vio, enum enum_vio_type type, vio->poll_read =no_poll_read; vio->is_connected =vio_is_connected_shared_memory; + vio->has_data =has_no_data; /* Currently, shared memory is on Windows only, hence the below is ok*/ vio->timeout= vio_win32_timeout; @@ -137,6 +144,7 @@ static void vio_init(Vio* vio, enum enum_vio_type type, vio->timeout =vio_timeout; vio->poll_read =vio_poll_read; vio->is_connected =vio_is_connected; + vio->has_data =vio_ssl_has_data; DBUG_VOID_RETURN; } #endif /* HAVE_OPENSSL */ @@ -155,6 +163,8 @@ static void vio_init(Vio* vio, enum enum_vio_type type, vio->timeout =vio_timeout; vio->poll_read =vio_poll_read; vio->is_connected =vio_is_connected; + vio->has_data= (flags & VIO_BUFFERED_READ) ? + vio_buff_has_data : has_no_data; DBUG_VOID_RETURN; } diff --git a/vio/vio_priv.h b/vio/vio_priv.h index 69eb26083d6..1bfb857b039 100644 --- a/vio/vio_priv.h +++ b/vio/vio_priv.h @@ -49,6 +49,7 @@ int vio_close_shared_memory(Vio * vio); #endif void vio_timeout(Vio *vio,uint which, uint timeout); +my_bool vio_buff_has_data(Vio *vio); #ifdef HAVE_OPENSSL #include "my_net.h" /* needed because of struct in_addr */ @@ -62,5 +63,7 @@ void vio_ssl_delete(Vio *vio); int vio_ssl_blocking(Vio *vio, my_bool set_blocking_mode, my_bool *old_mode); +my_bool vio_ssl_has_data(Vio *vio); + #endif /* HAVE_OPENSSL */ #endif /* VIO_PRIV_INCLUDED */ diff --git a/vio/viosocket.c b/vio/viosocket.c index 6c361e4a462..e60fe9bb225 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -98,6 +98,10 @@ size_t vio_read_buff(Vio *vio, uchar* buf, size_t size) #undef VIO_UNBUFFERED_READ_MIN_SIZE } +my_bool vio_buff_has_data(Vio *vio) +{ + return (vio->read_pos != vio->read_end); +} size_t vio_write(Vio * vio, const uchar* buf, size_t size) { diff --git a/vio/viossl.c b/vio/viossl.c index 0651fd8b7a3..1c6863c9943 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -274,6 +274,9 @@ int vio_ssl_blocking(Vio *vio __attribute__((unused)), return (set_blocking_mode ? 0 : 1); } - +my_bool vio_ssl_has_data(Vio *vio) +{ + return SSL_pending(vio->ssl_arg) > 0 ? TRUE : FALSE; +} #endif /* HAVE_OPENSSL */ From 71553c2c9db3c4c27973f12461b986c59e1dabfb Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Tue, 15 Jun 2010 09:44:26 +0200 Subject: [PATCH 002/136] WL#5363: Thread Pool Service Interface Fixes to ensure that it builds with the embedded server as well. --- sql/scheduler.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sql/scheduler.cc b/sql/scheduler.cc index 19f8ddc7355..d61a452b99e 100644 --- a/sql/scheduler.cc +++ b/sql/scheduler.cc @@ -44,7 +44,11 @@ static scheduler_functions one_thread_scheduler_functions= 1, // max_threads NULL, // init init_new_connection_handler_thread, // init_new_connection_thread +#ifndef EMBEDDED_LIBRARY handle_connection_in_main_thread, // add_connection +#else + NULL, // add_connection +#endif // EMBEDDED_LIBRARY NULL, // thd_wait_begin NULL, // thd_wait_end NULL, // post_kill_notification @@ -52,6 +56,7 @@ static scheduler_functions one_thread_scheduler_functions= NULL, // end }; +#ifndef EMBEDDED_LIBRARY static scheduler_functions one_thread_per_connection_scheduler_functions= { 0, // max_threads @@ -64,10 +69,10 @@ static scheduler_functions one_thread_per_connection_scheduler_functions= one_thread_per_connection_end, // end_thread NULL, // end }; +#endif // EMBEDDED_LIBRARY -scheduler_functions *thread_scheduler= - &one_thread_per_connection_scheduler_functions; +scheduler_functions *thread_scheduler= NULL; /** @internal Helper functions to allow mysys to call the thread scheduler when From 0b273845def50dfd22e8a3e34c4b6f82fa522539 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Thu, 8 Jul 2010 14:36:55 +0200 Subject: [PATCH 003/136] Bug#46086: crash when dropping a partitioned table and the original engine is disabled Missing check that engine is available. --- mysql-test/include/not_blackhole.inc | 5 ++++ mysql-test/r/partition_not_blackhole.result | 16 +++++++++++ mysql-test/std_data/parts/t1_blackhole.frm | Bin 0 -> 8556 bytes mysql-test/std_data/parts/t1_blackhole.par | Bin 0 -> 24 bytes .../t/partition_not_blackhole-master.opt | 1 + mysql-test/t/partition_not_blackhole.test | 25 ++++++++++++++++++ sql/ha_partition.cc | 7 ++++- 7 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 mysql-test/include/not_blackhole.inc create mode 100644 mysql-test/r/partition_not_blackhole.result create mode 100644 mysql-test/std_data/parts/t1_blackhole.frm create mode 100644 mysql-test/std_data/parts/t1_blackhole.par create mode 100644 mysql-test/t/partition_not_blackhole-master.opt create mode 100644 mysql-test/t/partition_not_blackhole.test diff --git a/mysql-test/include/not_blackhole.inc b/mysql-test/include/not_blackhole.inc new file mode 100644 index 00000000000..078927ec4ca --- /dev/null +++ b/mysql-test/include/not_blackhole.inc @@ -0,0 +1,5 @@ +if (`SELECT count(*) FROM information_schema.engines WHERE + (support = 'YES' OR support = 'DEFAULT') AND + engine = 'blackhole'`){ + skip Blackhole engine enabled; +} diff --git a/mysql-test/r/partition_not_blackhole.result b/mysql-test/r/partition_not_blackhole.result new file mode 100644 index 00000000000..dc0339f8c48 --- /dev/null +++ b/mysql-test/r/partition_not_blackhole.result @@ -0,0 +1,16 @@ +DROP TABLE IF EXISTS t1; +# +# Bug#46086: crash when dropping a partitioned table and +# the original engine is disabled +# Copy a .frm and .par file which was created with: +# create table `t1` (`id` int primary key) engine=blackhole +# partition by key () partitions 1; +SHOW TABLES; +Tables_in_test +t1 +SHOW CREATE TABLE t1; +ERROR HY000: Incorrect information in file: './test/t1.frm' +DROP TABLE t1; +ERROR 42S02: Unknown table 't1' +t1.frm +t1.par diff --git a/mysql-test/std_data/parts/t1_blackhole.frm b/mysql-test/std_data/parts/t1_blackhole.frm new file mode 100644 index 0000000000000000000000000000000000000000..be77b7a041abe8aeb50ac1add88c9a5178904808 GIT binary patch literal 8556 zcmeI&KMR6D7zXg?`~#_rkhHX1TTT^3a|I0&l~{{o&~gwJ;Roou^;!BF*^5bYQy4t& za(asQ+;8*cp2~}CAXLB*Fv`WJtR7lGH6i1>jJ)@_1LNwp4Gac=t{-xs00k&O0SZun z0u-PC1t>rP3Q(Y#0!n`9eTn8kE}(7}(49Ic(=1udvb=0&>OV|XOM1BMuZ1bh`P7qL z=yaCtl3lV{>v^u1i(L0(|1-DMqd(j!BU69^6rcbFC_n)UP=Epypg;o!jtXG|WBn|W vlD@|Tfvo4gk2+Ki$U|?Vb(!xN@48#RMJ^&A(0aXA1 literal 0 HcmV?d00001 diff --git a/mysql-test/t/partition_not_blackhole-master.opt b/mysql-test/t/partition_not_blackhole-master.opt new file mode 100644 index 00000000000..1e47be930bc --- /dev/null +++ b/mysql-test/t/partition_not_blackhole-master.opt @@ -0,0 +1 @@ +--loose-skip-blackhole diff --git a/mysql-test/t/partition_not_blackhole.test b/mysql-test/t/partition_not_blackhole.test new file mode 100644 index 00000000000..222c1bb091e --- /dev/null +++ b/mysql-test/t/partition_not_blackhole.test @@ -0,0 +1,25 @@ +--source include/have_partition.inc +--source include/not_blackhole.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +let $MYSQLD_DATADIR= `SELECT @@datadir`; + +--echo # +--echo # Bug#46086: crash when dropping a partitioned table and +--echo # the original engine is disabled +--echo # Copy a .frm and .par file which was created with: +--echo # create table `t1` (`id` int primary key) engine=blackhole +--echo # partition by key () partitions 1; +--copy_file std_data/parts/t1_blackhole.frm $MYSQLD_DATADIR/test/t1.frm +--copy_file std_data/parts/t1_blackhole.par $MYSQLD_DATADIR/test/t1.par +SHOW TABLES; +--error ER_NOT_FORM_FILE +SHOW CREATE TABLE t1; +--error ER_BAD_TABLE_ERROR +DROP TABLE t1; +--list_files $MYSQLD_DATADIR/test t1* +--remove_file $MYSQLD_DATADIR/test/t1.frm +--remove_file $MYSQLD_DATADIR/test/t1.par diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 60722f0100e..07a9035f865 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2403,9 +2403,14 @@ bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root) tot_partition_words= (m_tot_parts + 3) / 4; engine_array= (handlerton **) my_alloca(m_tot_parts * sizeof(handlerton*)); for (i= 0; i < m_tot_parts; i++) + { engine_array[i]= ha_resolve_by_legacy_type(ha_thd(), (enum legacy_db_type) - *(uchar *) ((file_buffer) + 12 + i)); + *(uchar *) ((file_buffer) + + 12 + i)); + if (!engine_array[i]) + goto err3; + } address_tot_name_len= file_buffer + 12 + 4 * tot_partition_words; tot_name_words= (uint4korr(address_tot_name_len) + 3) / 4; if (len_words != (tot_partition_words + tot_name_words + 4)) From bb3fbba1af97d95ec60f604e10796b9cff9b432d Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 23 Jul 2010 15:52:54 +0400 Subject: [PATCH 004/136] Bug #54476: crash when group_concat and 'with rollup' in prepared statements Using GROUP_CONCAT() together with the WITH ROLLUP modifier could crash the server. The reason was a combination of several facts: 1. The Item_func_group_concat class stores pointers to ORDER objects representing the columns in the ORDER BY clause of GROUP_CONCAT(). 2. find_order_in_list() called from Item_func_group_concat::setup() modifies the ORDER objects so that their 'item' member points to the arguments list allocated in the Item_func_group_concat constructor. 3. In some cases (e.g. in JOIN::rollup_make_fields) a copy of the original Item_func_group_concat object could be created by using the Item_func_group_concat::Item_func_group_concat(THD *thd, Item_func_group_concat *item) copy constructor. The latter essentially creates a shallow copy of the source object. Memory for the arguments array is allocated on thd->mem_root, but the pointers for arguments and ORDER are copied verbatim. What happens in the test case is that when executing the query for the first time, after a copy of the original Item_func_group_concat object has been created by JOIN::rollup_make_fields(), find_order_in_list() is called for this new object. It then resolves ORDER BY by modifying the ORDER objects so that they point to elements of the arguments array which is local to the cloned object. When thd->mem_root is freed upon completing the execution, pointers in the ORDER objects become invalid. Those ORDER objects, however, are also shared with the original Item_func_group_concat object which is preserved between executions of a prepared statement. So the first call to find_order_in_list() for the original object on the second execution tries to dereference an invalid pointer. The solution is to create copies of the ORDER objects when copying Item_func_group_concat to not leave any stale pointers in other instances with different lifecycles. --- mysql-test/r/func_gconcat.result | 21 ++++++++++++++++++++- mysql-test/t/func_gconcat.test | 16 +++++++++++++++- sql/item_sum.cc | 19 ++++++++++++++++++- sql/table.h | 1 - 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 766f3b6bfaa..ae48eb1e0ff 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -995,6 +995,7 @@ SELECT 1 FROM 1 1 DROP TABLE t1; +End of 5.0 tests # # Bug #52397: another crash with explain extended and group_concat # @@ -1010,4 +1011,22 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select 1 AS `1` from (select group_concat(`test`.`t1`.`a` order by `test`.`t1`.`a` ASC separator ',') AS `GROUP_CONCAT(t1.a ORDER BY t1.a ASC)` from `test`.`t1` `t2` join `test`.`t1` group by `test`.`t1`.`a`) `d` DROP TABLE t1; -End of 5.0 tests +# +# Bug #54476: crash when group_concat and 'with rollup' in prepared statements +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +PREPARE stmt FROM "SELECT GROUP_CONCAT(t1.a ORDER BY t1.a) FROM t1 JOIN t1 t2 GROUP BY t1.a WITH ROLLUP"; +EXECUTE stmt; +GROUP_CONCAT(t1.a ORDER BY t1.a) +1,1 +2,2 +1,1,2,2 +EXECUTE stmt; +GROUP_CONCAT(t1.a ORDER BY t1.a) +1,1 +2,2 +1,1,2,2 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index e832ea316eb..926c1f92855 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -708,6 +708,7 @@ SELECT 1 FROM DROP TABLE t1; +--echo End of 5.0 tests --echo # --echo # Bug #52397: another crash with explain extended and group_concat @@ -719,5 +720,18 @@ EXPLAIN EXTENDED SELECT 1 FROM t1 t2, t1 GROUP BY t1.a) AS d; DROP TABLE t1; +--echo # +--echo # Bug #54476: crash when group_concat and 'with rollup' in prepared statements +--echo # ---echo End of 5.0 tests +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); + +PREPARE stmt FROM "SELECT GROUP_CONCAT(t1.a ORDER BY t1.a) FROM t1 JOIN t1 t2 GROUP BY t1.a WITH ROLLUP"; +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 228e36fc9f9..1048bd3d6ff 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3034,7 +3034,6 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, tree(item->tree), unique_filter(item->unique_filter), table(item->table), - order(item->order), context(item->context), arg_count_order(item->arg_count_order), arg_count_field(item->arg_count_field), @@ -3047,6 +3046,24 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, { quick_group= item->quick_group; result.set_charset(collation.collation); + + /* + Since the ORDER structures pointed to by the elements of the 'order' array + may be modified in find_order_in_list() called from + Item_func_group_concat::setup(), create a copy of those structures so that + such modifications done in this object would not have any effect on the + object being copied. + */ + ORDER *tmp; + if (!(order= (ORDER **) thd->alloc(sizeof(ORDER *) * arg_count_order + + sizeof(ORDER) * arg_count_order))) + return; + tmp= (ORDER *)(order + arg_count_order); + for (uint i= 0; i < arg_count_order; i++, tmp++) + { + memcpy(tmp, item->order[i], sizeof(ORDER)); + order[i]= tmp; + } } diff --git a/sql/table.h b/sql/table.h index 3ef3c5e0cb2..9088b3b6965 100644 --- a/sql/table.h +++ b/sql/table.h @@ -55,7 +55,6 @@ typedef struct st_order { struct st_order *next; Item **item; /* Point at item in select fields */ Item *item_ptr; /* Storage for initial item */ - Item **item_copy; /* For SPs; the original item ptr */ int counter; /* position in SELECT list, correct only if counter_used is true*/ bool asc; /* true if ascending */ From 5fff906edd3d7a5d999cec5403f009f33f8dfb81 Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Tue, 27 Jul 2010 17:34:58 +0400 Subject: [PATCH 005/136] Fix for bug #52044 "FLUSH TABLES WITH READ LOCK and FLUSH TABLES WITH READ LOCK are incompatible". The problem was that FLUSH TABLES WITH READ LOCK which was issued when other connection has acquired global read lock using FLUSH TABLES WITH READ LOCK was blocked and has to wait until global read lock is released. This issue stemmed from the fact that FLUSH TABLES WITH READ LOCK implementation has acquired X metadata locks on tables to be flushed. Since these locks required acquiring of global IX lock this statement was incompatible with global read lock. This patch addresses problem by using SNW metadata type of lock for tables to be flushed by FLUSH TABLES WITH READ LOCK. It is OK to acquire them without global IX lock as long as we won't try to upgrade those locks. Since SNW locks allow concurrent statements using same table FLUSH TABLE WITH READ LOCK now has to wait until old versions of tables to be flushed go away after acquiring metadata locks. Since such waiting can lead to deadlock MDL deadlock detector was extended to take into account waits for flush and resolve such deadlocks. As a bonus code in open_tables() which was responsible for waiting old versions of tables to go away was refactored. Now when we encounter old version of table in open_table() we don't back-off and wait for all old version to go away, but instead wait for this particular table to be flushed. Such approach supported by deadlock detection should reduce number of scenarios in which FLUSH TABLES aborts concurrent multi-statement transactions. Note that active FLUSH TABLES WITH READ LOCK still blocks concurrent FLUSH TABLES WITH READ LOCK statement as the former keeps tables open and thus prevents the latter statement from doing flush. --- mysql-test/include/handler.inc | 2 +- mysql-test/r/flush.result | 14 + mysql-test/r/mdl_sync.result | 151 ++++++++++ .../perfschema/r/dml_setup_instruments.result | 2 +- .../suite/perfschema/r/server_init.result | 4 - .../suite/perfschema/t/server_init.test | 3 - mysql-test/t/flush.test | 14 + mysql-test/t/kill.test | 2 +- mysql-test/t/lock_multi.test | 2 +- mysql-test/t/mdl_sync.test | 250 ++++++++++++++++ sql/ha_ndbcluster.cc | 4 +- sql/ha_ndbcluster_binlog.cc | 12 +- sql/lock.cc | 24 +- sql/mdl.cc | 88 ++---- sql/mdl.h | 99 ++++++- sql/mysqld.cc | 7 +- sql/mysqld.h | 4 +- sql/sql_base.cc | 268 ++++++++---------- sql/sql_base.h | 11 +- sql/sql_class.h | 6 + sql/sql_parse.cc | 54 ++-- sql/sql_yacc.yy | 3 +- sql/sys_vars.cc | 3 +- sql/table.cc | 257 ++++++++++++++++- sql/table.h | 51 ++++ 25 files changed, 1038 insertions(+), 297 deletions(-) diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index 98988ab55ba..a8c62d3994f 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -523,7 +523,7 @@ connection waiter; --echo connection: waiter let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Flushing tables"; + where state = "Waiting for table"; --source include/wait_condition.inc connection default; --echo connection: default diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result index 3702443d04a..4251615a6e6 100644 --- a/mysql-test/r/flush.result +++ b/mysql-test/r/flush.result @@ -205,6 +205,20 @@ a insert into t2 (a) values (3); # --> connection default; unlock tables; +# +# Check that "flush tables with read lock" is +# compatible with active "flush tables with read lock". +# Vice versa is not true as tables read-locked by +# "flush tables with read lock" can't be flushed. +flush tables with read lock; +# --> connection con1; +flush table t1 with read lock; +select * from t1; +a +1 +unlock tables; +# --> connection default; +unlock tables; # --> connection con1 drop table t1, t2, t3; # diff --git a/mysql-test/r/mdl_sync.result b/mysql-test/r/mdl_sync.result index 0fd408b0208..2e3195c5a53 100644 --- a/mysql-test/r/mdl_sync.result +++ b/mysql-test/r/mdl_sync.result @@ -2034,6 +2034,157 @@ set debug_sync='now SIGNAL go2'; # Switching to connection 'default'. # Reaping ALTER. It should succeed and not produce ER_LOCK_DEADLOCK. drop table t1; +# +# Now, test for situation in which deadlock involves waiting not +# only in MDL subsystem but also for TDC. Such deadlocks should be +# successfully detected. If possible they should be resolved without +# resorting to ER_LOCK_DEADLOCK error. +# +create table t1(i int); +create table t2(j int); +# +# First, let us check how we handle simple scenario involving +# waits in MDL and TDC. +# +set debug_sync= 'RESET'; +# Switching to connection 'deadlock_con1'. +# Start statement which will acquire SR metadata lock on t1, open it +# and then will stop, before trying to acquire SW lock and opening t2. +set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; +# Sending: +select * from t1 where i in (select j from t2 for update); +# Switching to connection 'deadlock_con2'. +# Wait till the above SELECT stops. +set debug_sync='now WAIT_FOR parked'; +# The below FLUSH TABLES WITH READ LOCK should acquire +# SNW locks on t1 and t2 and wait till SELECT closes t1. +# Sending: +flush tables t1, t2 with read lock; +# Switching to connection 'deadlock_con3'. +# Wait until FLUSH TABLES WITH READ LOCK starts waiting +# for SELECT to close t1. +# Resume SELECT, so it tries to acquire SW lock on t1 and blocks, +# creating a deadlock. This deadlock should be detected and resolved +# by backing-off SELECT. As result FLUSH TABLES WITH READ LOCK should +# be able to finish. +set debug_sync='now SIGNAL go'; +# Switching to connection 'deadlock_con2'. +# Reap FLUSH TABLES WITH READ LOCK. +unlock tables; +# Switching to connection 'deadlock_con1'. +# Reap SELECT. +i +# +# The same scenario with a slightly different order of events +# which emphasizes that setting correct deadlock detector weights +# for flush waits is important. +# +set debug_sync= 'RESET'; +# Switching to connection 'deadlock_con2'. +set debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked WAIT_FOR go'; +# The below FLUSH TABLES WITH READ LOCK should acquire +# SNW locks on t1 and t2 and wait on debug sync point. +# Sending: +flush tables t1, t2 with read lock; +# Switching to connection 'deadlock_con1'. +# Wait till FLUSH TABLE WITH READ LOCK stops. +set debug_sync='now WAIT_FOR parked'; +# Start statement which will acquire SR metadata lock on t1, open +# it and then will block while trying to acquire SW lock on t2. +# Sending: +select * from t1 where i in (select j from t2 for update); +# Switching to connection 'deadlock_con3'. +# Wait till the above SELECT blocks. +# Resume FLUSH TABLES, so it tries to flush t1 creating a deadlock. +# This deadlock should be detected and resolved by backing-off SELECT. +# As result FLUSH TABLES WITH READ LOCK should be able to finish. +set debug_sync='now SIGNAL go'; +# Switching to connection 'deadlock_con2'. +# Reap FLUSH TABLES WITH READ LOCK. +unlock tables; +# Switching to connection 'deadlock_con1'. +# Reap SELECT. +i +# +# Now more complex scenario involving two connections +# waiting for MDL and one for TDC. +# +set debug_sync= 'RESET'; +# Switching to connection 'deadlock_con1'. +# Start statement which will acquire SR metadata lock on t2, open it +# and then will stop, before trying to acquire SR lock and opening t1. +set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; +# Sending: +select * from t2, t1; +# Switching to connection 'deadlock_con2'. +# Wait till the above SELECT stops. +set debug_sync='now WAIT_FOR parked'; +# The below FLUSH TABLES WITH READ LOCK should acquire +# SNW locks on t2 and wait till SELECT closes t2. +# Sending: +flush tables t2 with read lock; +# Switching to connection 'deadlock_con3'. +# Wait until FLUSH TABLES WITH READ LOCK starts waiting +# for SELECT to close t2. +# The below DROP TABLES should acquire X lock on t1 and start +# waiting for X lock on t2. +# Sending: +drop tables t1, t2; +# Switching to connection 'default'. +# Wait until DROP TABLES starts waiting for X lock on t2. +# Resume SELECT, so it tries to acquire SR lock on t1 and blocks, +# creating a deadlock. This deadlock should be detected and resolved +# by backing-off SELECT. As result FLUSH TABLES WITH READ LOCK should +# be able to finish. +set debug_sync='now SIGNAL go'; +# Switching to connection 'deadlock_con2'. +# Reap FLUSH TABLES WITH READ LOCK. +# Unblock DROP TABLES. +unlock tables; +# Switching to connection 'deadlock_con3'. +# Reap DROP TABLES. +# Switching to connection 'deadlock_con1'. +# Reap SELECT. It should emit error about missing table. +ERROR 42S02: Table 'test.t2' doesn't exist +# Switching to connection 'default'. +set debug_sync= 'RESET'; +# +# Test for scenario in which FLUSH TABLES WITH READ LOCK +# has been erroneously releasing metadata locks. +# +drop tables if exists t1, t2; +set debug_sync= 'RESET'; +create table t1(i int); +create table t2(j int); +# Switching to connection 'con2'. +set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; +# The below FLUSH TABLES WITH READ LOCK should acquire +# SNW locks on t1 and t2, open table t1 and wait on debug sync +# point. +# Sending: +flush tables t1, t2 with read lock; +# Switching to connection 'con1'. +# Wait till FLUSH TABLES WITH READ LOCK stops. +set debug_sync='now WAIT_FOR parked'; +# Start statement which will flush all tables and thus invalidate +# table t1 open by FLUSH TABLES WITH READ LOCK. +# Sending: +flush tables; +# Switching to connection 'default'. +# Wait till the above FLUSH TABLES blocks. +# Resume FLUSH TABLES WITH READ LOCK, so it tries to open t2 +# discovers that its t1 is obsolete and tries to reopen all tables. +# Such reopen should not cause releasing of SNW metadata locks +# which will result in assertion failures. +set debug_sync='now SIGNAL go'; +# Switching to connection 'con2'. +# Reap FLUSH TABLES WITH READ LOCK. +unlock tables; +# Switching to connection 'con1'. +# Reap FLUSH TABLES. +# Clean-up. +# Switching to connection 'default'. +drop tables t1, t2; set debug_sync= 'RESET'; # # Test for bug #46748 "Assertion in MDL_context::wait_for_locks() diff --git a/mysql-test/suite/perfschema/r/dml_setup_instruments.result b/mysql-test/suite/perfschema/r/dml_setup_instruments.result index 55256894743..2338252976c 100644 --- a/mysql-test/suite/perfschema/r/dml_setup_instruments.result +++ b/mysql-test/suite/perfschema/r/dml_setup_instruments.result @@ -40,12 +40,12 @@ wait/synch/cond/sql/COND_flush_thread_cache YES YES wait/synch/cond/sql/COND_global_read_lock YES YES wait/synch/cond/sql/COND_manager YES YES wait/synch/cond/sql/COND_queue_state YES YES -wait/synch/cond/sql/COND_refresh YES YES wait/synch/cond/sql/COND_rpl_status YES YES wait/synch/cond/sql/COND_server_started YES YES wait/synch/cond/sql/COND_thread_cache YES YES wait/synch/cond/sql/COND_thread_count YES YES wait/synch/cond/sql/Delayed_insert::cond YES YES +wait/synch/cond/sql/Delayed_insert::cond_client YES YES select * from performance_schema.SETUP_INSTRUMENTS where name='Wait'; select * from performance_schema.SETUP_INSTRUMENTS diff --git a/mysql-test/suite/perfschema/r/server_init.result b/mysql-test/suite/perfschema/r/server_init.result index a37a5805dd7..a73f12a0a20 100644 --- a/mysql-test/suite/perfschema/r/server_init.result +++ b/mysql-test/suite/perfschema/r/server_init.result @@ -184,10 +184,6 @@ where name like "wait/synch/cond/sql/COND_server_started"; count(name) 1 select count(name) from COND_INSTANCES -where name like "wait/synch/cond/sql/COND_refresh"; -count(name) -1 -select count(name) from COND_INSTANCES where name like "wait/synch/cond/sql/COND_thread_count"; count(name) 1 diff --git a/mysql-test/suite/perfschema/t/server_init.test b/mysql-test/suite/perfschema/t/server_init.test index 0bb3dd84ac4..080509b944f 100644 --- a/mysql-test/suite/perfschema/t/server_init.test +++ b/mysql-test/suite/perfschema/t/server_init.test @@ -209,9 +209,6 @@ select count(name) from RWLOCK_INSTANCES select count(name) from COND_INSTANCES where name like "wait/synch/cond/sql/COND_server_started"; -select count(name) from COND_INSTANCES - where name like "wait/synch/cond/sql/COND_refresh"; - select count(name) from COND_INSTANCES where name like "wait/synch/cond/sql/COND_thread_count"; diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index 0d406338394..0157f2dc764 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -318,6 +318,20 @@ insert into t2 (a) values (3); --echo # --> connection default; connection default; unlock tables; +--echo # +--echo # Check that "flush tables with read lock" is +--echo # compatible with active "flush tables with read lock". +--echo # Vice versa is not true as tables read-locked by +--echo # "flush tables with read lock" can't be flushed. +flush tables with read lock; +--echo # --> connection con1; +connection con1; +flush table t1 with read lock; +select * from t1; +unlock tables; +--echo # --> connection default; +connection default; +unlock tables; --echo # --> connection con1 connection con1; disconnect con1; diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index b91feb3a1d5..7169ca5f7c3 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -536,7 +536,7 @@ connection ddl; connection dml; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Flushing tables" and + where state = "Waiting for table" and info = "flush tables"; --source include/wait_condition.inc --send select * from t1 diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index 6983947d1c4..2a31392e8f8 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -982,7 +982,7 @@ connection con3; connection con2; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Flushing tables" AND info = "FLUSH TABLES"; + WHERE state = "Waiting for table" AND info = "FLUSH TABLES"; --source include/wait_condition.inc --error ER_LOCK_WAIT_TIMEOUT SELECT * FROM t1; diff --git a/mysql-test/t/mdl_sync.test b/mysql-test/t/mdl_sync.test index 6b721ace07f..13e6aef10be 100644 --- a/mysql-test/t/mdl_sync.test +++ b/mysql-test/t/mdl_sync.test @@ -2829,6 +2829,187 @@ connection default; drop table t1; +--echo # +--echo # Now, test for situation in which deadlock involves waiting not +--echo # only in MDL subsystem but also for TDC. Such deadlocks should be +--echo # successfully detected. If possible they should be resolved without +--echo # resorting to ER_LOCK_DEADLOCK error. +--echo # +create table t1(i int); +create table t2(j int); + +--echo # +--echo # First, let us check how we handle simple scenario involving +--echo # waits in MDL and TDC. +--echo # +set debug_sync= 'RESET'; + +--echo # Switching to connection 'deadlock_con1'. +connection deadlock_con1; +--echo # Start statement which will acquire SR metadata lock on t1, open it +--echo # and then will stop, before trying to acquire SW lock and opening t2. +set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; +--echo # Sending: +--send select * from t1 where i in (select j from t2 for update) + +--echo # Switching to connection 'deadlock_con2'. +connection deadlock_con2; +--echo # Wait till the above SELECT stops. +set debug_sync='now WAIT_FOR parked'; +--echo # The below FLUSH TABLES WITH READ LOCK should acquire +--echo # SNW locks on t1 and t2 and wait till SELECT closes t1. +--echo # Sending: +--send flush tables t1, t2 with read lock + +--echo # Switching to connection 'deadlock_con3'. +connection deadlock_con3; +--echo # Wait until FLUSH TABLES WITH READ LOCK starts waiting +--echo # for SELECT to close t1. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table" and info = "flush tables t1, t2 with read lock"; +--source include/wait_condition.inc + +--echo # Resume SELECT, so it tries to acquire SW lock on t1 and blocks, +--echo # creating a deadlock. This deadlock should be detected and resolved +--echo # by backing-off SELECT. As result FLUSH TABLES WITH READ LOCK should +--echo # be able to finish. +set debug_sync='now SIGNAL go'; + +--echo # Switching to connection 'deadlock_con2'. +connection deadlock_con2; +--echo # Reap FLUSH TABLES WITH READ LOCK. +--reap +unlock tables; + +--echo # Switching to connection 'deadlock_con1'. +connection deadlock_con1; +--echo # Reap SELECT. +--reap + +--echo # +--echo # The same scenario with a slightly different order of events +--echo # which emphasizes that setting correct deadlock detector weights +--echo # for flush waits is important. +--echo # +set debug_sync= 'RESET'; + +--echo # Switching to connection 'deadlock_con2'. +connection deadlock_con2; +set debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked WAIT_FOR go'; + +--echo # The below FLUSH TABLES WITH READ LOCK should acquire +--echo # SNW locks on t1 and t2 and wait on debug sync point. +--echo # Sending: +--send flush tables t1, t2 with read lock + +--echo # Switching to connection 'deadlock_con1'. +connection deadlock_con1; +--echo # Wait till FLUSH TABLE WITH READ LOCK stops. +set debug_sync='now WAIT_FOR parked'; + +--echo # Start statement which will acquire SR metadata lock on t1, open +--echo # it and then will block while trying to acquire SW lock on t2. +--echo # Sending: +--send select * from t1 where i in (select j from t2 for update) + +--echo # Switching to connection 'deadlock_con3'. +connection deadlock_con3; +--echo # Wait till the above SELECT blocks. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table" and + info = "select * from t1 where i in (select j from t2 for update)"; +--source include/wait_condition.inc + +--echo # Resume FLUSH TABLES, so it tries to flush t1 creating a deadlock. +--echo # This deadlock should be detected and resolved by backing-off SELECT. +--echo # As result FLUSH TABLES WITH READ LOCK should be able to finish. +set debug_sync='now SIGNAL go'; + +--echo # Switching to connection 'deadlock_con2'. +connection deadlock_con2; +--echo # Reap FLUSH TABLES WITH READ LOCK. +--reap +unlock tables; + +--echo # Switching to connection 'deadlock_con1'. +connection deadlock_con1; +--echo # Reap SELECT. +--reap + +--echo # +--echo # Now more complex scenario involving two connections +--echo # waiting for MDL and one for TDC. +--echo # +set debug_sync= 'RESET'; + +--echo # Switching to connection 'deadlock_con1'. +connection deadlock_con1; +--echo # Start statement which will acquire SR metadata lock on t2, open it +--echo # and then will stop, before trying to acquire SR lock and opening t1. +set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; +--echo # Sending: +--send select * from t2, t1 + +--echo # Switching to connection 'deadlock_con2'. +connection deadlock_con2; +--echo # Wait till the above SELECT stops. +set debug_sync='now WAIT_FOR parked'; +--echo # The below FLUSH TABLES WITH READ LOCK should acquire +--echo # SNW locks on t2 and wait till SELECT closes t2. +--echo # Sending: +--send flush tables t2 with read lock + +--echo # Switching to connection 'deadlock_con3'. +connection deadlock_con3; +--echo # Wait until FLUSH TABLES WITH READ LOCK starts waiting +--echo # for SELECT to close t2. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table" and info = "flush tables t2 with read lock"; +--source include/wait_condition.inc + +--echo # The below DROP TABLES should acquire X lock on t1 and start +--echo # waiting for X lock on t2. +--echo # Sending: +--send drop tables t1, t2 + +--echo # Switching to connection 'default'. +connection default; +--echo # Wait until DROP TABLES starts waiting for X lock on t2. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table" and info = "drop tables t1, t2"; +--source include/wait_condition.inc + +--echo # Resume SELECT, so it tries to acquire SR lock on t1 and blocks, +--echo # creating a deadlock. This deadlock should be detected and resolved +--echo # by backing-off SELECT. As result FLUSH TABLES WITH READ LOCK should +--echo # be able to finish. +set debug_sync='now SIGNAL go'; + +--echo # Switching to connection 'deadlock_con2'. +connection deadlock_con2; +--echo # Reap FLUSH TABLES WITH READ LOCK. +--reap +--echo # Unblock DROP TABLES. +unlock tables; + +--echo # Switching to connection 'deadlock_con3'. +connection deadlock_con3; +--echo # Reap DROP TABLES. +--reap + +--echo # Switching to connection 'deadlock_con1'. +connection deadlock_con1; +--echo # Reap SELECT. It should emit error about missing table. +--error ER_NO_SUCH_TABLE +--reap + +--echo # Switching to connection 'default'. +connection default; + set debug_sync= 'RESET'; disconnect deadlock_con1; @@ -2836,6 +3017,75 @@ disconnect deadlock_con2; disconnect deadlock_con3; +--echo # +--echo # Test for scenario in which FLUSH TABLES WITH READ LOCK +--echo # has been erroneously releasing metadata locks. +--echo # +connect(con1,localhost,root,,); +connect(con2,localhost,root,,); +connection default; +--disable_warnings +drop tables if exists t1, t2; +--enable_warnings +set debug_sync= 'RESET'; +create table t1(i int); +create table t2(j int); + +--echo # Switching to connection 'con2'. +connection con2; +set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; + +--echo # The below FLUSH TABLES WITH READ LOCK should acquire +--echo # SNW locks on t1 and t2, open table t1 and wait on debug sync +--echo # point. +--echo # Sending: +--send flush tables t1, t2 with read lock + +--echo # Switching to connection 'con1'. +connection con1; +--echo # Wait till FLUSH TABLES WITH READ LOCK stops. +set debug_sync='now WAIT_FOR parked'; + +--echo # Start statement which will flush all tables and thus invalidate +--echo # table t1 open by FLUSH TABLES WITH READ LOCK. +--echo # Sending: +--send flush tables + +--echo # Switching to connection 'default'. +connection default; +--echo # Wait till the above FLUSH TABLES blocks. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table" and + info = "flush tables"; +--source include/wait_condition.inc + +--echo # Resume FLUSH TABLES WITH READ LOCK, so it tries to open t2 +--echo # discovers that its t1 is obsolete and tries to reopen all tables. +--echo # Such reopen should not cause releasing of SNW metadata locks +--echo # which will result in assertion failures. +set debug_sync='now SIGNAL go'; + +--echo # Switching to connection 'con2'. +connection con2; +--echo # Reap FLUSH TABLES WITH READ LOCK. +--reap +unlock tables; + +--echo # Switching to connection 'con1'. +connection con1; +--echo # Reap FLUSH TABLES. +--reap + +--echo # Clean-up. +--echo # Switching to connection 'default'. +connection default; +drop tables t1, t2; +set debug_sync= 'RESET'; +disconnect con1; +disconnect con2; + + --echo # --echo # Test for bug #46748 "Assertion in MDL_context::wait_for_locks() --echo # on INSERT + CREATE TRIGGER". diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 7cac8373bc4..e3bafe36fb7 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -679,7 +679,7 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans) bzero((char*) &table_list,sizeof(table_list)); table_list.db= m_dbname; table_list.alias= table_list.table_name= m_tabname; - close_cached_tables(thd, &table_list, FALSE, FALSE); + close_cached_tables(thd, &table_list, FALSE, FALSE, LONG_TIMEOUT); break; } default: @@ -8452,7 +8452,7 @@ int handle_trailing_share(NDB_SHARE *share) table_list.db= share->db; table_list.alias= table_list.table_name= share->table_name; mysql_mutex_assert_owner(&LOCK_open); - close_cached_tables(thd, &table_list, TRUE, FALSE); + close_cached_tables(thd, &table_list, TRUE, FALSE, LONG_TIMEOUT); mysql_mutex_lock(&ndbcluster_mutex); /* ndb_share reference temporary free */ diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index b610687496e..e7ec6d67d52 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -937,7 +937,7 @@ int ndbcluster_setup_binlog_table_shares(THD *thd) ndb_binlog_tables_inited= TRUE; if (opt_ndb_extra_logging) sql_print_information("NDB Binlog: ndb tables writable"); - close_cached_tables(NULL, NULL, TRUE, FALSE); + close_cached_tables(NULL, NULL, TRUE, FALSE, LONG_TIMEOUT); mysql_mutex_unlock(&LOCK_open); /* Signal injector thread that all is setup */ mysql_cond_signal(&injector_cond); @@ -1751,7 +1751,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, bzero((char*) &table_list,sizeof(table_list)); table_list.db= (char *)dbname; table_list.alias= table_list.table_name= (char *)tabname; - close_cached_tables(thd, &table_list, TRUE, FALSE); + close_cached_tables(thd, &table_list, TRUE, FALSE, LONG_TIMEOUT); if ((error= ndbcluster_binlog_open_table(thd, share, table_share, table, 1))) @@ -1857,7 +1857,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, bzero((char*) &table_list,sizeof(table_list)); table_list.db= (char *)dbname; table_list.alias= table_list.table_name= (char *)tabname; - close_cached_tables(thd, &table_list, FALSE, FALSE); + close_cached_tables(thd, &table_list, FALSE, FALSE, LONG_TIMEOUT); /* ndb_share reference create free */ DBUG_PRINT("NDB_SHARE", ("%s create free use_count: %u", share->key, share->use_count)); @@ -1978,7 +1978,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, bzero((char*) &table_list,sizeof(table_list)); table_list.db= schema->db; table_list.alias= table_list.table_name= schema->name; - close_cached_tables(thd, &table_list, FALSE, FALSE); + close_cached_tables(thd, &table_list, FALSE, FALSE, LONG_TIMEOUT); } /* ndb_share reference temporary free */ if (share) @@ -2095,7 +2095,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, mysql_mutex_unlock(&ndb_schema_share_mutex); /* end protect ndb_schema_share */ - close_cached_tables(NULL, NULL, FALSE, FALSE); + close_cached_tables(NULL, NULL, FALSE, FALSE, LONG_TIMEOUT); // fall through case NDBEVENT::TE_ALTER: ndb_handle_schema_change(thd, ndb, pOp, tmp_share); @@ -2252,7 +2252,7 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd, bzero((char*) &table_list,sizeof(table_list)); table_list.db= schema->db; table_list.alias= table_list.table_name= schema->name; - close_cached_tables(thd, &table_list, FALSE, FALSE); + close_cached_tables(thd, &table_list, FALSE, FALSE, LONG_TIMEOUT); } if (schema_type != SOT_ALTER_TABLE) break; diff --git a/sql/lock.cc b/sql/lock.cc index 7c0acb58e7c..24566a04463 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -1298,27 +1298,19 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd) /** - Broadcast COND_refresh and COND_global_read_lock. + Broadcast COND_global_read_lock. - Due to a bug in a threading library it could happen that a signal - did not reach its target. A condition for this was that the same - condition variable was used with different mutexes in - mysql_cond_wait(). Some time ago we changed LOCK_open to - LOCK_global_read_lock in global read lock handling. So COND_refresh - was used with LOCK_open and LOCK_global_read_lock. - - We did now also change from COND_refresh to COND_global_read_lock - in global read lock handling. But now it is necessary to signal - both conditions at the same time. - - @note - When signalling COND_global_read_lock within the global read lock - handling, it is not necessary to also signal COND_refresh. + TODO/FIXME: Dmitry thinks that we broadcast on COND_global_read_lock + when old instance of table is closed to avoid races + between incrementing refresh_version and + wait_if_global_read_lock(thd, TRUE, FALSE) call. + Once global read lock implementation starts using MDL + infrastructure this will became unnecessary and should + be removed. */ void broadcast_refresh(void) { - mysql_cond_broadcast(&COND_refresh); mysql_cond_broadcast(&COND_global_read_lock); } diff --git a/sql/mdl.cc b/sql/mdl.cc index ca66799baed..61a43c83409 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -98,70 +98,6 @@ private: }; -enum enum_deadlock_weight -{ - MDL_DEADLOCK_WEIGHT_DML= 0, - MDL_DEADLOCK_WEIGHT_DDL= 100 -}; - - -/** - A context of the recursive traversal through all contexts - in all sessions in search for deadlock. -*/ - -class Deadlock_detection_visitor -{ -public: - Deadlock_detection_visitor(MDL_context *start_node_arg) - : m_start_node(start_node_arg), - m_victim(NULL), - m_current_search_depth(0) - {} - bool enter_node(MDL_context * /* unused */); - void leave_node(MDL_context * /* unused */); - - bool inspect_edge(MDL_context *dest); - - MDL_context *get_victim() const { return m_victim; } - - /** - Change the deadlock victim to a new one if it has lower deadlock - weight. - */ - MDL_context *opt_change_victim_to(MDL_context *new_victim); -private: - /** - The context which has initiated the search. There - can be multiple searches happening in parallel at the same time. - */ - MDL_context *m_start_node; - /** If a deadlock is found, the context that identifies the victim. */ - MDL_context *m_victim; - /** Set to the 0 at start. Increased whenever - we descend into another MDL context (aka traverse to the next - wait-for graph node). When MAX_SEARCH_DEPTH is reached, we - assume that a deadlock is found, even if we have not found a - loop. - */ - uint m_current_search_depth; - /** - Maximum depth for deadlock searches. After this depth is - achieved we will unconditionally declare that there is a - deadlock. - - @note This depth should be small enough to avoid stack - being exhausted by recursive search algorithm. - - TODO: Find out what is the optimal value for this parameter. - Current value is safe, but probably sub-optimal, - as there is an anecdotal evidence that real-life - deadlocks are even shorter typically. - */ - static const uint MAX_SEARCH_DEPTH= 32; -}; - - /** Enter a node of a wait-for graph. After a node is entered, inspect_edge() will be called @@ -876,7 +812,7 @@ void MDL_ticket::destroy(MDL_ticket *ticket) uint MDL_ticket::get_deadlock_weight() const { return (m_lock->key.mdl_namespace() == MDL_key::GLOBAL || - m_type > MDL_SHARED_NO_WRITE ? + m_type >= MDL_SHARED_NO_WRITE ? MDL_DEADLOCK_WEIGHT_DDL : MDL_DEADLOCK_WEIGHT_DML); } @@ -1528,9 +1464,8 @@ MDL_context::try_acquire_lock_impl(MDL_request *mdl_request, MDL_ticket *ticket; bool is_transactional; - DBUG_ASSERT(mdl_request->type < MDL_SHARED_NO_WRITE || - (is_lock_owner(MDL_key::GLOBAL, "", "", - MDL_INTENTION_EXCLUSIVE))); + DBUG_ASSERT(mdl_request->type != MDL_EXCLUSIVE || + is_lock_owner(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE)); DBUG_ASSERT(mdl_request->ticket == NULL); /* Don't take chances in production. */ @@ -2087,6 +2022,21 @@ end: } +/** + Traverse portion of wait-for graph which is reachable through edge + represented by this ticket in search for deadlocks. + + @retval TRUE A deadlock is found. A victim is remembered + by the visitor. + @retval FALSE +*/ + +bool MDL_ticket::find_deadlock(Deadlock_detection_visitor *dvisitor) +{ + return m_lock->find_deadlock(this, dvisitor); +} + + /** Recursively traverse the wait-for graph of MDL contexts in search for deadlocks. @@ -2105,7 +2055,7 @@ bool MDL_context::find_deadlock(Deadlock_detection_visitor *dvisitor) if (m_waiting_for) { - result= m_waiting_for->m_lock->find_deadlock(m_waiting_for, dvisitor); + result= m_waiting_for->find_deadlock(dvisitor); if (result) m_unlock_ctx= dvisitor->opt_change_victim_to(this); } diff --git a/sql/mdl.h b/sql/mdl.h index c8acd69c0f1..d7fbb14a140 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -34,7 +34,6 @@ class THD; class MDL_context; class MDL_lock; class MDL_ticket; -class Deadlock_detection_visitor; /** Type of metadata lock request. @@ -360,6 +359,96 @@ public: typedef void (*mdl_cached_object_release_hook)(void *); + +enum enum_deadlock_weight +{ + MDL_DEADLOCK_WEIGHT_DML= 0, + MDL_DEADLOCK_WEIGHT_DDL= 100 +}; + + +/** + A context of the recursive traversal through all contexts + in all sessions in search for deadlock. +*/ + +class Deadlock_detection_visitor +{ +public: + Deadlock_detection_visitor(MDL_context *start_node_arg) + : m_start_node(start_node_arg), + m_victim(NULL), + m_current_search_depth(0), + m_table_shares_visited(0) + {} + bool enter_node(MDL_context * /* unused */); + void leave_node(MDL_context * /* unused */); + + bool inspect_edge(MDL_context *dest); + + MDL_context *get_victim() const { return m_victim; } + + /** + Change the deadlock victim to a new one if it has lower deadlock + weight. + */ + MDL_context *opt_change_victim_to(MDL_context *new_victim); +private: + /** + The context which has initiated the search. There + can be multiple searches happening in parallel at the same time. + */ + MDL_context *m_start_node; + /** If a deadlock is found, the context that identifies the victim. */ + MDL_context *m_victim; + /** Set to the 0 at start. Increased whenever + we descend into another MDL context (aka traverse to the next + wait-for graph node). When MAX_SEARCH_DEPTH is reached, we + assume that a deadlock is found, even if we have not found a + loop. + */ + uint m_current_search_depth; + /** + Maximum depth for deadlock searches. After this depth is + achieved we will unconditionally declare that there is a + deadlock. + + @note This depth should be small enough to avoid stack + being exhausted by recursive search algorithm. + + TODO: Find out what is the optimal value for this parameter. + Current value is safe, but probably sub-optimal, + as there is an anecdotal evidence that real-life + deadlocks are even shorter typically. + */ + static const uint MAX_SEARCH_DEPTH= 32; + +public: + /** + Number of TABLE_SHARE objects visited by deadlock detector so far. + Used by TABLE_SHARE::find_deadlock() method to implement recursive + locking for LOCK_open mutex. + */ + uint m_table_shares_visited; +}; + + +/** + Abstract class representing edge in waiters graph to be + traversed by deadlock detection algorithm. +*/ + +class Wait_for_edge +{ +public: + virtual ~Wait_for_edge() {}; + + virtual bool find_deadlock(Deadlock_detection_visitor *dvisitor) = 0; + + virtual uint get_deadlock_weight() const = 0; +}; + + /** A granted metadata lock. @@ -380,7 +469,7 @@ typedef void (*mdl_cached_object_release_hook)(void *); threads/contexts. */ -class MDL_ticket +class MDL_ticket : public Wait_for_edge { public: /** @@ -414,6 +503,7 @@ public: bool is_incompatible_when_granted(enum_mdl_type type) const; bool is_incompatible_when_waiting(enum_mdl_type type) const; + bool find_deadlock(Deadlock_detection_visitor *dvisitor); /* A helper used to determine which lock request should be aborted. */ uint get_deadlock_weight() const; private: @@ -680,7 +770,7 @@ private: by inspecting waiting queues, but we'd very much like it to be readily available to the wait-for graph iterator. */ - MDL_ticket *m_waiting_for; + Wait_for_edge *m_waiting_for; private: MDL_ticket *find_ticket(MDL_request *mdl_req, bool *is_transactional); @@ -688,10 +778,11 @@ private: bool try_acquire_lock_impl(MDL_request *mdl_request, MDL_ticket **out_ticket); +public: void find_deadlock(); /** Inform the deadlock detector there is an edge in the wait-for graph. */ - void will_wait_for(MDL_ticket *pending_ticket) + void will_wait_for(Wait_for_edge *pending_ticket) { mysql_prlock_wrlock(&m_LOCK_waiting_for); m_waiting_for= pending_ticket; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 375c96bdec4..2b4547a299c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -634,7 +634,7 @@ mysql_mutex_t LOCK_des_key_file; mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; mysql_rwlock_t LOCK_system_variables_hash; mysql_cond_t COND_thread_count; -mysql_cond_t COND_refresh, COND_global_read_lock; +mysql_cond_t COND_global_read_lock; pthread_t signal_thread; pthread_attr_t connection_attrib; mysql_mutex_t LOCK_server_started; @@ -1573,7 +1573,6 @@ static void clean_up_mutexes() mysql_mutex_destroy(&LOCK_prepared_stmt_count); mysql_mutex_destroy(&LOCK_error_messages); mysql_cond_destroy(&COND_thread_count); - mysql_cond_destroy(&COND_refresh); mysql_cond_destroy(&COND_global_read_lock); mysql_cond_destroy(&COND_thread_cache); mysql_cond_destroy(&COND_flush_thread_cache); @@ -3564,7 +3563,6 @@ static int init_thread_environment() mysql_rwlock_init(key_rwlock_LOCK_sys_init_slave, &LOCK_sys_init_slave); mysql_rwlock_init(key_rwlock_LOCK_grant, &LOCK_grant); mysql_cond_init(key_COND_thread_count, &COND_thread_count, NULL); - mysql_cond_init(key_COND_refresh, &COND_refresh, NULL); mysql_cond_init(key_COND_global_read_lock, &COND_global_read_lock, NULL); mysql_cond_init(key_COND_thread_cache, &COND_thread_cache, NULL); mysql_cond_init(key_COND_flush_thread_cache, &COND_flush_thread_cache, NULL); @@ -7786,7 +7784,7 @@ PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool; PSI_cond_key key_BINLOG_COND_prep_xids, key_BINLOG_update_cond, key_COND_cache_status_changed, key_COND_global_read_lock, key_COND_manager, - key_COND_refresh, key_COND_rpl_status, key_COND_server_started, + key_COND_rpl_status, key_COND_server_started, key_delayed_insert_cond, key_delayed_insert_cond_client, key_item_func_sleep_cond, key_master_info_data_cond, key_master_info_start_cond, key_master_info_stop_cond, @@ -7810,7 +7808,6 @@ static PSI_cond_info all_server_conds[]= { &key_COND_cache_status_changed, "Query_cache::COND_cache_status_changed", 0}, { &key_COND_global_read_lock, "COND_global_read_lock", PSI_FLAG_GLOBAL}, { &key_COND_manager, "COND_manager", PSI_FLAG_GLOBAL}, - { &key_COND_refresh, "COND_refresh", PSI_FLAG_GLOBAL}, { &key_COND_rpl_status, "COND_rpl_status", PSI_FLAG_GLOBAL}, { &key_COND_server_started, "COND_server_started", PSI_FLAG_GLOBAL}, { &key_delayed_insert_cond, "Delayed_insert::cond", 0}, diff --git a/sql/mysqld.h b/sql/mysqld.h index b07d148f507..74d840d55cb 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -255,7 +255,7 @@ extern PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool; extern PSI_cond_key key_BINLOG_COND_prep_xids, key_BINLOG_update_cond, key_COND_cache_status_changed, key_COND_global_read_lock, key_COND_manager, - key_COND_refresh, key_COND_rpl_status, key_COND_server_started, + key_COND_rpl_status, key_COND_server_started, key_delayed_insert_cond, key_delayed_insert_cond_client, key_item_func_sleep_cond, key_master_info_data_cond, key_master_info_start_cond, key_master_info_stop_cond, @@ -339,7 +339,7 @@ extern mysql_cond_t COND_server_started; extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; extern mysql_rwlock_t LOCK_system_variables_hash; extern mysql_cond_t COND_thread_count; -extern mysql_cond_t COND_refresh, COND_manager; +extern mysql_cond_t COND_manager; extern mysql_cond_t COND_global_read_lock; extern int32 thread_running; extern my_atomic_rwlock_t thread_running_lock; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7a59fefdddd..74f03d8d3c6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -146,9 +146,6 @@ static bool check_and_update_table_version(THD *thd, TABLE_LIST *tables, static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry); static bool auto_repair_table(THD *thd, TABLE_LIST *table_list); static void free_cache_entry(TABLE *entry); -static bool tdc_wait_for_old_versions(THD *thd, - MDL_request_list *mdl_requests, - ulong timeout); static bool has_write_table_with_auto_increment(TABLE_LIST *tables); @@ -315,7 +312,7 @@ void table_def_start_shutdown(void) { mysql_mutex_lock(&LOCK_open); /* Free all cached but unused TABLEs and TABLE_SHAREs first. */ - close_cached_tables(NULL, NULL, TRUE, FALSE); + close_cached_tables(NULL, NULL, TRUE, FALSE, LONG_TIMEOUT); /* Ensure that TABLE and TABLE_SHARE objects which are created for tables that are open during process of plugins' shutdown are @@ -928,6 +925,7 @@ static void kill_delayed_threads_for_table(TABLE_SHARE *share) @param tables List of tables to remove from the cache @param have_lock If LOCK_open is locked @param wait_for_refresh Wait for a impending flush + @param timeout Timeout for waiting for flush to be completed. @note THD can be NULL, but then wait_for_refresh must be FALSE and tables must be NULL. @@ -941,10 +939,11 @@ static void kill_delayed_threads_for_table(TABLE_SHARE *share) */ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, - bool wait_for_refresh) + bool wait_for_refresh, ulong timeout) { bool result= FALSE; bool found= TRUE; + struct timespec abstime; DBUG_ENTER("close_cached_tables"); DBUG_ASSERT(thd || (!wait_for_refresh && !tables)); @@ -952,7 +951,16 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, mysql_mutex_lock(&LOCK_open); if (!tables) { - refresh_version++; // Force close of open tables + /* + Force close of all open tables. + + Note that code in TABLE_SHARE::wait_until_flushed() assumes that + incrementing of refresh_version and removal of unused tables and + shares from TDC happens atomically under protection of LOCK_open, + or putting it another way that TDC does not contain old shares + which don't have any tables used. + */ + refresh_version++; DBUG_PRINT("tcache", ("incremented global refresh_version to: %lu", refresh_version)); kill_delayed_threads(); @@ -995,6 +1003,8 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, /* Code below assume that LOCK_open is released. */ DBUG_ASSERT(!have_lock); + set_timespec(abstime, timeout); + if (thd->locked_tables_mode) { /* @@ -1034,6 +1044,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, while (found && ! thd->killed) { + TABLE_SHARE *share; found= FALSE; /* To a self-deadlock or deadlocks with other FLUSH threads @@ -1044,13 +1055,11 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, mysql_mutex_lock(&LOCK_open); - thd->enter_cond(&COND_refresh, &LOCK_open, "Flushing tables"); - if (!tables) { for (uint idx=0 ; idx < table_def_cache.records ; idx++) { - TABLE_SHARE *share=(TABLE_SHARE*) my_hash_element(&table_def_cache, + share= (TABLE_SHARE*) my_hash_element(&table_def_cache, idx); if (share->needs_reopen()) { @@ -1063,7 +1072,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, { for (TABLE_LIST *table= tables; table; table= table->next_local) { - TABLE_SHARE *share= get_cached_table_share(table->db, table->table_name); + share= get_cached_table_share(table->db, table->table_name); if (share && share->needs_reopen()) { found= TRUE; @@ -1074,11 +1083,17 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, if (found) { - DBUG_PRINT("signal", ("Waiting for COND_refresh")); - mysql_cond_wait(&COND_refresh, &LOCK_open); + /* The below method will unlock LOCK_open and frees share's memory. */ + if (share->wait_until_flushed(&thd->mdl_context, &abstime, + MDL_DEADLOCK_WEIGHT_DDL)) + { + mysql_mutex_unlock(&LOCK_open); + result= TRUE; + goto err_with_reopen; + } } - thd->exit_cond(NULL); + mysql_mutex_unlock(&LOCK_open); } err_with_reopen: @@ -1149,7 +1164,7 @@ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh, } if (tables) - result= close_cached_tables(thd, tables, TRUE, FALSE); + result= close_cached_tables(thd, tables, TRUE, FALSE, LONG_TIMEOUT); if (!have_lock) mysql_mutex_unlock(&LOCK_open); @@ -2347,7 +2362,7 @@ bool MDL_deadlock_handler::handle_condition(THD *, { /* Disable the handler to avoid infinite recursion. */ m_is_active= TRUE; - (void) m_ot_ctx->request_backoff_action(Open_table_context::OT_MDL_CONFLICT, + (void) m_ot_ctx->request_backoff_action(Open_table_context::OT_CONFLICT, NULL); m_is_active= FALSE; /* @@ -2394,6 +2409,8 @@ open_table_get_mdl_lock(THD *thd, Open_table_context *ot_ctx, uint flags, MDL_ticket **mdl_ticket) { + MDL_request mdl_request_shared; + if (flags & (MYSQL_OPEN_FORCE_SHARED_MDL | MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL)) { @@ -2419,16 +2436,12 @@ open_table_get_mdl_lock(THD *thd, Open_table_context *ot_ctx, DBUG_ASSERT(!(flags & MYSQL_OPEN_FORCE_SHARED_MDL) || !(flags & MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL)); - mdl_request= new (thd->mem_root) MDL_request(mdl_request); - if (mdl_request == NULL) - return TRUE; - - mdl_request->set_type((flags & MYSQL_OPEN_FORCE_SHARED_MDL) ? - MDL_SHARED : MDL_SHARED_HIGH_PRIO); + mdl_request_shared.init(&mdl_request->key, + (flags & MYSQL_OPEN_FORCE_SHARED_MDL) ? + MDL_SHARED : MDL_SHARED_HIGH_PRIO); + mdl_request= &mdl_request_shared; } - ot_ctx->add_request(mdl_request); - if (flags & MYSQL_OPEN_FAIL_ON_MDL_CONFLICT) { /* @@ -2491,6 +2504,38 @@ open_table_get_mdl_lock(THD *thd, Open_table_context *ot_ctx, } +/** + Check if table's share requires flush and if yes wait until it + will be flushed. + + @param thd Thread context. + @param table_list Table which share should be checked. + @param timeout Timeout for waiting. + @param deadlock_weight Weight of this wait for deadlock detector. + + @retval FALSE - Success. Share is up to date or has been flushed. + @retval TRUE - Error (OOM, thread was killed, wait resulted in + deadlock or timeout). +*/ + +static bool tdc_wait_for_old_version(THD *thd, TABLE_LIST *table_list, + ulong timeout, uint deadlock_weight) +{ + TABLE_SHARE *share; + + if ((share= get_cached_table_share(table_list->db, + table_list->table_name)) && + share->needs_reopen()) + { + struct timespec abstime; + set_timespec(abstime, timeout); + return share->wait_until_flushed(&thd->mdl_context, &abstime, + deadlock_weight); + } + return FALSE; +} + + /* Open a table. @@ -2580,8 +2625,8 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, if (thd->open_tables && thd->open_tables->s->version != refresh_version) { - (void) ot_ctx->request_backoff_action(Open_table_context::OT_WAIT_TDC, - NULL); + (void)ot_ctx->request_backoff_action(Open_table_context::OT_REOPEN_TABLES, + NULL); DBUG_RETURN(TRUE); } } @@ -2794,6 +2839,8 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, mysql_mutex_lock(&LOCK_open); +retry_share: + if (!(share= get_table_share_with_create(thd, table_list, key, key_length, OPEN_VIEW, &error, @@ -2849,31 +2896,50 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, if (table_list->i_s_requested_object & OPEN_VIEW_ONLY) goto err_unlock; - /* - If the version changes while we're opening the tables, - we have to back off, close all the tables opened-so-far, - and try to reopen them. Note: refresh_version is currently - changed only during FLUSH TABLES. - */ - if (share->needs_reopen() || - (thd->open_tables && thd->open_tables->s->version != share->version)) + if (!(flags & MYSQL_OPEN_IGNORE_FLUSH)) { - if (!(flags & MYSQL_OPEN_IGNORE_FLUSH)) + if (share->needs_reopen()) { - /* - We already have an MDL lock. But we have encountered an old - version of table in the table definition cache which is possible - when someone changes the table version directly in the cache - without acquiring a metadata lock (e.g. this can happen during - "rolling" FLUSH TABLE(S)). - Note, that to avoid a "busywait" in this case, we have to wait - separately in the caller for old table versions to go away - (see tdc_wait_for_old_versions()). - */ + /* + We already have an MDL lock. But we have encountered an old + version of table in the table definition cache which is possible + when someone changes the table version directly in the cache + without acquiring a metadata lock (e.g. this can happen during + "rolling" FLUSH TABLE(S)). + Release our reference to share, wait until old version of + share goes away and then try to get new version of table share. + */ + MDL_deadlock_handler mdl_deadlock_handler(ot_ctx); + bool wait_result; + + release_table_share(share); + + thd->push_internal_handler(&mdl_deadlock_handler); + wait_result= tdc_wait_for_old_version(thd, table_list, + ot_ctx->get_timeout(), + mdl_ticket->get_deadlock_weight()); + thd->pop_internal_handler(); + + if (wait_result) + { + mysql_mutex_unlock(&LOCK_open); + DBUG_RETURN(TRUE); + } + goto retry_share; + } + + if (thd->open_tables && thd->open_tables->s->version != share->version) + { + /* + If the version changes while we're opening the tables, + we have to back off, close all the tables opened-so-far, + and try to reopen them. Note: refresh_version is currently + changed only during FLUSH TABLES. + */ release_table_share(share); mysql_mutex_unlock(&LOCK_open); - (void) ot_ctx->request_backoff_action(Open_table_context::OT_WAIT_TDC, - NULL); + (void)ot_ctx->request_backoff_action(Open_table_context::OT_REOPEN_TABLES, + NULL); DBUG_RETURN(TRUE); } } @@ -3831,7 +3897,7 @@ request_backoff_action(enum_open_table_action action_arg, Since there is no way to detect such a deadlock, we prevent it by reporting an error. */ - if (m_has_locks) + if (action_arg != OT_REOPEN_TABLES && m_has_locks) { my_error(ER_LOCK_DEADLOCK, MYF(0)); return TRUE; @@ -3877,11 +3943,9 @@ recover_from_failed_open(THD *thd) /* Execute the action. */ switch (m_action) { - case OT_MDL_CONFLICT: + case OT_CONFLICT: break; - case OT_WAIT_TDC: - result= tdc_wait_for_old_versions(thd, &m_mdl_requests, get_timeout()); - DBUG_ASSERT(thd->mysys_var->current_mutex == NULL); + case OT_REOPEN_TABLES: break; case OT_DISCOVER: { @@ -3921,8 +3985,6 @@ recover_from_failed_open(THD *thd) default: DBUG_ASSERT(0); } - /* Remove all old requests, they will be re-added. */ - m_mdl_requests.empty(); /* Reset the pointers to conflicting MDL request and the TABLE_LIST element, set when we need auto-discovery or repair, @@ -4043,8 +4105,6 @@ open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx, if (rt != (Sroutine_hash_entry*)prelocking_ctx->sroutines_list.first || mdl_type != MDL_key::PROCEDURE) { - ot_ctx->add_request(&rt->mdl_request); - /* Since we acquire only shared lock on routines we don't need to care about global intention exclusive locks. @@ -4721,6 +4781,8 @@ restart: } goto err; } + + DEBUG_SYNC(thd, "open_tables_after_open_and_process_table"); } /* @@ -8595,17 +8657,6 @@ bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use, } mysql_mutex_unlock(&in_use->LOCK_thd_data); } - /* - Wake up threads waiting in tdc_wait_for_old_versions(). - Normally such threads would already get blocked - in MDL subsystem, when trying to acquire a shared lock. - But in case a thread has an open HANDLER statement, - (and thus already grabbed a metadata lock), it gets - blocked only too late -- at the table cache level. - Starting from 5.5, this could also easily happen in - a multi-statement transaction. - */ - broadcast_refresh(); return signalled; } @@ -8680,6 +8731,13 @@ void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, /* Set share's version to zero in order to ensure that it gets automatically deleted once it is no longer referenced. + + Note that code in TABLE_SHARE::wait_until_flushed() assumes + that marking share as old and removal of its unused tables + and of the share itself from TDC happens atomically under + protection of LOCK_open, or, putting it another way, that + TDC does not contain old shares which don't have any tables + used. */ share->version= 0; @@ -8692,84 +8750,6 @@ void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, } -/** - Wait until there are no old versions of tables in the table - definition cache for the metadata locks that we try to acquire. - - @param thd Thread context - @param context Metadata locking context with locks. - @param timeout Seconds to wait before reporting ER_LOCK_WAIT_TIMEOUT. -*/ - -static bool -tdc_wait_for_old_versions(THD *thd, MDL_request_list *mdl_requests, - ulong timeout) -{ - TABLE_SHARE *share; - const char *old_msg; - MDL_request *mdl_request; - struct timespec abstime; - set_timespec(abstime, timeout); - int wait_result= 0; - - while (!thd->killed) - { - /* - We have to get rid of HANDLERs which are open by this thread - and have old TABLE versions. Otherwise we might get a deadlock - in situation when we are waiting for an old TABLE object which - corresponds to a HANDLER open by another session. And this - other session waits for our HANDLER object to get closed. - - TODO: We should also investigate in which situations we have - to broadcast on COND_refresh because of this. - */ - mysql_ha_flush(thd); - - mysql_mutex_lock(&LOCK_open); - - MDL_request_list::Iterator it(*mdl_requests); - while ((mdl_request= it++)) - { - /* Skip requests on non-TDC objects. */ - if (mdl_request->key.mdl_namespace() != MDL_key::TABLE) - continue; - - if ((share= get_cached_table_share(mdl_request->key.db_name(), - mdl_request->key.name())) && - share->needs_reopen()) - break; - } - if (!mdl_request) - { - /* - Reset wait_result here in case this was the final check - after getting a timeout from mysql_cond_timedwait(). - */ - wait_result= 0; - mysql_mutex_unlock(&LOCK_open); - break; - } - if (wait_result == ETIMEDOUT || wait_result == ETIME) - { - /* - Test for timeout here instead of right after mysql_cond_timedwait(). - This allows for a final iteration and a final check before reporting - ER_LOCK_WAIT_TIMEOUT. - */ - mysql_mutex_unlock(&LOCK_open); - my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0)); - break; - } - old_msg= thd->enter_cond(&COND_refresh, &LOCK_open, "Waiting for table"); - wait_result= mysql_cond_timedwait(&COND_refresh, &LOCK_open, &abstime); - /* LOCK_open mutex is unlocked by THD::exit_cond() as side-effect. */ - thd->exit_cond(old_msg); - } - return thd->killed || wait_result == ETIMEDOUT || wait_result == ETIME; -} - - int setup_ftfuncs(SELECT_LEX *select_lex) { List_iterator li(*(select_lex->ftfunc_list)), diff --git a/sql/sql_base.h b/sql/sql_base.h index b912f80d44f..7d13b69e063 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -250,7 +250,7 @@ TABLE *open_performance_schema_table(THD *thd, TABLE_LIST *one_table, void close_performance_schema_table(THD *thd, Open_tables_state *backup); bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, - bool wait_for_refresh); + bool wait_for_refresh, ulong timeout); bool close_cached_connection_tables(THD *thd, bool wait_for_refresh, LEX_STRING *connect_string, bool have_lock = FALSE); @@ -454,8 +454,8 @@ public: enum enum_open_table_action { OT_NO_ACTION= 0, - OT_MDL_CONFLICT, - OT_WAIT_TDC, + OT_CONFLICT, + OT_REOPEN_TABLES, OT_DISCOVER, OT_REPAIR }; @@ -465,9 +465,6 @@ public: bool request_backoff_action(enum_open_table_action action_arg, TABLE_LIST *table); - void add_request(MDL_request *request) - { m_mdl_requests.push_front(request); } - bool can_recover_from_failed_open() const { return m_action != OT_NO_ACTION; } @@ -489,8 +486,6 @@ public: uint get_flags() const { return m_flags; } private: - /** List of requests for all locks taken so far. Used for waiting on locks. */ - MDL_request_list m_mdl_requests; /** For OT_DISCOVER and OT_REPAIR actions, the table list element for the table which definition should be re-discovered or which diff --git a/sql/sql_class.h b/sql/sql_class.h index c095fee6232..e96c3f8dd26 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2302,6 +2302,12 @@ public: { const char* old_msg = proc_info; mysql_mutex_assert_owner(mutex); + /* + This method should not be called with LOCK_open mutex as an + argument. Otherwise deadlocks can arise in MDL deadlock detector. + @sa TABLE_SHARE::find_deadlock(). + */ + DBUG_ASSERT(mutex != &LOCK_open); mysys_var->current_mutex = mutex; mysys_var->current_cond = cond; proc_info = msg; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 53c2ca6fa39..7cb27ff4916 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1756,6 +1756,7 @@ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) { Lock_tables_prelocking_strategy lock_tables_prelocking_strategy; TABLE_LIST *table_list; + MDL_request_list mdl_requests; /* This is called from SQLCOM_FLUSH, the transaction has @@ -1774,23 +1775,27 @@ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) } /* - @todo: Since lock_table_names() acquires a global IX - lock, this actually waits for a GRL in another connection. - We are thus introducing an incompatibility. - Do nothing for now, since not taking a global IX violates - current internal MDL asserts, fix after discussing with - Dmitry. + Acquire SNW locks on tables to be flushed. We can't use + lock_table_names() here as this call will also acquire global IX + and database-scope IX locks on the tables, and this will make + this statement incompatible with FLUSH TABLES WITH READ LOCK. */ - if (lock_table_names(thd, all_tables, 0, thd->variables.lock_wait_timeout, - MYSQL_OPEN_SKIP_TEMPORARY)) + for (table_list= all_tables; table_list; + table_list= table_list->next_global) + mdl_requests.push_front(&table_list->mdl_request); + + if (thd->mdl_context.acquire_locks(&mdl_requests, + thd->variables.lock_wait_timeout)) goto error; + DEBUG_SYNC(thd,"flush_tables_with_read_lock_after_acquire_locks"); + for (table_list= all_tables; table_list; table_list= table_list->next_global) { - /* Remove the table from cache. */ + /* Request removal of table from cache. */ mysql_mutex_lock(&LOCK_open); - tdc_remove_table(thd, TDC_RT_REMOVE_ALL, + tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, table_list->db, table_list->table_name); mysql_mutex_unlock(&LOCK_open); @@ -1800,6 +1805,11 @@ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) table_list->open_type= OT_BASE_ONLY; /* Ignore temporary tables. */ } + /* + Before opening and locking tables the below call also waits for old + shares to go away, so the fact that we don't pass MYSQL_LOCK_IGNORE_FLUSH + flag to it is important. + */ if (open_and_lock_tables(thd, all_tables, FALSE, MYSQL_OPEN_HAS_MDL_LOCK, &lock_tables_prelocking_strategy) || @@ -1810,17 +1820,11 @@ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) thd->variables.option_bits|= OPTION_TABLE_LOCK; /* - Downgrade the exclusive locks. - Use MDL_SHARED_NO_WRITE as the intended - post effect of this call is identical - to LOCK TABLES <...> READ, and we didn't use - thd->in_lock_talbes and thd->sql_command= SQLCOM_LOCK_TABLES - hacks to enter the LTM. - @todo: release the global IX lock here!!! + We don't downgrade MDL_SHARED_NO_WRITE here as the intended + post effect of this call is identical to LOCK TABLES <...> READ, + and we didn't use thd->in_lock_talbes and + thd->sql_command= SQLCOM_LOCK_TABLES hacks to enter the LTM. */ - for (table_list= all_tables; table_list; - table_list= table_list->next_global) - table_list->mdl_request.ticket->downgrade_exclusive_lock(MDL_SHARED_NO_WRITE); return FALSE; @@ -6854,8 +6858,8 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, tmp_write_to_binlog= 0; if (thd->global_read_lock.lock_global_read_lock(thd)) return 1; // Killed - if (close_cached_tables(thd, tables, FALSE, (options & REFRESH_FAST) ? - FALSE : TRUE)) + if (close_cached_tables(thd, tables, FALSE, ((options & REFRESH_FAST) ? + FALSE : TRUE), thd->variables.lock_wait_timeout)) result= 1; if (thd->global_read_lock.make_global_read_lock_block_commit(thd)) // Killed @@ -6894,8 +6898,10 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, } } - if (close_cached_tables(thd, tables, FALSE, (options & REFRESH_FAST) ? - FALSE : TRUE)) + if (close_cached_tables(thd, tables, FALSE, ((options & REFRESH_FAST) ? + FALSE : TRUE), + (thd ? thd->variables.lock_wait_timeout : + LONG_TIMEOUT))) result= 1; } my_dbopt_cleanup(); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ca951897055..3341ffc7a30 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -11202,9 +11202,8 @@ opt_with_read_lock: { TABLE_LIST *tables= Lex->query_tables; Lex->type|= REFRESH_READ_LOCK; - /* We acquire an X lock currently and then downgrade. */ for (; tables; tables= tables->next_global) - tables->mdl_request.set_type(MDL_EXCLUSIVE); + tables->mdl_request.set_type(MDL_SHARED_NO_WRITE); } ; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 9e212fb95e9..cf185db0b7a 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1488,7 +1488,8 @@ static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type) can cause to wait on a read lock, it's required for the client application to unlock everything, and acceptable for the server to wait on all locks. */ - if ((result= close_cached_tables(thd, NULL, FALSE, TRUE))) + if ((result= close_cached_tables(thd, NULL, FALSE, TRUE, + thd->variables.lock_wait_timeout))) goto end_with_read_lock; if ((result= thd->global_read_lock.make_global_read_lock_block_commit(thd))) diff --git a/sql/table.cc b/sql/table.cc index a58623f0036..a8e1caa271a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -34,6 +34,7 @@ #include #include "my_md5.h" #include "sql_select.h" +#include "mdl.h" // Deadlock_detection_visitor /* INFORMATION_SCHEMA name */ LEX_STRING INFORMATION_SCHEMA_NAME= {C_STRING_WITH_LEN("information_schema")}; @@ -325,6 +326,7 @@ TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key, share->used_tables.empty(); share->free_tables.empty(); + share->m_flush_tickets.empty(); memcpy((char*) &share->mem_root, (char*) &mem_root, sizeof(mem_root)); mysql_mutex_init(key_TABLE_SHARE_LOCK_ha_data, @@ -389,6 +391,7 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key, share->used_tables.empty(); share->free_tables.empty(); + share->m_flush_tickets.empty(); DBUG_VOID_RETURN; } @@ -432,9 +435,40 @@ void free_table_share(TABLE_SHARE *share) key_info->flags= 0; } } - /* We must copy mem_root from share because share is allocated through it */ - memcpy((char*) &mem_root, (char*) &share->mem_root, sizeof(mem_root)); - free_root(&mem_root, MYF(0)); // Free's share + + if (share->m_flush_tickets.is_empty()) + { + /* + There are no threads waiting for this share to be flushed. So + we can immediately release memory associated with it. We must + copy mem_root from share because share is allocated through it. + */ + memcpy((char*) &mem_root, (char*) &share->mem_root, sizeof(mem_root)); + free_root(&mem_root, MYF(0)); // Free's share + } + else + { + /* + If there are threads waiting for this share to be flushed we + don't free share memory here. Instead we notify waiting threads + and delegate freeing share's memory to them. + At this point a) all resources except memory associated with share + were already released b) share should have been already removed + from table definition cache. So it is OK to proceed without waiting + for these threads to finish their work. + */ + Flush_ticket_list::Iterator it(share->m_flush_tickets); + Flush_ticket *ticket; + + /* + To avoid problems due to threads being wake up concurrently modifying + flush ticket list we must hold LOCK_open here. + */ + mysql_mutex_assert_owner(&LOCK_open); + + while ((ticket= it++)) + (void) ticket->get_ctx()->m_wait.set_status(MDL_wait::GRANTED); + } DBUG_VOID_RETURN; } @@ -2996,6 +3030,223 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def) } +/** + Traverse portion of wait-for graph which is reachable through edge + represented by this flush ticket in search for deadlocks. + + @retval TRUE A deadlock is found. A victim is remembered + by the visitor. + @retval FALSE +*/ + +bool Flush_ticket::find_deadlock(Deadlock_detection_visitor *dvisitor) +{ + return m_share->find_deadlock(this, dvisitor); +} + + +uint Flush_ticket::get_deadlock_weight() const +{ + return m_deadlock_weight; +} + + +/** + Traverse portion of wait-for graph which is reachable through this + table share in search for deadlocks. + + @param waiting_ticket Ticket representing wait for this share. + @param dvisitor Deadlock detection visitor. + + @retval TRUE A deadlock is found. A victim is remembered + by the visitor. + @retval FALSE +*/ + +bool TABLE_SHARE::find_deadlock(Flush_ticket *waiting_ticket, + Deadlock_detection_visitor *dvisitor) +{ + TABLE *table; + MDL_context *src_ctx= waiting_ticket->get_ctx(); + bool result= TRUE; + + /* + To protect used_tables list from being concurrently modified while we + are iterating through it we acquire LOCK_open. This should not introduce + deadlocks in deadlock detector because we support recursive acquiring of + such mutex and also because we won't try to acquire LOCK_open mutex while + holding write-lock on MDL_lock::m_rwlock. + + Here is the more elaborate proof: + + 0) Let us assume that there is a deadlock. + 1) Wait graph (the one which reflects waits for system synchronization + primitives and not the one which inspected by MDL deadlock detector) + for this deadlock should contain loop including both LOCK_open and + some of MDL synchronization primitives. Otherwise deadlock would had + already exisited before we have introduced acquiring of LOCK_open in + MDL deadlock detector. + 2) Also in this graph edge going out of LOCK_open node should go to one + of MDL synchronization primitives. Different situation would mean that + we have some non-MDL synchronization primitive besides LOCK_open under + which we try to acquire MDL lock, which is not the case. + 3) Moreover edge coming from LOCK_open should go to MDL_lock::m_rwlock + object and correspond to request for read-lock. It can't be request + for rwlock in MDL_context or mutex in MDL_wait object because they + are terminal (i.e. thread having them locked in exclusive mode won't + wait for any other resource). It can't be request for write-lock on + MDL_lock::m_rwlock as this would mean that we try to acquire metadata + lock under LOCK_open (which is not the case). + 4) Since MDL_lock::m_rwlock is rwlock which prefers readers the only + situation when it can be waited for is when some thread has it + write-locked. + 5) TODO/FIXME: + - Either prove that thread having MDL_lock::m_rwlock write-locked won't + wait for LOCK_open directly or indirectly (see notify_shared_lock()). + - Or change code to hold only read-lock on MDL_lock::m_rwlock during + notify_shared_lock() and thus make MDL_lock::m_rwlock terminal when + write-locked. + */ + if (! (dvisitor->m_table_shares_visited++)) + mysql_mutex_lock(&LOCK_open); + + I_P_List_iterator tables_it(used_tables); + + /* Not strictly necessary ? */ + if (src_ctx->m_wait.get_status() != MDL_wait::EMPTY) + { + result= FALSE; + goto end; + } + + if (dvisitor->enter_node(src_ctx)) + goto end; + + while ((table= tables_it++)) + { + if (dvisitor->inspect_edge(&table->in_use->mdl_context)) + { + goto end_leave_node; + } + } + + tables_it.rewind(); + while ((table= tables_it++)) + { + if (table->in_use->mdl_context.find_deadlock(dvisitor)) + { + goto end_leave_node; + } + } + + result= FALSE; + +end_leave_node: + dvisitor->leave_node(src_ctx); + +end: + if (! (--dvisitor->m_table_shares_visited)) + mysql_mutex_unlock(&LOCK_open); + + return result; +} + + +/** + Wait until old version of table share is removed from TDC. + + @param mdl_context MDL context for thread which is going to wait. + @param abstime Timeout for waiting as absolute time value. + @param deadlock_weight Weight of this wait for deadlock detector. + + @note This method assumes that its caller owns LOCK_open mutex. + This mutex will be unlocked temporarily during its execution. + + @retval FALSE - Success. + @retval TRUE - Error (OOM, deadlock, timeout, etc...). +*/ + +bool TABLE_SHARE::wait_until_flushed(MDL_context *mdl_context, + struct timespec *abstime, + uint deadlock_weight) +{ + Flush_ticket *ticket; + MDL_wait::enum_wait_status wait_status; + + mysql_mutex_assert_owner(&LOCK_open); + + /* + We should enter this method only then share's version is not + up to date and the share is referenced. Otherwise there is + no guarantee that our thread will be waken-up from wait. + */ + DBUG_ASSERT(version != refresh_version && ref_count != 0); + + if (! (ticket= new Flush_ticket(mdl_context, this, deadlock_weight))) + { + mysql_mutex_unlock(&LOCK_open); + return TRUE; + } + + m_flush_tickets.push_front(ticket); + + mdl_context->m_wait.reset_status(); + + mysql_mutex_unlock(&LOCK_open); + + mdl_context->will_wait_for(ticket); + + mdl_context->find_deadlock(); + + wait_status= mdl_context->m_wait.timed_wait(mdl_context->get_thd(), + abstime, TRUE); + + mdl_context->done_waiting_for(); + + mysql_mutex_lock(&LOCK_open); + + m_flush_tickets.remove(ticket); + + /* + If our thread was the last one waiting for table share to be flushed + we can finish destruction of share object by releasing its memory + (share object was allocated on share's own MEM_ROOT). + + In cases when our wait was aborted due KILL statement, deadlock or + timeout share still might be referenced, so we don't free its memory + in this case. Note that we can't rely on checking wait_status to + determine this condition as, for example, timeout can happen even + when there are no references to table share so memory should be + released. + */ + if (m_flush_tickets.is_empty() && ! ref_count) + { + MEM_ROOT mem_root_copy; + memcpy((char*) &mem_root_copy, (char*) &mem_root, sizeof(mem_root)); + free_root(&mem_root_copy, MYF(0)); + } + + delete ticket; + + switch (wait_status) + { + case MDL_wait::GRANTED: + return FALSE; + case MDL_wait::VICTIM: + my_error(ER_LOCK_DEADLOCK, MYF(0)); + return TRUE; + case MDL_wait::TIMEOUT: + my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0)); + return TRUE; + case MDL_wait::KILLED: + return TRUE; + default: + DBUG_ASSERT(0); + return TRUE; + } +} + + /* Create Item_field for each column in the table. diff --git a/sql/table.h b/sql/table.h index 2bf390aee4d..46015f4425a 100644 --- a/sql/table.h +++ b/sql/table.h @@ -45,6 +45,7 @@ class ACL_internal_schema_access; class ACL_internal_table_access; struct TABLE_LIST; class Field; +class Deadlock_detection_visitor; /* Used to identify NESTED_JOIN structures within a join (applicable only to @@ -508,6 +509,45 @@ public: }; +/** + Class representing the fact that some thread waits for table + share to be flushed. Is used to represent information about + such waits in MDL deadlock detector. +*/ + +class Flush_ticket : public Wait_for_edge +{ + MDL_context *m_ctx; + TABLE_SHARE *m_share; + uint m_deadlock_weight; +public: + Flush_ticket(MDL_context *ctx_arg, TABLE_SHARE *share_arg, + uint deadlock_weight_arg) + : m_ctx(ctx_arg), m_share(share_arg), + m_deadlock_weight(deadlock_weight_arg) + {} + + MDL_context *get_ctx() const { return m_ctx; } + + bool find_deadlock(Deadlock_detection_visitor *dvisitor); + + uint get_deadlock_weight() const; + + /** + Pointers for participating in the list of waiters for table share. + */ + Flush_ticket *next_in_share; + Flush_ticket **prev_in_share; +}; + + +typedef I_P_List > + Flush_ticket_list; + + /* This structure is shared between different table objects. There is one instance of table share per one table in the database. @@ -662,6 +702,11 @@ struct TABLE_SHARE /** Instrumentation for this table share. */ PSI_table_share *m_psi; + /** + List of tickets representing threads waiting for the share to be flushed. + */ + Flush_ticket_list m_flush_tickets; + /* Set share's table cache key and update its db and table name appropriately. @@ -837,6 +882,12 @@ struct TABLE_SHARE return (tmp_table == SYSTEM_TMP_TABLE || is_view) ? 0 : table_map_id; } + bool find_deadlock(Flush_ticket *waiting_ticket, + Deadlock_detection_visitor *dvisitor); + + bool wait_until_flushed(MDL_context *mdl_context, + struct timespec *abstime, + uint deadlock_weight); }; From ccf6ec093e14e6a5eb0fc15c9f365bae9d1a57f6 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Wed, 28 Jul 2010 12:59:19 -0300 Subject: [PATCH 006/136] Bug#53463: YaSSL patch appears to be reverted The problem is that the fix Bug#29784 was mistakenly reverted when updating YaSSL to a newer version. The solution is to re-apply the fix and this time actually add a meaningful test case so that possible regressions are caught. --- extra/yassl/taocrypt/src/coding.cpp | 2 +- mysql-test/std_data/server8k-cert.pem | 172 +++++++---------------- mysql-test/std_data/server8k-key.pem | 194 +++++++++++++------------- mysql-test/t/ssl_8k_key-master.opt | 1 + 4 files changed, 148 insertions(+), 221 deletions(-) create mode 100644 mysql-test/t/ssl_8k_key-master.opt diff --git a/extra/yassl/taocrypt/src/coding.cpp b/extra/yassl/taocrypt/src/coding.cpp index 7a9d50aaac9..7fc681e1a05 100644 --- a/extra/yassl/taocrypt/src/coding.cpp +++ b/extra/yassl/taocrypt/src/coding.cpp @@ -185,7 +185,7 @@ void Base64Decoder::Decode() { word32 bytes = coded_.size(); word32 plainSz = bytes - ((bytes + (pemLineSz - 1)) / pemLineSz); - plainSz = (plainSz * 3 + 3) / 4; + plainSz = ((plainSz * 3) / 4) + 3; decoded_.New(plainSz); word32 i = 0; diff --git a/mysql-test/std_data/server8k-cert.pem b/mysql-test/std_data/server8k-cert.pem index 06e118cf034..e71ba5722b9 100644 --- a/mysql-test/std_data/server8k-cert.pem +++ b/mysql-test/std_data/server8k-cert.pem @@ -1,125 +1,51 @@ -Certificate: - Data: - Version: 1 (0x0) - Serial Number: 1048579 (0x100003) - Signature Algorithm: md5WithRSAEncryption - Issuer: C=SE, ST=Uppsala, L=Uppsala, O=MySQL AB - Validity - Not Before: Jan 29 12:01:53 2010 GMT - Not After : Jan 28 12:01:53 2015 GMT - Subject: C=SE, ST=Uppsala, O=MySQL AB, CN=server - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (8192 bit) - Modulus: - 00:ca:aa:1d:c4:11:ec:91:f0:c7:ff:5f:90:92:fc: - 40:0c:5e:b7:3d:00:c5:20:d5:0f:89:31:07:d7:41: - 4c:8b:60:80:aa:38:14:de:93:6b:9c:74:88:41:68: - b5:02:41:01:2d:86:a2:7a:95:53:5e:7b:67:2f:6c: - 1e:29:51:f9:44:fd:4a:80:be:b2:23:a1:3e:1b:38: - cf:88:c4:71:ee:f8:6b:41:c5:2d:c0:c3:52:ac:59: - 7d:81:34:19:95:32:b8:9a:51:b6:41:36:d4:c4:a1: - ae:84:e6:38:b9:e8:bf:96:be:19:7a:6b:77:4d:e0: - de:e6:b3:b6:6b:bc:3d:dd:68:bc:4b:c4:eb:f5:36: - 93:ed:56:a2:15:50:8a:10:e8:d6:22:ed:6c:b1:cd: - c3:18:c9:f6:0a:e1:de:61:65:62:d6:14:41:8c:b5: - fb:14:68:c1:cf:12:5d:41:21:9d:57:11:43:7d:bb: - 43:2c:21:bb:c3:44:7d:a8:cf:1f:c3:71:75:b5:47: - c2:7d:ce:38:3c:73:64:9e:15:d8:a7:27:cf:bd:40: - c8:45:08:e3:c8:39:a8:0b:8e:c2:5b:7b:f1:47:91: - 12:91:cc:e1:00:e0:94:5b:bd:32:e4:0c:8d:c3:be: - cc:76:32:52:12:69:b0:18:e0:b0:c2:76:34:5a:5f: - 79:d9:f6:81:9d:02:0a:61:69:1c:33:ce:49:fa:76: - 03:1e:07:5b:27:0b:bf:34:9e:34:96:b8:03:9b:50: - 3a:6a:2f:17:7a:14:cf:65:63:00:37:52:a8:73:ce: - 4b:14:40:f4:d2:9a:56:54:33:b8:77:2e:42:5b:8f: - ec:1f:18:f4:ad:ab:8a:4a:8d:6d:70:25:f3:58:e7: - cb:66:51:14:7d:16:f4:eb:6d:56:76:76:51:6e:d6: - 1d:da:d3:8d:c0:64:5a:67:4e:af:e2:bf:33:d1:b8: - f6:2a:fc:57:87:a7:35:5e:80:c9:ac:fc:87:c9:71: - 17:91:bf:b7:4d:a3:ed:3c:1b:27:f4:66:a0:f9:46: - 03:27:cc:ea:80:f6:4b:40:f6:41:94:cd:bd:0a:b3: - ef:26:be:de:6f:69:ae:0f:3f:1c:55:63:33:90:9b: - ed:ca:5a:12:4d:de:4b:06:c2:a2:92:b0:42:3d:31: - af:a4:15:12:15:f8:8a:e9:88:8d:cf:fd:85:66:50: - 6f:11:f1:9f:48:f3:b5:ba:9d:86:68:24:a2:5d:a8: - 7c:54:42:fa:d8:b5:c5:f2:dd:0e:0f:d0:68:e4:54: - 7e:c5:b9:a0:9b:65:2d:77:f4:8f:b9:30:0a:d5:86: - 5c:ed:c9:7c:d1:da:9d:0d:63:50:ee:e5:1e:92:63: - cc:a2:0c:e8:4a:96:02:4d:dc:8f:df:7c:8f:08:18: - a8:30:88:d7:af:89:ad:fc:57:4b:10:f9:f1:cb:48: - e8:b6:3b:c8:3f:fc:c2:d3:d1:4a:10:3c:1b:6b:64: - dc:e5:65:1e:5b:b2:da:b1:e2:24:97:8f:ee:c0:4b: - 8e:18:83:7c:17:a6:3c:45:b3:60:06:23:f2:2f:18: - 13:9e:17:8a:c6:72:79:8c:4d:04:f3:9d:ea:e0:25: - d3:33:8c:1e:11:47:63:1f:a5:45:3f:bd:85:b3:fe: - a5:68:ee:48:b7:0c:a4:c9:7f:72:d0:75:66:9b:6a: - f9:a0:50:f3:a8:59:6d:a3:dd:38:4f:70:2b:bb:ff: - 92:2e:71:ab:ef:e9:00:ed:0d:d1:b4:6f:f0:8e:b2: - 09:fb:4d:61:0d:d9:10:d5:54:11:cd:03:94:84:fd: - a8:68:e4:45:6e:1e:6a:1e:2f:85:a1:6d:f5:b6:c0: - f1:ee:f7:36:e9:fe:c2:f7:ad:cc:13:46:5b:88:42: - f0:2d:1f:b5:0e:7e:b5:2b:e4:8d:ab:b9:87:30:6a: - 3d:12:f4:ad:f3:1c:ac:cc:1a:48:29:2a:96:7b:80: - 00:0b:6e:59:87:bf:a3:ca:70:99:1b:1c:fd:72:3d: - b2:d3:94:4a:cf:55:75:be:1f:40:ec:55:35:48:2d: - 55:f0:00:da:3c:b0:60:ba:11:32:66:54:0b:be:06: - a4:5e:b7:c9:59:bb:4d:f4:92:06:26:48:6e:c2:12: - d4:7c:f0:20:b8:a2:e1:bc:6a:b6:19:0e:37:47:55: - c9:f2:49:0d:96:75:a2:84:64:bf:34:fc:be:b2:41: - e4:f5:88:eb:e1:b7:26:a5:e5:41:c2:20:0c:f6:e2: - a8:a5:e7:76:54:a5:fb:4b:80:05:7d:18:85:7a:ba: - bc:b7:ad:c0:2f:60:85:cc:15:12:1c:2f:0a:9e:f3: - 7c:40:cf:f4:3e:23:d2:95:ca:d0:06:58:52:f0:84: - d8:0f:3d:eb:ff:12:68:94:79:8f:be:40:29:5f:98: - c8:90:6c:05:2f:99:8c:2a:63:78:1f:23:b1:29:c5: - e7:49:c9:b2:92:0f:53:0b:d5:71:28:17:c2:19:bf: - 60:bf:7c:87:a8:ab:c1:f4:0a:c1:b8:d2:68:ee:c1: - ce:a7:13:13:17:6d:24:5d:a2:37:a6:d7:7d:48:8b: - 2b:74:2d:40:2e:ca:19:d5:b6:3e:6c:42:71:fa:cf: - 85:87:f9:de:80:73:8b:89:f4:70:f0:d8:d7:ff:40: - 41:9c:c7:15:6d:9b:6e:4c:b5:52:02:99:79:32:73: - ca:26:a0:ac:31:6f:c4:b0:f5:da:bb:c2:1f:e0:9f: - 44:ba:25:f7:9f - Exponent: 65537 (0x10001) - Signature Algorithm: md5WithRSAEncryption - 08:75:dc:b9:3f:aa:b6:7e:81:7a:39:d1:ee:ed:44:b6:ce:1b: - 37:c4:4c:19:d0:66:e6:eb:b5:4f:2a:ef:95:58:64:21:55:01: - 12:30:ac:8a:95:d1:06:de:29:46:a4:f1:7d:7f:b0:1e:d2:4e: - fb:f6:fa:9a:74:be:85:62:db:0b:82:90:58:62:c5:5f:f1:80: - 02:9f:c5:fb:f3:6b:b0:b4:3b:04:b1:e5:53:c2:d0:00:a1:1a: - 9d:65:60:6f:73:98:67:e0:9c:c8:12:94:79:59:bf:43:7b:f5: - 77:c8:8f:df:b1:cd:11:1c:01:19:99:c2:22:42:f7:41:ae:b4: - b8:1a -----BEGIN CERTIFICATE----- -MIIFfDCCBOUCAxAAAzANBgkqhkiG9w0BAQQFADBEMQswCQYDVQQGEwJTRTEQMA4G -A1UECBMHVXBwc2FsYTEQMA4GA1UEBxMHVXBwc2FsYTERMA8GA1UEChMITXlTUUwg -QUIwHhcNMTAwMTI5MTIwMTUzWhcNMTUwMTI4MTIwMTUzWjBDMQswCQYDVQQGEwJT -RTEQMA4GA1UECBMHVXBwc2FsYTERMA8GA1UEChMITXlTUUwgQUIxDzANBgNVBAMT -BnNlcnZlcjCCBCIwDQYJKoZIhvcNAQEBBQADggQPADCCBAoCggQBAMqqHcQR7JHw -x/9fkJL8QAxetz0AxSDVD4kxB9dBTItggKo4FN6Ta5x0iEFotQJBAS2GonqVU157 -Zy9sHilR+UT9SoC+siOhPhs4z4jEce74a0HFLcDDUqxZfYE0GZUyuJpRtkE21MSh -roTmOLnov5a+GXprd03g3uaztmu8Pd1ovEvE6/U2k+1WohVQihDo1iLtbLHNwxjJ -9grh3mFlYtYUQYy1+xRowc8SXUEhnVcRQ327Qywhu8NEfajPH8NxdbVHwn3OODxz -ZJ4V2Kcnz71AyEUI48g5qAuOwlt78UeREpHM4QDgl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Lbt +V3Sy9IKtyAXqqd66fPFj4NhJygyncj8M6CSqhG5L0GhDbkA8UJ8yK/gfKm3h5xe2 +utULK5VMtAhQt6cVahO59A9t/OI17y45bmlIgdlEQISzVFe9ZbIUJW44zBfPx74k +/w8pMRr8gEuRqpL2WdJiKGG6lhMHLVFo -----END CERTIFICATE----- diff --git a/mysql-test/std_data/server8k-key.pem b/mysql-test/std_data/server8k-key.pem index faf4b43fa56..99e7417733e 100644 --- a/mysql-test/std_data/server8k-key.pem +++ b/mysql-test/std_data/server8k-key.pem @@ -1,99 +1,99 @@ -----BEGIN RSA PRIVATE KEY----- -MIISKgIBAAKCBAEAyqodxBHskfDH/1+QkvxADF63PQDFINUPiTEH10FMi2CAqjgU -3pNrnHSIQWi1AkEBLYaiepVTXntnL2weKVH5RP1KgL6yI6E+GzjPiMRx7vhrQcUt -wMNSrFl9gTQZlTK4mlG2QTbUxKGuhOY4uei/lr4Zemt3TeDe5rO2a7w93Wi8S8Tr -9TaT7VaiFVCKEOjWIu1ssc3DGMn2CuHeYWVi1hRBjLX7FGjBzxJdQSGdVxFDfbtD -LCG7w0R9qM8fw3F1tUfCfc44PHNknhXYpyfPvUDIRQjjyDmoC47CW3vxR5ESkczh -AOCUW70y5AyNw77MdjJSEmmwGOCwwnY0Wl952faBnQIKYWkcM85J+nYDHgdbJwu/ -NJ40lrgDm1A6ai8XehTPZWMAN1Koc85LFED00ppWVDO4dy5CW4/sHxj0rauKSo1t -cCXzWOfLZlEUfRb0621WdnZRbtYd2tONwGRaZ06v4r8z0bj2KvxXh6c1XoDJrPyH -yXEXkb+3TaPtPBsn9Gag+UYDJ8zqgPZLQPZBlM29CrPvJr7eb2muDz8cVWMzkJvt -yloSTd5LBsKikrBCPTGvpBUSFfiK6YiNz/2FZlBvEfGfSPO1up2GaCSiXah8VEL6 -2LXF8t0OD9Bo5FR+xbmgm2Utd/SPuTAK1YZc7cl80dqdDWNQ7uUekmPMogzoSpYC -TdyP33yPCBioMIjXr4mt/FdL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twm4sjL0VBV9fRRoxzJWRduKyeOtDL +EhhBhUoTrT48UnfW9hxnbNLB9P/hh+UJu9HrS2uAwHoGE1+8gcyundupGDBn -----END RSA PRIVATE KEY----- diff --git a/mysql-test/t/ssl_8k_key-master.opt b/mysql-test/t/ssl_8k_key-master.opt new file mode 100644 index 00000000000..b58ca7f39f0 --- /dev/null +++ b/mysql-test/t/ssl_8k_key-master.opt @@ -0,0 +1 @@ +--loose-ssl-key=$MYSQL_TEST_DIR/std_data/server8k-key.pem --loose-ssl-cert=$MYSQL_TEST_DIR/std_data/server8k-cert.pem From 96e113b60a6190d927936c2f9aa868b9d104af04 Mon Sep 17 00:00:00 2001 From: Date: Fri, 30 Jul 2010 11:59:34 +0800 Subject: [PATCH 007/136] Bug #34283 mysqlbinlog leaves tmpfile after termination if binlog contains load data infile With statement- or mixed-mode logging, "LOAD DATA INFILE" queries are written to the binlog using special types of log events. When mysqlbinlog reads such events, it re-creates the file in a temporary directory with a generated filename and outputs a "LOAD DATA INFILE" query where the filename is replaced by the generated file. The temporary file is not deleted by mysqlbinlog after termination. To fix the problem, in mixed mode we go to row-based. In SBR, we document it to remind user the tmpfile is left in a temporary directory. --- .../suite/binlog/r/binlog_mixed_load_data.result | 10 ++++++++++ .../suite/binlog/t/binlog_mixed_load_data.test | 15 +++++++++++++++ sql/sql_load.cc | 8 ++++++++ 3 files changed, 33 insertions(+) create mode 100644 mysql-test/suite/binlog/r/binlog_mixed_load_data.result create mode 100644 mysql-test/suite/binlog/t/binlog_mixed_load_data.test diff --git a/mysql-test/suite/binlog/r/binlog_mixed_load_data.result b/mysql-test/suite/binlog/r/binlog_mixed_load_data.result new file mode 100644 index 00000000000..840257f11ff --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_mixed_load_data.result @@ -0,0 +1,10 @@ +RESET MASTER; +CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=MYISAM; +LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # 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 # # COMMIT +DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/binlog_mixed_load_data.test b/mysql-test/suite/binlog/t/binlog_mixed_load_data.test new file mode 100644 index 00000000000..7e7cb973c1b --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mixed_load_data.test @@ -0,0 +1,15 @@ +# +# Bug #34283 mysqlbinlog leaves tmpfile after termination +# if binlog contains load data infile, so in mixed mode we +# go to row-based for avoiding the problem. +# + +--source include/have_binlog_format_mixed.inc +--source include/have_log_bin.inc + +RESET MASTER; +CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=MYISAM; +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); +LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; +--source include/show_binlog_events.inc +DROP TABLE t1; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index a4cf46b35e8..f9386206dce 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -141,6 +141,14 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool transactional_table; DBUG_ENTER("mysql_load"); + /* + Bug #34283 + mysqlbinlog leaves tmpfile after termination if binlog contains + load data infile, so in mixed mode we go to row-based for + avoiding the problem. + */ + thd->set_current_stmt_binlog_row_based_if_mixed(); + #ifdef EMBEDDED_LIBRARY read_file_from_client = 0; //server is always in the same process #endif From 0d7c321540e36b5928e2bd4a5d158f5852c44270 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 30 Jul 2010 09:17:10 -0300 Subject: [PATCH 008/136] Bug#54041: MySQL 5.0.92 fails when tests from Connector/C suite run Fix a regression (due to a typo) which caused spurious incorrect argument errors for long data stream parameters if all forms of logging were disabled (binary, general and slow logs). --- mysql-test/r/mysql_client_test.result | 2 ++ mysql-test/t/mysql_client_test.test | 2 ++ sql/sql_prepare.cc | 4 +-- tests/mysql_client_test.c | 49 +++++++++++++++++++++------ 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/mysql_client_test.result b/mysql-test/r/mysql_client_test.result index 08d982c85e3..edda7980e97 100644 --- a/mysql-test/r/mysql_client_test.result +++ b/mysql-test/r/mysql_client_test.result @@ -1,3 +1,5 @@ SET @old_general_log= @@global.general_log; +SET @old_slow_query_log= @@global.slow_query_log; ok SET @@global.general_log= @old_general_log; +SET @@global.slow_query_log= @old_slow_query_log; diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index 15c0cd4ac84..41670117c7c 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -2,6 +2,7 @@ -- source include/not_embedded.inc SET @old_general_log= @@global.general_log; +SET @old_slow_query_log= @@global.slow_query_log; # We run with different binaries for normal and --embedded-server # @@ -17,3 +18,4 @@ SET @old_general_log= @@global.general_log; echo ok; SET @@global.general_log= @old_general_log; +SET @@global.slow_query_log= @old_slow_query_log; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index bd152866deb..d6eb90a57be 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -793,7 +793,7 @@ static bool insert_params_with_log(Prepared_statement *stmt, uchar *null_array, type (the types are supplied at execute). Check that the supplied type of placeholder can accept a data stream. */ - else if (!is_param_long_data_type(param)) + else if (! is_param_long_data_type(param)) DBUG_RETURN(1); res= param->query_val_str(&str); if (param->convert_str_value(thd)) @@ -839,7 +839,7 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array, type (the types are supplied at execute). Check that the supplied type of placeholder can accept a data stream. */ - else if (is_param_long_data_type(param)) + else if (! is_param_long_data_type(param)) DBUG_RETURN(1); if (param->convert_str_value(stmt->thd)) DBUG_RETURN(1); /* out of memory */ diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 00389d431fa..87c35666ac6 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -13246,37 +13246,52 @@ static void test_bug15518() } -static void disable_general_log() +static void disable_query_logs() { int rc; rc= mysql_query(mysql, "set @@global.general_log=off"); myquery(rc); + rc= mysql_query(mysql, "set @@global.slow_query_log=off"); + myquery(rc); } -static void enable_general_log(int truncate) +static void enable_query_logs(int truncate) { int rc; rc= mysql_query(mysql, "set @save_global_general_log=@@global.general_log"); myquery(rc); + rc= mysql_query(mysql, "set @save_global_slow_query_log=@@global.slow_query_log"); + myquery(rc); + rc= mysql_query(mysql, "set @@global.general_log=on"); myquery(rc); + rc= mysql_query(mysql, "set @@global.slow_query_log=on"); + myquery(rc); + + if (truncate) { rc= mysql_query(mysql, "truncate mysql.general_log"); myquery(rc); + + rc= mysql_query(mysql, "truncate mysql.slow_log"); + myquery(rc); } } -static void restore_general_log() +static void restore_query_logs() { int rc; rc= mysql_query(mysql, "set @@global.general_log=@save_global_general_log"); myquery(rc); + + rc= mysql_query(mysql, "set @@global.slow_query_log=@save_global_slow_query_log"); + myquery(rc); } @@ -15447,7 +15462,7 @@ static void test_bug17667() return; } - enable_general_log(1); + enable_query_logs(1); for (statement_cursor= statements; statement_cursor->buffer != NULL; statement_cursor++) @@ -15527,7 +15542,7 @@ static void test_bug17667() statement_cursor->buffer); } - restore_general_log(); + restore_query_logs(); if (!opt_silent) printf("success. All queries found intact in the log.\n"); @@ -17390,7 +17405,7 @@ static void test_bug28386() } mysql_free_result(result); - enable_general_log(1); + enable_query_logs(1); stmt= mysql_simple_prepare(mysql, "SELECT ?"); check_stmt(stmt); @@ -17429,7 +17444,7 @@ static void test_bug28386() mysql_free_result(result); - restore_general_log(); + restore_query_logs(); DBUG_VOID_RETURN; } @@ -18215,7 +18230,7 @@ static void test_bug42373() Bug#54041: MySQL 5.0.92 fails when tests from Connector/C suite run */ -static void test_bug54041() +static void test_bug54041_impl() { int rc; MYSQL_STMT *stmt; @@ -18230,7 +18245,7 @@ static void test_bug54041() rc= mysql_query(mysql, "CREATE TABLE t1 (a INT)"); myquery(rc); - stmt= mysql_simple_prepare(mysql, "INSERT INTO t1 (a) VALUES (?)"); + stmt= mysql_simple_prepare(mysql, "SELECT a FROM t1 WHERE a > ?"); check_stmt(stmt); verify_param_count(stmt, 1); @@ -18268,6 +18283,20 @@ static void test_bug54041() } +/** + Bug#54041: MySQL 5.0.92 fails when tests from Connector/C suite run +*/ + +static void test_bug54041() +{ + enable_query_logs(0); + test_bug54041_impl(); + disable_query_logs(); + test_bug54041_impl(); + restore_query_logs(); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -18348,7 +18377,7 @@ and you are welcome to modify and redistribute it under the GPL license\n"); static struct my_tests_st my_tests[]= { - { "disable_general_log", disable_general_log }, + { "disable_query_logs", disable_query_logs }, { "test_view_sp_list_fields", test_view_sp_list_fields }, { "client_query", client_query }, { "test_prepare_insert_update", test_prepare_insert_update}, From 6d60052e32f5d1432d2bf6efa4c0906156ccfce1 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 30 Jul 2010 09:34:40 -0300 Subject: [PATCH 009/136] Bug#54041: MySQL 5.0.92 fails when tests from Connector/C suite run Fix a regression (due to a typo) which caused spurious incorrect argument errors for long data stream parameters if all forms of logging were disabled (binary, general and slow logs). --- sql/sql_prepare.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index c2fecd63777..9815acfe815 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -755,7 +755,7 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array, type (the types are supplied at execute). Check that the supplied type of placeholder can accept a data stream. */ - else if (!is_param_long_data_type(param)) + else if (! is_param_long_data_type(param)) DBUG_RETURN(1); res= param->query_val_str(&str); if (param->convert_str_value(thd)) @@ -801,7 +801,7 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array, type (the types are supplied at execute). Check that the supplied type of placeholder can accept a data stream. */ - else if (is_param_long_data_type(param)) + else if (! is_param_long_data_type(param)) DBUG_RETURN(1); if (param->convert_str_value(stmt->thd)) DBUG_RETURN(1); /* out of memory */ From d765e30a1d2533ce74e45a144be0e132c3485bf4 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 30 Jul 2010 16:35:06 +0300 Subject: [PATCH 010/136] Bug #55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results In order to be able to check if the set of the grouping fields in a GROUP BY has changed (and thus to start a new group) the optimizer caches the current values of these fields in a set of Cached_item derived objects. The Cached_item_str, used for caching varchar and TEXT columns, is limited in length by the max_sort_length variable. A String buffer to store the value with an alloced length of either the max length of the string or the value of max_sort_length (whichever is smaller) in Cached_item_str's constructor. Then, at compare time the value of the string to compare to was truncated to the alloced length of the string buffer inside Cached_item_str. This is all fine and valid, but only if you're not assigning values near or equal to the alloced length of this buffer. Because when assigning values like this the alloced length is rounded up and as a result the next set of data will not match the group buffer, thus leading to wrong results because of the changed alloced_length. Fixed by preserving the original maximum length in the Cached_item_str's constructor and using this instead of the alloced_length to limit the string to compare to. Test case added. --- mysql-test/r/group_by.result | 35 +++++++++++++++++++++++++++++++++++ mysql-test/t/group_by.test | 14 ++++++++++++++ sql/item.h | 1 + sql/item_buff.cc | 6 ++++-- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 645dd460735..f74584f6bcf 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1810,4 +1810,39 @@ MAX(t2.a) 2 DROP TABLE t1, t2; # +# Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results +# +CREATE TABLE t1 (a text, b varchar(10)); +INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two'); +EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +id 1 +select_type SIMPLE +table t1 +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +Extra Using filesort +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +SUBSTRING(a,1,10) LENGTH(a) GROUP_CONCAT(b) +1111111111 1300 one,two +EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +id 1 +select_type SIMPLE +table t1 +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +Extra Using temporary; Using filesort +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +SUBSTRING(a,1,10) LENGTH(a) +1111111111 1300 +DROP TABLE t1; # End of 5.1 tests diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index c5b27ee1a62..75ec1d82b02 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1221,5 +1221,19 @@ DROP TABLE t1, t2; --echo # +--echo # Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results +--echo # + +CREATE TABLE t1 (a text, b varchar(10)); +INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two'); + +query_vertical EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +query_vertical EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +DROP TABLE t1; + --echo # End of 5.1 tests diff --git a/sql/item.h b/sql/item.h index 174995b43e6..57abb43010e 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2740,6 +2740,7 @@ public: class Cached_item_str :public Cached_item { Item *item; + uint32 value_max_length; String value,tmp_value; public: Cached_item_str(THD *thd, Item *arg); diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 2f45d0a17c2..0ac4edb3656 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -58,7 +58,9 @@ Cached_item::~Cached_item() {} */ Cached_item_str::Cached_item_str(THD *thd, Item *arg) - :item(arg), value(min(arg->max_length, thd->variables.max_sort_length)) + :item(arg), + value_max_length(min(arg->max_length, thd->variables.max_sort_length)), + value(value_max_length) {} bool Cached_item_str::cmp(void) @@ -67,7 +69,7 @@ bool Cached_item_str::cmp(void) bool tmp; if ((res=item->val_str(&tmp_value))) - res->length(min(res->length(), value.alloced_length())); + res->length(min(res->length(), value_max_length)); if (null_value != item->null_value) { if ((null_value= item->null_value)) From c8adc1d5e1753b99a2b94551c6d89db9dff52e24 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Fri, 30 Jul 2010 14:44:39 +0100 Subject: [PATCH 011/136] Revert patch for BUG#34283. Causing lots of test failures in PB2, mostly because existing test result files were not updated. --- .../suite/binlog/r/binlog_mixed_load_data.result | 10 ---------- .../suite/binlog/t/binlog_mixed_load_data.test | 15 --------------- sql/sql_load.cc | 8 -------- 3 files changed, 33 deletions(-) delete mode 100644 mysql-test/suite/binlog/r/binlog_mixed_load_data.result delete mode 100644 mysql-test/suite/binlog/t/binlog_mixed_load_data.test diff --git a/mysql-test/suite/binlog/r/binlog_mixed_load_data.result b/mysql-test/suite/binlog/r/binlog_mixed_load_data.result deleted file mode 100644 index 840257f11ff..00000000000 --- a/mysql-test/suite/binlog/r/binlog_mixed_load_data.result +++ /dev/null @@ -1,10 +0,0 @@ -RESET MASTER; -CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=MYISAM; -LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; -show binlog events from ; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # 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 # # COMMIT -DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/binlog_mixed_load_data.test b/mysql-test/suite/binlog/t/binlog_mixed_load_data.test deleted file mode 100644 index 7e7cb973c1b..00000000000 --- a/mysql-test/suite/binlog/t/binlog_mixed_load_data.test +++ /dev/null @@ -1,15 +0,0 @@ -# -# Bug #34283 mysqlbinlog leaves tmpfile after termination -# if binlog contains load data infile, so in mixed mode we -# go to row-based for avoiding the problem. -# - ---source include/have_binlog_format_mixed.inc ---source include/have_log_bin.inc - -RESET MASTER; -CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=MYISAM; -let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); -LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; ---source include/show_binlog_events.inc -DROP TABLE t1; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index f9386206dce..a4cf46b35e8 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -141,14 +141,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool transactional_table; DBUG_ENTER("mysql_load"); - /* - Bug #34283 - mysqlbinlog leaves tmpfile after termination if binlog contains - load data infile, so in mixed mode we go to row-based for - avoiding the problem. - */ - thd->set_current_stmt_binlog_row_based_if_mixed(); - #ifdef EMBEDDED_LIBRARY read_file_from_client = 0; //server is always in the same process #endif From a9356a894c148e40204eb6bfb1cfb451c48b6bc8 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 30 Jul 2010 17:09:24 +0300 Subject: [PATCH 012/136] Disable the tests failing under valgrind because of bug #55503 --- mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test | 2 ++ mysql-test/suite/innodb_plugin/t/innodb-autoinc.test | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test b/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test index 99cdac72e2e..5e4cf9dcb4c 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test +++ b/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test @@ -1,6 +1,8 @@ -- source include/have_innodb_plugin.inc # embedded server ignores 'delayed', so skip this -- source include/not_embedded.inc +# remove the next line after bug #55503 is fixed +-- source include/not_valgrind.inc let $innodb_file_format_check_orig=`select @@innodb_file_format_check`; diff --git a/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test b/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test index 5a83ffe3617..49394a019d0 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test @@ -1,6 +1,8 @@ -- source include/have_innodb_plugin.inc # embedded server ignores 'delayed', so skip this -- source include/not_embedded.inc +# remove the next line after bug #55503 is fixed +-- source include/not_valgrind.inc let $innodb_file_format_check_orig=`select @@innodb_file_format_check`; From c7e307e987327f100ba769856ae43dbd3f783cb0 Mon Sep 17 00:00:00 2001 From: Inaam Rana Date: Fri, 30 Jul 2010 10:39:16 -0400 Subject: [PATCH 013/136] When the caller of buf_flush_list() provides us with the number of pages that it wants to flush then we should honor that value as in not going beyond that in our eagerness to flush the neighbors of the selected victim. --- storage/innobase/buf/buf0flu.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/storage/innobase/buf/buf0flu.c b/storage/innobase/buf/buf0flu.c index 3737627301f..4131d863e6a 100644 --- a/storage/innobase/buf/buf0flu.c +++ b/storage/innobase/buf/buf0flu.c @@ -1248,8 +1248,12 @@ buf_flush_try_neighbors( /*====================*/ ulint space, /*!< in: space id */ ulint offset, /*!< in: page offset */ - enum buf_flush flush_type) /*!< in: BUF_FLUSH_LRU or + enum buf_flush flush_type, /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ + ulint n_flushed, /*!< in: number of pages + flushed so far in this batch */ + ulint n_to_flush) /*!< in: maximum number of pages + we are allowed to flush */ { ulint i; ulint low; @@ -1290,6 +1294,21 @@ buf_flush_try_neighbors( buf_page_t* bpage; + if ((count + n_flushed) >= n_to_flush) { + + /* We have already flushed enough pages and + should call it a day. There is, however, one + exception. If the page whose neighbors we + are flushing has not been flushed yet then + we'll try to flush the victim that we + selected originally. */ + if (i <= offset) { + i = offset; + } else { + break; + } + } + buf_pool = buf_pool_get(space, i); buf_pool_mutex_enter(buf_pool); @@ -1357,6 +1376,8 @@ buf_flush_page_and_try_neighbors( buf_page_in_file(bpage) */ enum buf_flush flush_type, /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ + ulint n_to_flush, /*!< in: number of pages to + flush */ ulint* count) /*!< in/out: number of pages flushed */ { @@ -1390,7 +1411,11 @@ buf_flush_page_and_try_neighbors( mutex_exit(block_mutex); /* Try to flush also all the neighbors */ - *count += buf_flush_try_neighbors(space, offset, flush_type); + *count += buf_flush_try_neighbors(space, + offset, + flush_type, + *count, + n_to_flush); buf_pool_mutex_enter(buf_pool); flushed = TRUE; @@ -1430,7 +1455,7 @@ buf_flush_LRU_list_batch( a page that isn't ready for flushing. */ while (bpage != NULL && !buf_flush_page_and_try_neighbors( - bpage, BUF_FLUSH_LRU, &count)) { + bpage, BUF_FLUSH_LRU, max, &count)) { bpage = UT_LIST_GET_PREV(LRU, bpage); } @@ -1511,7 +1536,7 @@ buf_flush_flush_list_batch( while (bpage != NULL && len > 0 && !buf_flush_page_and_try_neighbors( - bpage, BUF_FLUSH_LIST, &count)) { + bpage, BUF_FLUSH_LIST, min_n, &count)) { buf_flush_list_mutex_enter(buf_pool); From e260cc3ff28d4d1130efe29cab917f6fb946faf7 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 30 Jul 2010 17:33:10 -0300 Subject: [PATCH 014/136] Bug#45288: pb2 returns a lot of compilation warnings on linux Fix compiler warnings. --- mysys/stacktrace.c | 4 +++- sql/sql_lex.cc | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 75fda93b56e..7bac8017324 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -86,7 +86,9 @@ void my_print_stacktrace(uchar* stack_bottom __attribute__((unused)), #if BACKTRACE_DEMANGLE -char __attribute__ ((weak)) *my_demangle(const char *mangled_name, int *status) +char __attribute__ ((weak)) * +my_demangle(const char *mangled_name __attribute__((unused)), + int *status __attribute__((unused))) { return NULL; } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2bff036b1f1..24c51be2512 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1303,8 +1303,6 @@ int MYSQLlex(void *arg, void *yythd) } else { - const char* version_mark= lip->get_ptr() - 1; - DBUG_ASSERT(*version_mark == '!'); /* Patch and skip the conditional comment to avoid it being propagated infinitely (eg. to a slave). @@ -1313,7 +1311,6 @@ int MYSQLlex(void *arg, void *yythd) comment_closed= ! consume_comment(lip, 1); if (! comment_closed) { - DBUG_ASSERT(pcom == version_mark); *pcom= '!'; } /* version allowed to have one level of comment inside. */ From 38165ce4a3fdd0d539fa5b0972d105af31a0d134 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Sun, 1 Aug 2010 22:12:36 +0400 Subject: [PATCH 015/136] Bug #54461: crash with longblob and union or update with subquery Queries may crash, if 1) the GREATEST or the LEAST function has a mixed list of numeric and LONGBLOB arguments and 2) the result of such a function goes through an intermediate temporary table. An Item that references a LONGBLOB field has max_length of UINT_MAX32 == (2^32 - 1). The current implementation of GREATEST/LEAST returns REAL result for a mixed list of numeric and string arguments (that contradicts with the current documentation, this contradiction was discussed and it was decided to update the documentation). The max_length of such a function call was calculated as a maximum of argument max_length values (i.e. UINT_MAX32). That max_length value of UINT_MAX32 was used as a length for the intermediate temporary table Field_double to hold GREATEST/LEAST function result. The Field_double::val_str() method call on that field allocates a String value. Since an allocation of String reserves an additional byte for a zero-termination, the size of String buffer was set to (UINT_MAX32 + 1), that caused an integer overflow: actually, an empty buffer of size 0 was allocated. An initialization of the "first" byte of that zero-size buffer with '\0' caused a crash. The Item_func_min_max::fix_length_and_dec() has been modified to calculate max_length for the REAL result like we do it for arithmetical operators. ****** Bug #54461: crash with longblob and union or update with subquery Queries may crash, if 1) the GREATEST or the LEAST function has a mixed list of numeric and LONGBLOB arguments and 2) the result of such a function goes through an intermediate temporary table. An Item that references a LONGBLOB field has max_length of UINT_MAX32 == (2^32 - 1). The current implementation of GREATEST/LEAST returns REAL result for a mixed list of numeric and string arguments (that contradicts with the current documentation, this contradiction was discussed and it was decided to update the documentation). The max_length of such a function call was calculated as a maximum of argument max_length values (i.e. UINT_MAX32). That max_length value of UINT_MAX32 was used as a length for the intermediate temporary table Field_double to hold GREATEST/LEAST function result. The Field_double::val_str() method call on that field allocates a String value. Since an allocation of String reserves an additional byte for a zero-termination, the size of String buffer was set to (UINT_MAX32 + 1), that caused an integer overflow: actually, an empty buffer of size 0 was allocated. An initialization of the "first" byte of that zero-size buffer with '\0' caused a crash. The Item_func_min_max::fix_length_and_dec() has been modified to calculate max_length for the REAL result like we do it for arithmetical operators. --- mysql-test/r/func_misc.result | 15 +++++++++++++++ mysql-test/t/func_misc.test | 12 ++++++++++++ sql/item_func.cc | 2 ++ 3 files changed, 29 insertions(+) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 81dddd0f648..eee56ae7461 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -336,4 +336,19 @@ End of 5.0 tests select connection_id() > 0; connection_id() > 0 1 +# +# Bug #54461: crash with longblob and union or update with subquery +# +CREATE TABLE t1 (a INT, b LONGBLOB); +INSERT INTO t1 VALUES (1, '2'), (2, '3'), (3, '2'); +SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +LEAST(a, (SELECT b FROM t1 LIMIT 1)) +1 +2 +SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +GREATEST(a, (SELECT b FROM t1 LIMIT 1)) +2 +3 +1 +DROP TABLE t1; End of tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 6590b43f2dc..c6b5ffd5a3f 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -467,4 +467,16 @@ select NAME_CONST('_id',1234) as id; select connection_id() > 0; +--echo # +--echo # Bug #54461: crash with longblob and union or update with subquery +--echo # + +CREATE TABLE t1 (a INT, b LONGBLOB); +INSERT INTO t1 VALUES (1, '2'), (2, '3'), (3, '2'); + +SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; + +DROP TABLE t1; + --echo End of tests diff --git a/sql/item_func.cc b/sql/item_func.cc index 1bec4700bff..1b13297c951 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2243,6 +2243,8 @@ void Item_func_min_max::fix_length_and_dec() max_length= my_decimal_precision_to_length_no_truncation(max_int_part + decimals, decimals, unsigned_flag); + else if (cmp_type == REAL_RESULT) + max_length= float_length(decimals); cached_field_type= agg_field_type(args, arg_count); } From 4ee89071af88ad61ce2e1291c336630df548d6b9 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 2 Aug 2010 10:48:24 +0300 Subject: [PATCH 016/136] tree name update --- .bzr-mysql/default.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 4b2affc1529..f79c1cd6319 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,4 +1,4 @@ [MYSQL] -post_commit_to = "dbg_mysql_security@sun.com" -post_push_to = "dbg_mysql_security@sun.com" -tree_name = "mysql-5.0-security" +post_commit_to = "commits@lists.mysql.com" +post_push_to = "commits@lists.mysql.com" +tree_name = "mysql-5.0" From 1feee134fdc346bb1ad73cce54cd7e87df5c839a Mon Sep 17 00:00:00 2001 From: Alfranio Correia Date: Mon, 2 Aug 2010 20:48:56 +0100 Subject: [PATCH 017/136] BUG#55625 RBR breaks on failing 'CREATE TABLE' A CREATE...SELECT that fails is written to the binary log if a non-transactional statement is updated. If the logging format is ROW, the CREATE statement and the changes are written to the binary log as distinct events and by consequence the created table is not rolled back in the slave. In this patch, we opted to let the slave goes out of sync by not writting to the binary log the CREATE statement. We do this by simply reseting the binary log's cache. --- mysql-test/suite/rpl/r/rpl_drop.result | 24 ++++++++++++ mysql-test/suite/rpl/t/rpl_drop.test | 53 +++++++++++++++++++++++++- sql/log.cc | 13 +++++++ sql/log.h | 3 +- sql/sql_insert.cc | 11 ++++++ 5 files changed, 102 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_drop.result b/mysql-test/suite/rpl/r/rpl_drop.result index b83594c9bb1..5ebbc4f9ce7 100644 --- a/mysql-test/suite/rpl/r/rpl_drop.result +++ b/mysql-test/suite/rpl/r/rpl_drop.result @@ -8,3 +8,27 @@ drop table if exists t1, t2; create table t1 (a int); drop table t1, t2; ERROR 42S02: Unknown table 't2' +include/stop_slave.inc +SET @old_binlog_format= @@global.binlog_format; +SET GLOBAL binlog_format = ROW; +include/start_slave.inc +SET @old_binlog_format= @@global.binlog_format; +SET binlog_format = ROW; +CREATE TABLE t2(a INT) ENGINE=MYISAM; +CREATE TABLE t3(a INT) ENGINE=INNODB; +CREATE FUNCTION f1() RETURNS INT +BEGIN +insert into t2 values(1); +insert into t3 values(1); +return 1; +END| +CREATE TABLE t1(UNIQUE(a)) ENGINE=MYISAM SELECT 1 AS a UNION ALL SELECT f1(); +ERROR 23000: Duplicate entry '1' for key 'a' +CREATE TABLE t1(UNIQUE(a)) ENGINE=INNODB SELECT 1 AS a UNION ALL SELECT f1(); +ERROR 23000: Duplicate entry '1' for key 'a' +show binlog events in 'master-bin.000001' from ; +Log_name Pos Event_type Server_id End_log_pos Info +DROP FUNCTION f1; +DROP TABLE t2, t3; +SET @@global.binlog_format= @old_binlog_format; +SET @@global.binlog_format= @old_binlog_format; diff --git a/mysql-test/suite/rpl/t/rpl_drop.test b/mysql-test/suite/rpl/t/rpl_drop.test index b38007a755f..336edad6fc5 100644 --- a/mysql-test/suite/rpl/t/rpl_drop.test +++ b/mysql-test/suite/rpl/t/rpl_drop.test @@ -1,6 +1,7 @@ # Testcase for BUG#4552 (DROP on two tables, one of which does not # exist, must be binlogged with a non-zero error code) source include/master-slave.inc; +source include/have_innodb.inc; --disable_warnings drop table if exists t1, t2; --enable_warnings @@ -10,7 +11,57 @@ drop table t1, t2; save_master_pos; connection slave; sync_with_master; - # End of 4.1 tests +# BUG#55625 RBR breaks on failing 'CREATE TABLE' +# A CREATE...SELECT that fails is written to the binary log if a non-transactional +# statement is updated. If the logging format is ROW, the CREATE statement and the +# changes are written to the binary log as distinct events and by consequence the +# created table is not rolled back in the slave. +# To fix the problem, we do not write a CREATE...SELECT that fails to the binary +# log. Howerver, the changes to non-transactional tables are not replicated and +# thus the slave goes out of sync. This should be fixed after BUG#47899. +# +# In the test case, we verify if the binary log contains no information for a +# CREATE...SELECT that fails. +connection slave; +--source include/stop_slave.inc +SET @old_binlog_format= @@global.binlog_format; +SET GLOBAL binlog_format = ROW; +--source include/start_slave.inc + +connection master; +SET @old_binlog_format= @@global.binlog_format; +SET binlog_format = ROW; + +CREATE TABLE t2(a INT) ENGINE=MYISAM; +CREATE TABLE t3(a INT) ENGINE=INNODB; + +delimiter |; +CREATE FUNCTION f1() RETURNS INT +BEGIN + insert into t2 values(1); + insert into t3 values(1); + return 1; +END| +delimiter ;| + +let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1); +let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1); + +--error 1062 +CREATE TABLE t1(UNIQUE(a)) ENGINE=MYISAM SELECT 1 AS a UNION ALL SELECT f1(); +--error 1062 +CREATE TABLE t1(UNIQUE(a)) ENGINE=INNODB SELECT 1 AS a UNION ALL SELECT f1(); + +--source include/show_binlog_events.inc + +DROP FUNCTION f1; +DROP TABLE t2, t3; +SET @@global.binlog_format= @old_binlog_format; + +--sync_slave_with_master +SET @@global.binlog_format= @old_binlog_format; + +# End of 5.1 tests diff --git a/sql/log.cc b/sql/log.cc index 614a07e6b63..3f41bf1c929 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1628,6 +1628,19 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) DBUG_RETURN(error); } +/** + Cleanup the cache. + + @param thd The client thread that wants to clean up the cache. +*/ +void MYSQL_BIN_LOG::reset_gathered_updates(THD *thd) +{ + binlog_trx_data *const trx_data= + (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton); + + trx_data->reset(); +} + void MYSQL_BIN_LOG::set_write_error(THD *thd) { DBUG_ENTER("MYSQL_BIN_LOG::set_write_error"); diff --git a/sql/log.h b/sql/log.h index 8d3880d9171..8f1ed7ee90c 100644 --- a/sql/log.h +++ b/sql/log.h @@ -356,10 +356,11 @@ public: /* Use this to start writing a new log file */ void new_file(); + void reset_gathered_updates(THD *thd); bool write(Log_event* event_info); // binary log write bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool incident); - bool write_incident(THD *thd, bool lock); + bool write_incident(THD *thd, bool lock); int write_cache(IO_CACHE *cache, bool lock_log, bool flush_and_sync); void set_write_error(THD *thd); bool check_write_error(THD *thd); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 35c24e7571e..83b1834da0b 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3873,6 +3873,17 @@ void select_create::abort() if (table) { + if (thd->lex->sql_command == SQLCOM_CREATE_TABLE && + thd->current_stmt_binlog_row_based && + !(thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && + mysql_bin_log.is_open()) + { + /* + This should be removed after BUG#47899. + */ + mysql_bin_log.reset_gathered_updates(thd); + } + table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); if (!create_info->table_existed) From aa1572f46df7e3406acc6fdade4700d5fff67355 Mon Sep 17 00:00:00 2001 From: Date: Tue, 3 Aug 2010 10:22:19 +0800 Subject: [PATCH 018/136] Bug #34283 mysqlbinlog leaves tmpfile after termination if binlog contains load data infile With statement- or mixed-mode logging, "LOAD DATA INFILE" queries are written to the binlog using special types of log events. When mysqlbinlog reads such events, it re-creates the file in a temporary directory with a generated filename and outputs a "LOAD DATA INFILE" query where the filename is replaced by the generated file. The temporary file is not deleted by mysqlbinlog after termination. To fix the problem, in mixed mode we go to row-based. In SBR, we document it to remind user the tmpfile is left in a temporary directory. --- mysql-test/extra/rpl_tests/rpl_loaddata.test | 2 +- .../suite/binlog/r/binlog_mixed_load_data.result | 10 ++++++++++ .../suite/binlog/t/binlog_killed_simulate.test | 2 +- .../suite/binlog/t/binlog_mixed_load_data.test | 15 +++++++++++++++ .../suite/binlog/t/binlog_stm_blackhole.test | 2 +- .../suite/rpl/r/rpl_innodb_mixed_dml.result | 4 ++-- mysql-test/suite/rpl/t/rpl_loaddata_fatal.test | 2 +- mysql-test/suite/rpl/t/rpl_loaddata_map.test | 2 +- .../rpl/t/rpl_slave_load_remove_tmpfile.test | 2 +- mysql-test/suite/rpl/t/rpl_stm_log.test | 2 +- sql/sql_load.cc | 8 ++++++++ 11 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 mysql-test/suite/binlog/r/binlog_mixed_load_data.result create mode 100644 mysql-test/suite/binlog/t/binlog_mixed_load_data.test diff --git a/mysql-test/extra/rpl_tests/rpl_loaddata.test b/mysql-test/extra/rpl_tests/rpl_loaddata.test index 1ae17398596..a3c7d032c32 100644 --- a/mysql-test/extra/rpl_tests/rpl_loaddata.test +++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test @@ -1,5 +1,5 @@ # Requires statement logging --- source include/have_binlog_format_mixed_or_statement.inc +-- source include/have_binlog_format_statement.inc # See if replication of a "LOAD DATA in an autoincrement column" # Honours autoincrement values diff --git a/mysql-test/suite/binlog/r/binlog_mixed_load_data.result b/mysql-test/suite/binlog/r/binlog_mixed_load_data.result new file mode 100644 index 00000000000..840257f11ff --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_mixed_load_data.result @@ -0,0 +1,10 @@ +RESET MASTER; +CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=MYISAM; +LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # 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 # # COMMIT +DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/binlog_killed_simulate.test b/mysql-test/suite/binlog/t/binlog_killed_simulate.test index ec61271ae88..b87d47559fe 100644 --- a/mysql-test/suite/binlog/t/binlog_killed_simulate.test +++ b/mysql-test/suite/binlog/t/binlog_killed_simulate.test @@ -1,5 +1,5 @@ -- source include/have_debug.inc --- source include/have_binlog_format_mixed_or_statement.inc +-- source include/have_binlog_format_statement.inc # # bug#27571 asynchronous setting mysql_$query()'s local error and # Query_log_event::error_code diff --git a/mysql-test/suite/binlog/t/binlog_mixed_load_data.test b/mysql-test/suite/binlog/t/binlog_mixed_load_data.test new file mode 100644 index 00000000000..7e7cb973c1b --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mixed_load_data.test @@ -0,0 +1,15 @@ +# +# Bug #34283 mysqlbinlog leaves tmpfile after termination +# if binlog contains load data infile, so in mixed mode we +# go to row-based for avoiding the problem. +# + +--source include/have_binlog_format_mixed.inc +--source include/have_log_bin.inc + +RESET MASTER; +CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=MYISAM; +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); +LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; +--source include/show_binlog_events.inc +DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/binlog_stm_blackhole.test b/mysql-test/suite/binlog/t/binlog_stm_blackhole.test index 02ba2be095b..6047d8ca2fc 100644 --- a/mysql-test/suite/binlog/t/binlog_stm_blackhole.test +++ b/mysql-test/suite/binlog/t/binlog_stm_blackhole.test @@ -2,5 +2,5 @@ # For both statement and row based bin logs 9/19/2005 [jbm] -- source include/not_embedded.inc --- source include/have_binlog_format_mixed_or_statement.inc +-- source include/have_binlog_format_statement.inc -- source extra/binlog_tests/blackhole.test diff --git a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result index 35f4cd3ecbb..7fc940f25e0 100644 --- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result +++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result @@ -883,8 +883,8 @@ master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # BEGIN -master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=# -master-bin.000001 # Execute_load_query # # use `test_rpl`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/rpl_mixed.dat' INTO TABLE `t1` FIELDS TERMINATED BY '|' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, `b`) ;file_id=# +master-bin.000001 # Table_map # # table_id: # (test_rpl.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test_rpl`; DELETE FROM t1 diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test b/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test index e80fc160d8f..b8975308a86 100644 --- a/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test +++ b/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test @@ -1,4 +1,4 @@ -source include/have_binlog_format_mixed_or_statement.inc; +source include/have_binlog_format_statement.inc; source include/have_debug.inc; source include/master-slave.inc; diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_map.test b/mysql-test/suite/rpl/t/rpl_loaddata_map.test index ddee9e7e989..1db7c4a893b 100644 --- a/mysql-test/suite/rpl/t/rpl_loaddata_map.test +++ b/mysql-test/suite/rpl/t/rpl_loaddata_map.test @@ -16,7 +16,7 @@ # BUG#33413 show binlog events fails if binlog has event size of close # to max_allowed_packet -source include/have_binlog_format_mixed_or_statement.inc; +source include/have_binlog_format_statement.inc; source include/master-slave.inc; diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test index 22309c33724..b7342fd1c40 100644 --- a/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test +++ b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test @@ -8,7 +8,7 @@ # 2 - Catches error. ########################################################################## ---source include/have_binlog_format_mixed_or_statement.inc +--source include/have_binlog_format_statement.inc --source include/have_innodb.inc --source include/have_debug.inc --source include/master-slave.inc diff --git a/mysql-test/suite/rpl/t/rpl_stm_log.test b/mysql-test/suite/rpl/t/rpl_stm_log.test index 2af9d7f85bc..7bc17fbaada 100644 --- a/mysql-test/suite/rpl/t/rpl_stm_log.test +++ b/mysql-test/suite/rpl/t/rpl_stm_log.test @@ -1,5 +1,5 @@ # Requires statement logging --- source include/have_binlog_format_mixed_or_statement.inc +-- source include/have_binlog_format_statement.inc -- source include/master-slave.inc let $engine_type=MyISAM; -- source extra/rpl_tests/rpl_log.test diff --git a/sql/sql_load.cc b/sql/sql_load.cc index a4cf46b35e8..f9386206dce 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -141,6 +141,14 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool transactional_table; DBUG_ENTER("mysql_load"); + /* + Bug #34283 + mysqlbinlog leaves tmpfile after termination if binlog contains + load data infile, so in mixed mode we go to row-based for + avoiding the problem. + */ + thd->set_current_stmt_binlog_row_based_if_mixed(); + #ifdef EMBEDDED_LIBRARY read_file_from_client = 0; //server is always in the same process #endif From ae67979f76f9bdcda08d6afdaf748bb9d0c12bb0 Mon Sep 17 00:00:00 2001 From: Calvin Sun Date: Tue, 3 Aug 2010 01:12:03 -0500 Subject: [PATCH 019/136] Bug #54702: revert the default of innodb_strict_mode to false. --- storage/innobase/handler/ha_innodb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index ab9df9a0272..e78f167beb6 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -425,7 +425,7 @@ static MYSQL_THDVAR_BOOL(table_locks, PLUGIN_VAR_OPCMDARG, static MYSQL_THDVAR_BOOL(strict_mode, PLUGIN_VAR_OPCMDARG, "Use strict mode when evaluating create options.", - NULL, NULL, TRUE); + NULL, NULL, FALSE); static MYSQL_THDVAR_ULONG(lock_wait_timeout, PLUGIN_VAR_RQCMDARG, "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.", From 029bc22b671dfb850c98ae50cd50864a7f70ae41 Mon Sep 17 00:00:00 2001 From: Date: Tue, 3 Aug 2010 18:27:45 +0800 Subject: [PATCH 020/136] Bug #34283 mysqlbinlog leaves tmpfile after termination if binlog contains load data infile Post fix --- mysql-test/t/mysqlbinlog.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 7c9fbf031bb..783708cc3b2 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -1,6 +1,6 @@ # We are using .opt file since we need small binlog size # TODO: Need to look at making a row based version once the new row based client is completed. [jbm] --- source include/have_binlog_format_mixed_or_statement.inc +-- source include/have_binlog_format_statement.inc -- source include/have_log_bin.inc From 534e69338a449ce258426264b14f0ce3b658e5aa Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 3 Aug 2010 19:01:30 +0300 Subject: [PATCH 021/136] Bug #42144: plugin_load fails The enum system variables were handled inconsistently as ints, unsigned int and unsigned long on various places. This caused problems on platforms on which sizeof(int) != sizeof(long). Fixed by homogenizing the type of the enum variables to unsigned int, since it's size compatible with the C enum type. Removed the test from the experimental list. --- include/mysql/plugin.h | 2 +- mysql-test/collections/default.experimental | 1 - mysys/my_getopt.c | 24 ++++++++++++--------- sql/sql_plugin.cc | 4 ++-- storage/example/ha_example.cc | 2 +- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 55ef6070f85..c2ca8a0f94e 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -318,7 +318,7 @@ DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \ #name, comment, check, update, &varname, def, min, max, blk } #define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \ -DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \ +DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned int) = { \ PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \ #name, comment, check, update, &varname, def, typelib } diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental index f84337660ea..d47523ad945 100644 --- a/mysql-test/collections/default.experimental +++ b/mysql-test/collections/default.experimental @@ -14,7 +14,6 @@ funcs_2.ndb_charset # joro : NDB tests marked as experiment main.ctype_gbk_binlog @solaris # Bug#46010: main.ctype_gbk_binlog fails sporadically : Table 't2' already exists main.func_str @solaris # joro: Bug#40928 -main.plugin_load @solaris # Bug#42144 main.sp @solaris # joro : Bug#54138 main.outfile_loaddata @solaris # joro : Bug #46895 diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index b0e7175d0b9..6ed4189a69a 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -656,17 +656,21 @@ static int setval(const struct my_option *opts, void *value, char *argument, return EXIT_OUT_OF_MEMORY; break; case GET_ENUM: - if (((*(int*)result_pos)= - find_type(argument, opts->typelib, 2) - 1) < 0) { - /* - Accept an integer representation of the enumerated item. - */ - char *endptr; - unsigned int arg= (unsigned int) strtol(argument, &endptr, 10); - if (*endptr || arg >= opts->typelib->count) - return EXIT_ARGUMENT_INVALID; - *(int*)result_pos= arg; + int type= find_type(argument, opts->typelib, 2); + if (type < 1) + { + /* + Accept an integer representation of the enumerated item. + */ + char *endptr; + uint arg= (uint) strtoul(argument, &endptr, 10); + if (*endptr || arg >= opts->typelib->count) + return EXIT_ARGUMENT_INVALID; + *(uint*)result_pos= arg; + } + else + *(uint*)result_pos= type - 1; } break; case GET_SET: diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 7383d59a1d9..6eed702e5ec 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3030,10 +3030,10 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, Allocate temporary space for the value of the tristate. This option will have a limited lifetime and is not used beyond server initialization. - GET_ENUM value is an integer. + GET_ENUM value is unsigned integer. */ options[0].value= options[1].value= (uchar **)alloc_root(mem_root, - sizeof(int)); + sizeof(uint)); *((uint*) options[0].value)= *((uint*) options[1].value)= (uint) options[0].def_value; diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 2a4fe538c85..402be70efab 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -848,7 +848,7 @@ int ha_example::create(const char *name, TABLE *table_arg, struct st_mysql_storage_engine example_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; -static ulong srv_enum_var= 0; +static uint srv_enum_var= 0; static ulong srv_ulong_var= 0; const char *enum_var_names[]= From 84686593ad78bcc3d6f60ee6d3db8adf58525c51 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 4 Aug 2010 15:58:09 +0300 Subject: [PATCH 022/136] Bug #42144: plugin_load fails Reverted the ulong->uint diff Re-applied the first diff. The original commit message follows: enum plugin system variables are ulong internally, not int. On systems where long is not the same as an int it causes problems. Fixed by correct typecasting. Removed the test from the experimental list. --- include/mysql/plugin.h | 2 +- mysys/my_getopt.c | 10 +++++----- sql/sql_plugin.cc | 8 ++++---- storage/example/ha_example.cc | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index c2ca8a0f94e..55ef6070f85 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -318,7 +318,7 @@ DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \ #name, comment, check, update, &varname, def, min, max, blk } #define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \ -DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned int) = { \ +DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \ PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \ #name, comment, check, update, &varname, def, typelib } diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 6ed4189a69a..0327db33e98 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -664,13 +664,13 @@ static int setval(const struct my_option *opts, void *value, char *argument, Accept an integer representation of the enumerated item. */ char *endptr; - uint arg= (uint) strtoul(argument, &endptr, 10); + ulong arg= strtoul(argument, &endptr, 10); if (*endptr || arg >= opts->typelib->count) return EXIT_ARGUMENT_INVALID; - *(uint*)result_pos= arg; + *((ulong*) result_pos)= arg; } else - *(uint*)result_pos= type - 1; + *((ulong*) result_pos)= type - 1; } break; case GET_SET: @@ -1008,7 +1008,7 @@ static void init_one_value(const struct my_option *option, void *variable, *((int*) variable)= (int) getopt_ll_limit_value((int) value, option, NULL); break; case GET_ENUM: - *((uint*) variable)= (uint) value; + *((ulong*) variable)= (ulong) value; break; case GET_UINT: *((uint*) variable)= (uint) getopt_ull_limit_value((uint) value, option, NULL); @@ -1248,7 +1248,7 @@ void my_print_variables(const struct my_option *options) } break; case GET_ENUM: - printf("%s\n", get_type(optp->typelib, *(uint*) value)); + printf("%s\n", get_type(optp->typelib, *(ulong*) value)); break; case GET_STR: case GET_STR_ALLOC: /* fall through */ diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 6eed702e5ec..a5640f5d80c 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3030,12 +3030,12 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, Allocate temporary space for the value of the tristate. This option will have a limited lifetime and is not used beyond server initialization. - GET_ENUM value is unsigned integer. + GET_ENUM value is a unsigned long integer. */ options[0].value= options[1].value= (uchar **)alloc_root(mem_root, - sizeof(uint)); - *((uint*) options[0].value)= *((uint*) options[1].value)= - (uint) options[0].def_value; + sizeof(ulong)); + *((ulong*) options[0].value)= *((ulong*) options[1].value)= + (ulong) options[0].def_value; options+= 2; diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 402be70efab..2a4fe538c85 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -848,7 +848,7 @@ int ha_example::create(const char *name, TABLE *table_arg, struct st_mysql_storage_engine example_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; -static uint srv_enum_var= 0; +static ulong srv_enum_var= 0; static ulong srv_ulong_var= 0; const char *enum_var_names[]= From 6a447d1047fc4fe3b4ed432461d94e709650d5aa Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Wed, 4 Aug 2010 20:29:13 +0400 Subject: [PATCH 023/136] Cleanup: remove unused declarations from sql_base.h. --- sql/sql_base.cc | 5 ++--- sql/sql_base.h | 27 --------------------------- sql/sql_test.cc | 4 ++-- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e810d5fc091..734f5658e80 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8647,9 +8647,8 @@ bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use, @param db Name of database @param table_name Name of table - @note Unlike remove_table_from_cache() it assumes that table instances - are already not used by any (other) thread (this should be achieved - by using meta-data locks). + @note It assumes that table instances are already not used by any + (other) thread (this should be achieved by using meta-data locks). */ void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, diff --git a/sql/sql_base.h b/sql/sql_base.h index 45f1408e2f5..05401a8cc6d 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -90,28 +90,10 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update, uint lock_flags); bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, Open_table_context *ot_ctx); -bool name_lock_locked_table(THD *thd, TABLE_LIST *tables); -bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list, bool link_in); -TABLE *table_cache_insert_placeholder(THD *thd, const char *key, - uint key_length); -bool lock_table_name_if_not_cached(THD *thd, const char *db, - const char *table_name, TABLE **table); -void detach_merge_children(TABLE *table, bool clear_refs); -bool fix_merge_after_open(TABLE_LIST *old_child_list, TABLE_LIST **old_last, - TABLE_LIST *new_child_list, TABLE_LIST **new_last); -bool reopen_table(TABLE *table); -bool reopen_tables(THD *thd,bool get_locks,bool in_refresh); -void close_data_files_and_morph_locks(THD *thd, const char *db, - const char *table_name); -void close_handle_and_leave_table_as_lock(TABLE *table); bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias, uint db_stat, uint prgflag, uint ha_open_flags, TABLE *outparam, TABLE_LIST *table_desc, MEM_ROOT *mem_root); -bool wait_for_tables(THD *thd); -bool table_is_used(TABLE *table, bool wait_for_name_lock); -TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name); -void abort_locked_tables(THD *thd,const char *db, const char *table_name); bool get_key_map_from_key_list(key_map *map, TABLE *table, List *index_list); @@ -190,12 +172,9 @@ bool setup_tables_and_check_access(THD *thd, ulong want_access); bool wait_while_table_is_used(THD *thd, TABLE *table, enum ha_extra_function function); -void unlink_open_table(THD *thd, TABLE *find, bool unlock); void drop_open_table(THD *thd, TABLE *table, const char *db_name, const char *table_name); -void close_all_tables_for_name(THD *thd, TABLE_SHARE *share, - bool remove_from_locked_tables); void update_non_unique_table_error(TABLE_LIST *update, const char *operation, TABLE_LIST *duplicate); @@ -232,8 +211,6 @@ void close_temporary_table(THD *thd, TABLE *table, bool free_share, void close_temporary(TABLE *table, bool free_share, bool delete_table); bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db, const char *table_name); -void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table); -void remove_db_from_cache(const char *db); bool is_equal(const LEX_STRING *a, const LEX_STRING *b); /* Functions to work with system tables. */ @@ -257,8 +234,6 @@ bool close_cached_connection_tables(THD *thd, bool wait_for_refresh, void close_all_tables_for_name(THD *thd, TABLE_SHARE *share, bool remove_from_locked_tables); OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild); -bool remove_table_from_cache(THD *thd, const char *db, const char *table, - uint flags); void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, const char *db, const char *table_name); bool tdc_open_view(THD *thd, TABLE_LIST *table_list, const char *alias, @@ -271,12 +246,10 @@ TABLE *find_table_for_mdl_upgrade(TABLE *list, const char *db, void mark_tmp_table_for_reuse(TABLE *table); bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists); -extern uint table_cache_count; extern TABLE *unused_tables; extern Item **not_found_item; extern Field *not_found_field; extern Field *view_ref_found; -extern HASH open_cache; extern HASH table_def_cache; /** diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 501c4cf6a94..9d0614f8529 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -118,7 +118,7 @@ static void print_cached_tables(void) printf("unused_links isn't linked properly\n"); return; } - } while (count++ < table_cache_count && (lnk=lnk->next) != start_link); + } while (count++ < cached_open_tables() && (lnk=lnk->next) != start_link); if (lnk != start_link) { printf("Unused_links aren't connected\n"); @@ -416,7 +416,7 @@ static void display_table_locks(void) void *saved_base; DYNAMIC_ARRAY saved_table_locks; - (void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO), table_cache_count + 20,50); + (void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO), cached_open_tables() + 20,50); mysql_mutex_lock(&THR_LOCK_lock); for (list= thr_lock_thread_list; list; list= list_rest(list)) { From f77996950a3d8e0cc025c5c6293e244ac8ae3309 Mon Sep 17 00:00:00 2001 From: Martin Hansson Date: Thu, 5 Aug 2010 12:42:14 +0200 Subject: [PATCH 024/136] Bug#54568: create view cause Assertion failed: 0, file .\item_subselect.cc, line 836 IN quantified predicates are never executed directly. They are rather wrapped inside nodes called IN Optimizers (Item_in_optimizer) which take care of the execution. However, this is not done during query preparation. Unfortunately the LIKE predicate pre-evaluates constant right-hand side arguments even during name resolution. Likely this is meant as an optimization. Fixed by not pre-evaluating LIKE arguments in view prepare mode. --- mysql-test/r/subselect4.result | 21 +++++++++++++++++++++ mysql-test/t/subselect4.test | 16 ++++++++++++++++ sql/item_cmpfunc.cc | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index 482e0045840..fad65d3f000 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -59,3 +59,24 @@ FROM t3 WHERE 1 = 0 GROUP BY 1; (SELECT 1 FROM t1,t2 WHERE t2.b > t3.b) DROP TABLE t1,t2,t3; End of 5.0 tests. +# +# Bug#54568: create view cause Assertion failed: 0, +# file .\item_subselect.cc, line 836 +# +EXPLAIN SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1249 Select 2 was reduced during optimization +DESCRIBE SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1249 Select 2 was reduced during optimization +# None of the below should crash +CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) ); +DROP VIEW v1, v2; +# +# End of 5.1 tests. +# diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index 440eca22828..2c6efdbaac2 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -62,3 +62,19 @@ FROM t3 WHERE 1 = 0 GROUP BY 1; DROP TABLE t1,t2,t3; --echo End of 5.0 tests. + +--echo # +--echo # Bug#54568: create view cause Assertion failed: 0, +--echo # file .\item_subselect.cc, line 836 +--echo # +EXPLAIN SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +DESCRIBE SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +--echo # None of the below should crash +CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) ); +DROP VIEW v1, v2; + + +--echo # +--echo # End of 5.1 tests. +--echo # diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index e91aba63023..fe4616f64d7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4606,7 +4606,7 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref) return TRUE; } - if (escape_item->const_item()) + if (escape_item->const_item() && !thd->lex->view_prepare_mode) { /* If we are on execution stage */ String *escape_str= escape_item->val_str(&cmp.value1); From 82e2ca0181cdf3682c965ee500dc40472d07b41d Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 5 Aug 2010 15:10:24 +0300 Subject: [PATCH 025/136] Addendum to bug #42144 : fixed a wrong type conversation causing plugin tests failures on sparc64. --- sql/sql_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index a5640f5d80c..e0fc88c3068 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3319,7 +3319,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, Set plugin loading policy from option value. First element in the option list is always the option value. */ - plugin_load_policy= (enum_plugin_load_policy)*(uint*)opts[0].value; + plugin_load_policy= (enum_plugin_load_policy)*(ulong*)opts[0].value; } disable_plugin= (plugin_load_policy == PLUGIN_OFF); From ec6ba66af1d42209f4723fa9dcd5278905598b7a Mon Sep 17 00:00:00 2001 From: Inaam Rana Date: Thu, 5 Aug 2010 11:09:05 -0400 Subject: [PATCH 026/136] Currently we do a full validation of AHI whenever check tables is called on any table. This patch fixes this by only doing this full check in debug versions. bug#55716 rb://423 approved by: Marko --- storage/innobase/btr/btr0sea.c | 2 ++ storage/innobase/ha/ha0ha.c | 2 ++ storage/innobase/include/btr0sea.h | 4 ++++ storage/innobase/include/ha0ha.h | 2 ++ 4 files changed, 10 insertions(+) diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c index 06cc48c7c60..fb667bcae82 100644 --- a/storage/innobase/btr/btr0sea.c +++ b/storage/innobase/btr/btr0sea.c @@ -1746,6 +1746,7 @@ function_exit: } } +#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG /********************************************************************//** Validates the search system. @return TRUE if ok */ @@ -1913,3 +1914,4 @@ btr_search_validate(void) return(ok); } +#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ diff --git a/storage/innobase/ha/ha0ha.c b/storage/innobase/ha/ha0ha.c index f9e798012f8..7f11917de0a 100644 --- a/storage/innobase/ha/ha0ha.c +++ b/storage/innobase/ha/ha0ha.c @@ -354,6 +354,7 @@ ha_remove_all_nodes_to_page( #endif } +#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG /*************************************************************//** Validates a given range of the cells in hash table. @return TRUE if ok */ @@ -400,6 +401,7 @@ ha_validate( return(ok); } +#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ /*************************************************************//** Prints info of a hash table. */ diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h index 20a2be7f877..6493689a969 100644 --- a/storage/innobase/include/btr0sea.h +++ b/storage/innobase/include/btr0sea.h @@ -180,6 +180,7 @@ btr_search_update_hash_on_delete( btr_cur_t* cursor);/*!< in: cursor which was positioned on the record to delete using btr_cur_search_..., the record is not yet deleted */ +#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG /********************************************************************//** Validates the search system. @return TRUE if ok */ @@ -187,6 +188,9 @@ UNIV_INTERN ibool btr_search_validate(void); /*======================*/ +#else +# define btr_search_validate() TRUE +#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ /** Flag: has the search system been enabled? Protected by btr_search_latch and btr_search_enabled_mutex. */ diff --git a/storage/innobase/include/ha0ha.h b/storage/innobase/include/ha0ha.h index 1ffbd3440aa..3299000bf3c 100644 --- a/storage/innobase/include/ha0ha.h +++ b/storage/innobase/include/ha0ha.h @@ -186,6 +186,7 @@ ha_remove_all_nodes_to_page( hash_table_t* table, /*!< in: hash table */ ulint fold, /*!< in: fold value */ const page_t* page); /*!< in: buffer page */ +#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG /*************************************************************//** Validates a given range of the cells in hash table. @return TRUE if ok */ @@ -196,6 +197,7 @@ ha_validate( hash_table_t* table, /*!< in: hash table */ ulint start_index, /*!< in: start index */ ulint end_index); /*!< in: end index */ +#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ /*************************************************************//** Prints info of a hash table. */ UNIV_INTERN From ae2c3d62e911ffc51f9b851aeaddeb63298148c7 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Fri, 6 Aug 2010 11:35:17 +0200 Subject: [PATCH 027/136] Bug #55503 MTR fails to filter LEAK SUMMARY from valgrind report of restarted servers Undo workaround as fix is being merged in --- mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test | 2 -- mysql-test/suite/innodb_plugin/t/innodb-autoinc.test | 2 -- 2 files changed, 4 deletions(-) diff --git a/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test b/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test index 5e4cf9dcb4c..99cdac72e2e 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test +++ b/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test @@ -1,8 +1,6 @@ -- source include/have_innodb_plugin.inc # embedded server ignores 'delayed', so skip this -- source include/not_embedded.inc -# remove the next line after bug #55503 is fixed --- source include/not_valgrind.inc let $innodb_file_format_check_orig=`select @@innodb_file_format_check`; diff --git a/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test b/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test index 49394a019d0..5a83ffe3617 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test @@ -1,8 +1,6 @@ -- source include/have_innodb_plugin.inc # embedded server ignores 'delayed', so skip this -- source include/not_embedded.inc -# remove the next line after bug #55503 is fixed --- source include/not_valgrind.inc let $innodb_file_format_check_orig=`select @@innodb_file_format_check`; From a6c00c276ed8e7f2e30301a414533891a8cf2b5d Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Fri, 6 Aug 2010 15:29:37 +0400 Subject: [PATCH 028/136] Part of fix for bug#52044 "FLUSH TABLES WITH READ LOCK and FLUSH TABLES WITH READ LOCK are incompatible" to be pushed as separate patch. Replaced thread state name "Waiting for table", which was used by threads waiting for a metadata lock or table flush, with a set of names which better reflect types of resources being waited for. Also replaced "Table lock" thread state name, which was used by threads waiting on thr_lock.c table level lock, with more elaborate "Waiting for table level lock", to make it more consistent with other thread state names. Updated test cases and their results according to these changes. Fixed sys_vars.query_cache_wlock_invalidate_func test to not to wait for timeout of wait_condition.inc script. --- mysql-test/extra/rpl_tests/rpl_innodb.test | 2 +- .../include/check_no_concurrent_insert.inc | 3 +- mysql-test/include/handler.inc | 58 +++- mysql-test/include/mix1.inc | 2 +- mysql-test/r/query_cache.result | 16 +- mysql-test/r/sp-lock.result | 46 +-- mysql-test/r/sp-threads.result | 2 +- mysql-test/suite/binlog/t/binlog_stm_row.test | 2 +- .../funcs_1/datadict/processlist_val.inc | 12 +- .../funcs_1/r/processlist_val_no_prot.result | 6 +- .../suite/funcs_1/r/processlist_val_ps.result | 6 +- mysql-test/suite/innodb/t/innodb-lock.test | 3 +- mysql-test/suite/rpl/t/rpl_savepoint.test | 2 +- mysql-test/suite/rpl/t/rpl_sp.test | 5 +- mysql-test/suite/rpl/t/rpl_view_multi.test | 4 +- .../sys_vars/r/concurrent_insert_func.result | 4 +- .../query_cache_wlock_invalidate_func.result | 13 +- .../sys_vars/t/concurrent_insert_func.test | 5 +- .../sys_vars/t/delayed_insert_limit_func.test | 4 +- .../t/query_cache_wlock_invalidate_func.test | 14 +- .../t/sql_low_priority_updates_func.test | 14 +- mysql-test/t/delayed.test | 2 +- mysql-test/t/information_schema.test | 3 +- mysql-test/t/innodb_mysql_lock.test | 12 +- mysql-test/t/innodb_mysql_lock2.test | 8 +- mysql-test/t/insert_notembedded.test | 2 +- mysql-test/t/kill.test | 23 +- mysql-test/t/lock_multi.test | 72 ++-- mysql-test/t/lock_sync.test | 4 +- mysql-test/t/mdl_sync.test | 317 ++++++++++++------ mysql-test/t/merge-big.test | 4 +- mysql-test/t/multi_update.test | 4 +- mysql-test/t/query_cache.test | 8 + mysql-test/t/query_cache_28249.test | 6 +- mysql-test/t/schema.test | 8 +- mysql-test/t/sp-lock.test | 106 +++--- mysql-test/t/sp_notembedded.test | 2 +- mysql-test/t/sp_sync.test | 2 +- mysql-test/t/status.test | 3 +- mysql-test/t/trigger_notembedded.test | 2 +- mysql-test/t/view.test | 5 +- mysys/thr_lock.c | 2 +- sql/mdl.cc | 37 +- sql/mdl.h | 16 +- sql/sql_base.cc | 3 +- 45 files changed, 549 insertions(+), 325 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_innodb.test b/mysql-test/extra/rpl_tests/rpl_innodb.test index 4bc1c004ba7..8b9b7e7ff39 100644 --- a/mysql-test/extra/rpl_tests/rpl_innodb.test +++ b/mysql-test/extra/rpl_tests/rpl_innodb.test @@ -153,7 +153,7 @@ connection master; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE info = "RENAME TABLE t1 TO t3, t2 TO t1" and - state = "Waiting for table"; + state = "Waiting for table metadata lock"; --source include/wait_condition.inc COMMIT; diff --git a/mysql-test/include/check_no_concurrent_insert.inc b/mysql-test/include/check_no_concurrent_insert.inc index 57772dddefc..c615ebd02cd 100644 --- a/mysql-test/include/check_no_concurrent_insert.inc +++ b/mysql-test/include/check_no_concurrent_insert.inc @@ -43,7 +43,8 @@ connection default; # of our statement. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "insert into $table (i) values (0)"; + where state = "Waiting for table level lock" and + info = "insert into $table (i) values (0)"; --source include/wait_condition.inc --disable_result_log diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index 98988ab55ba..48cbd17b940 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -557,7 +557,8 @@ connection waiter; --echo connection: waiter let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t0"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t0"; --source include/wait_condition.inc connection default; --echo connection: default @@ -743,7 +744,8 @@ send alter table t1 engine=memory; connection con2; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 engine=memory"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 engine=memory"; --source include/wait_condition.inc connection default; --error ER_ILLEGAL_HA @@ -764,7 +766,8 @@ send alter table t1 engine=memory; connection con2; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 engine=memory"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 engine=memory"; --source include/wait_condition.inc connection default; --echo # Since S metadata lock was already acquired at HANDLER OPEN time @@ -1024,7 +1027,9 @@ connection con1; --echo # --> connection con2 connection con2; --echo # Waitng for 'drop table t1' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t1'; --source include/wait_condition.inc --echo # --> connection default connection default; @@ -1055,7 +1060,9 @@ connection con1; --echo # --> connection con2 connection con2; --echo # Waiting for 'drop table t1' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t1'; --source include/wait_condition.inc --echo # --> connection default connection default; @@ -1097,7 +1104,8 @@ send rename table t0 to t3, t1 to t0, t3 to t1; connection con1; --echo # Waiting for 'rename table ...' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='rename table t0 to t3, t1 to t0, t3 to t1'; + where state='Waiting for table metadata lock' and + info='rename table t0 to t3, t1 to t0, t3 to t1'; --source include/wait_condition.inc --echo # --> connection default connection default; @@ -1137,7 +1145,9 @@ connection con2; --echo # --> connection con1 connection con1; --echo # Waiting for 'drop table t2' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t2'; --source include/wait_condition.inc --echo # --> connection default connection default; @@ -1146,7 +1156,9 @@ send select * from t2; --echo # --> connection con1 connection con1; --echo # Waiting for 'select * from t2' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='select * from t2'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='select * from t2'; unlock tables; --echo # --> connection con2 connection con2; @@ -1190,10 +1202,14 @@ connection default; --echo # --> connection con3 connection con3; --echo # Waiting for 'drop table t1' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t1'; --source include/wait_condition.inc --echo # Waiting for 'drop table t2' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t2'; --source include/wait_condition.inc --echo # Demonstrate that t2 lock was released and t2 was dropped --echo # after ROLLBACK TO SAVEPOINT @@ -1255,10 +1271,14 @@ connection default; --echo # --> connection con3 connection con3; --echo # Waiting for 'drop table t1' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t1'; --source include/wait_condition.inc --echo # Waiting for 'drop table t2' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t2'; --source include/wait_condition.inc --echo # Demonstrate that t2 lock was released and t2 was dropped --echo # after ROLLBACK TO SAVEPOINT @@ -1314,7 +1334,9 @@ drop table t1, t2; --echo # --> connection con2 connection con2; --echo # Waiting for 'drop table t3' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t3'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t3'; --source include/wait_condition.inc --echo # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler --echo # lock. @@ -1348,7 +1370,9 @@ send drop table t2; --echo # --> connection con2 connection con2; --echo # Waiting for 'drop table t2' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t2'; --source include/wait_condition.inc --echo # --> connection con1 connection con1; @@ -1400,7 +1424,8 @@ connection con2; --echo # has read from the table commits. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "lock tables t1 write"; + where state = "Waiting for table metadata lock" and + info = "lock tables t1 write"; --source include/wait_condition.inc --echo # --> connection default @@ -1427,7 +1452,8 @@ connection con1; --echo # Waiting for 'handler t1 read a next' to get blocked... let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "handler t1 read a next"; + where state = "Waiting for table level lock" and + info = "handler t1 read a next"; --source include/wait_condition.inc --echo # The below 'drop table t1' should be able to proceed without diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index fe6abe13892..d1afb8bcf0b 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1583,7 +1583,7 @@ connect (con1, localhost, root,,); --echo # Connection default connection default; let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='TRUNCATE TABLE t1'; + WHERE state='Waiting for table metadata lock' AND info='TRUNCATE TABLE t1'; --source include/wait_condition.inc SELECT * FROM t1 ORDER BY a; ROLLBACK; diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 112a86e0c88..f209e401764 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -701,6 +701,7 @@ drop table t1,t2,t3,t4; set query_cache_wlock_invalidate=1; create table t1 (a int not null); create table t2 (a int not null); +create view v1 as select * from t1; select * from t1; a select * from t2; @@ -713,6 +714,17 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 1 unlock table; +select * from t1; +a +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 2 +lock table v1 write; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 2 +unlock table; +drop view v1; drop table t1,t2; set query_cache_wlock_invalidate=default; CREATE TABLE t1 (id INT PRIMARY KEY); @@ -853,7 +865,7 @@ Variable_name Value Qcache_queries_in_cache 0 show status like "Qcache_inserts"; Variable_name Value -Qcache_inserts 18 +Qcache_inserts 19 show status like "Qcache_hits"; Variable_name Value Qcache_hits 6 @@ -866,7 +878,7 @@ Variable_name Value Qcache_queries_in_cache 1 show status like "Qcache_inserts"; Variable_name Value -Qcache_inserts 19 +Qcache_inserts 20 show status like "Qcache_hits"; Variable_name Value Qcache_hits 7 diff --git a/mysql-test/r/sp-lock.result b/mysql-test/r/sp-lock.result index a7823175b3c..0d3e87f17e2 100644 --- a/mysql-test/r/sp-lock.result +++ b/mysql-test/r/sp-lock.result @@ -148,12 +148,12 @@ f1() # Sending 'drop procedure p1'... drop procedure p1; # --> connection con2 -# Waitng for 'drop procedure t1' to get blocked on MDL lock... +# Waiting for 'drop procedure t1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -174,12 +174,12 @@ f1() # Sending 'create procedure p1'... create procedure p1() begin end; # --> connection con2 -# Waitng for 'create procedure t1' to get blocked on MDL lock... +# Waiting for 'create procedure t1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -200,12 +200,12 @@ f1() # Sending 'alter procedure p1'... alter procedure p1 contains sql; # --> connection con2 -# Waitng for 'alter procedure t1' to get blocked on MDL lock... +# Waiting for 'alter procedure t1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -226,12 +226,12 @@ f1() # Sending 'drop function f1'... drop function f1; # --> connection con2 -# Waitng for 'drop function f1' to get blocked on MDL lock... +# Waiting for 'drop function f1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -252,12 +252,12 @@ f1() # Sending 'create function f1'... create function f1() returns int return 2; # --> connection con2 -# Waitng for 'create function f1' to get blocked on MDL lock... +# Waiting for 'create function f1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -279,12 +279,12 @@ f1() # Sending 'alter function f1'... alter function f1 contains sql; # --> connection con2 -# Waitng for 'alter function f1' to get blocked on MDL lock... +# Waiting for 'alter function f1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -360,7 +360,7 @@ insert into t1 (a) values (1); # Sending 'drop function f1' drop function f1; # --> connection con2 -# Waitng for 'drop function f1' to get blocked on MDL lock... +# Waiting for 'drop function f1' to get blocked on MDL lock... # --> connnection default commit; # --> connection con1 @@ -379,7 +379,7 @@ a # Sending 'drop function f1' drop function f1; # --> connection con2 -# Waitng for 'drop function f1' to get blocked on MDL lock... +# Waiting for 'drop function f1' to get blocked on MDL lock... # --> connnection default commit; # --> connection con1 @@ -403,7 +403,7 @@ a # Sending 'drop procedure p1' drop procedure p1; # --> connection con2 -# Waitng for 'drop procedure p1' to get blocked on MDL lock... +# Waiting for 'drop procedure p1' to get blocked on MDL lock... # --> connnection default commit; # --> connection con1 @@ -424,7 +424,7 @@ insert into t1 (a) values (3); # Sending 'drop function f2' drop function f2; # --> connection con2 -# Waitng for 'drop function f2' to get blocked on MDL lock... +# Waiting for 'drop function f2' to get blocked on MDL lock... # --> connnection default commit; # --> connection con1 @@ -479,11 +479,11 @@ f2() # Sending 'drop function f1'... drop function f1; # --> connection con2 -# Waitng for 'drop function f1' to get blocked on MDL lock... +# Waiting for 'drop function f1' to get blocked on MDL lock... # Sending 'drop function f2'... drop function f2; # --> connection default -# Waitng for 'drop function f2' to get blocked on MDL lock... +# Waiting for 'drop function f2' to get blocked on MDL lock... rollback to savepoint sv; # --> connection con2 # Reaping 'drop function f2'... @@ -537,10 +537,10 @@ f1() # Sending 'alter function f1 ...'... alter function f1 comment "comment"; # --> connection con2 -# Waitng for 'alter function f1 ...' to get blocked on MDL lock... +# Waiting for 'alter function f1 ...' to get blocked on MDL lock... # Sending 'call p1()'... call p1(); -# Waitng for 'call p1()' to get blocked on MDL lock on f1... +# Waiting for 'call p1()' to get blocked on MDL lock on f1... # Let 'alter function f1 ...' go through... commit; # --> connection con1 @@ -573,7 +573,7 @@ f1() # Sending 'alter function f1 ...'... alter function f1 comment "comment"; # --> connection con2 -# Waitng for 'alter function f1 ...' to get blocked on MDL lock... +# Waiting for 'alter function f1 ...' to get blocked on MDL lock... # # We just mention p1() in the body of f2() to make # sure that p1() is prelocked for f2(). @@ -595,7 +595,7 @@ select f2() into @var; end| # Sending 'call p1()'... call p1(); -# Waitng for 'call p1()' to get blocked on MDL lock on f1... +# Waiting for 'call p1()' to get blocked on MDL lock on f1... # Let 'alter function f1 ...' go through... commit; # --> connection con1 @@ -634,7 +634,7 @@ get_lock("30977", 0) # Sending 'select f3()'... select f3(); # --> connection con1 -# Waitng for 'select f3()' to get blocked on the user level lock... +# Waiting for 'select f3()' to get blocked on the user level lock... # Do something to change the cache version. create function f4() returns int return 4; drop function f4; diff --git a/mysql-test/r/sp-threads.result b/mysql-test/r/sp-threads.result index a14d099c673..9b458e25615 100644 --- a/mysql-test/r/sp-threads.result +++ b/mysql-test/r/sp-threads.result @@ -35,7 +35,7 @@ call bug9486(); show processlist; Id User Host db Command Time State Info # root localhost test Sleep # NULL -# root localhost test Query # Waiting for table update t1, t2 set val= 1 where id1=id2 +# root localhost test Query # Waiting for table metadata lock update t1, t2 set val= 1 where id1=id2 # root localhost test Query # NULL show processlist # root localhost test Sleep # NULL unlock tables; diff --git a/mysql-test/suite/binlog/t/binlog_stm_row.test b/mysql-test/suite/binlog/t/binlog_stm_row.test index 6165048c7d4..87758d57725 100644 --- a/mysql-test/suite/binlog/t/binlog_stm_row.test +++ b/mysql-test/suite/binlog/t/binlog_stm_row.test @@ -60,7 +60,7 @@ let $wait_condition= --echo # con1 let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE - state = "Table lock" and info = "INSERT INTO t2 VALUES (3)"; + state = "Waiting for table level lock" and info = "INSERT INTO t2 VALUES (3)"; --source include/wait_condition.inc SELECT RELEASE_LOCK('Bug#34306'); --connection con2 diff --git a/mysql-test/suite/funcs_1/datadict/processlist_val.inc b/mysql-test/suite/funcs_1/datadict/processlist_val.inc index 9c6bd585fde..1327338e761 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_val.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_val.inc @@ -367,14 +367,14 @@ echo ; connection default; echo -# Poll till INFO is no more NULL and State = 'Waiting for table'. +# Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'. ; let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST - WHERE INFO IS NOT NULL AND STATE = 'Waiting for table'; + WHERE INFO IS NOT NULL AND STATE = 'Waiting for table metadata lock'; --source include/wait_condition.inc # -# Expect to see the state 'Waiting for table' for the third connection because the SELECT -# collides with the WRITE TABLE LOCK. +# Expect to see the state 'Waiting for table metadata lock' for the third +# connection because the SELECT collides with the WRITE TABLE LOCK. --replace_column 1 3 6