From 6ef4dc29c3cbd131c42b852c2526312a61729be0 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 9 Sep 2003 19:23:01 +0200 Subject: [PATCH 1/6] fixed: thread lock-up on a FLASH TABLE when another thread has an open handler Bug#1204 --- sql/sql_handler.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index b0d8b18dd17..a19fcdc2d73 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -34,7 +34,7 @@ The second is to be freeed only on thread end. mysql_ha_open should then do { handler_items=concat(handler_items, free_list); free_list=0; } - But !!! do_cammand calls free_root at the end of every query and frees up + But !!! do_command calls free_root at the end of every query and frees up all the sql_alloc'ed memory. It's harder to work around... */ @@ -73,7 +73,11 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok) if (*ptr) { VOID(pthread_mutex_lock(&LOCK_open)); - close_thread_table(thd, ptr); + if (close_thread_table(thd, ptr)) + { + /* Tell threads waiting for refresh that something has happened */ + VOID(pthread_cond_broadcast(&COND_refresh)); + } VOID(pthread_mutex_unlock(&LOCK_open)); } else @@ -90,8 +94,11 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok) int mysql_ha_closeall(THD *thd, TABLE_LIST *tables) { TABLE **ptr=find_table_ptr_by_name(thd, tables->db, tables->real_name, 0); - if (*ptr) - close_thread_table(thd, ptr); + if (*ptr && close_thread_table(thd, ptr)) + { + /* Tell threads waiting for refresh that something has happened */ + VOID(pthread_cond_broadcast(&COND_refresh)); + } return 0; } From ebfa41086dc91a953c83ea993d3e4f69f9904d7d Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 11 Sep 2003 13:36:08 +0200 Subject: [PATCH 2/6] - backported compatibility fix for extra/resolveip.c from 4.0 to be able to compile on HP-UX 10.20 (which does not have in_add_t). --- extra/resolveip.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extra/resolveip.c b/extra/resolveip.c index 764844bf622..133f6ddeb07 100644 --- a/extra/resolveip.c +++ b/extra/resolveip.c @@ -36,6 +36,10 @@ extern int h_errno; #endif +#ifndef HAVE_IN_ADDR_T +#define in_addr_t u_long +#endif + static int silent=0; From 40a88045cb4e60028f9e548deeb89b1d412adf3c Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Fri, 12 Sep 2003 17:26:48 +0200 Subject: [PATCH 3/6] Quick backport of the following bugfix from MySQL 4.0.14. DO NOT COPY THIS CODE TO 4.0. The bugfix is better in 4.0, but here in 3.23 we don't want to add a new error code so we just use ER_EMPTY_QUERY. Bug was: "If a query was ignored on the slave (because of @code{replicate-ignore-table} and other similar rules), the slave still checked if the query got the same error code (0, no error) as on the master. So if the master had an error on the query (for example, ``Duplicate entry'' in a multiple-row insert), then the slave stopped and warned that the error codes didn't match. (Bug #797)" --- sql/slave.cc | 3 ++- sql/sql_parse.cc | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sql/slave.cc b/sql/slave.cc index 50cb224d83d..a51db52cc7f 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -923,7 +923,8 @@ point. If you are sure that your master is ok, run this query manually on the\ inline int ignored_error_code(int err_code) { - return use_slave_mask && bitmap_is_set(&slave_error_mask, err_code); + return ((err_code == ER_EMPTY_QUERY) || + (use_slave_mask && bitmap_is_set(&slave_error_mask, err_code))); } static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 805063cb6dc..81233c038a1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1085,7 +1085,19 @@ mysql_execute_command(void) // rules have been given and the table list says the query should not be // replicated if(table_rules_on && tables && !tables_ok(thd,tables)) + { + /* + We consider the query as empty and warn the slave thread which will + consider ER_EMPTY_QUERY as an ignorable error. Note that this has a + drawback: if the event is corrupted it could contain an empty query; + then the slave thread will silently ignore it instead of warning. But + such corruption is unlikely enough. + In MySQL 4.0 we do it more properly using a new error code + (ER_SLAVE_IGNORED_TABLE). + */ + my_error(ER_EMPTY_QUERY, MYF(0)); DBUG_VOID_RETURN; + } // this is a workaround to deal with the shortcoming // in 3.23.44-3.23.46 masters // in RELEASE_LOCK() logging. We re-write SELECT RELEASE_LOCK() as From 1394684e12b85ed9808115b9fe3a80c4d84c64ef Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Sat, 27 Sep 2003 18:54:22 +0200 Subject: [PATCH 4/6] make mysqld to respect socket/port options of mysqld_safe command line and [mysqld_safe] section in my.cnf, even if they are also specified in [mysql] section. --- scripts/mysqld_safe.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 1c056e963cb..ece4ba098f4 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -51,9 +51,9 @@ parse_arguments() { ;; # these two might have been set in a [mysqld_safe] section of my.cnf - # they get passed via environment variables to mysqld_safe - --socket=*) MYSQL_UNIX_PORT=`echo "$arg" | sed -e "s;--socket=;;"` ;; - --port=*) MYSQL_TCP_PORT=`echo "$arg" | sed -e "s;--port=;;"` ;; + # they are added to mysqld command line to override settings from my.cnf + --socket=*) mysql_unix_port=`echo "$arg" | sed -e "s;--socket=;;"` ;; + --port=*) mysql_tcp_port=`echo "$arg" | sed -e "s;--port=;;"` ;; # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])! --ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;; @@ -114,8 +114,7 @@ else ledir=@libexecdir@ fi -MYSQL_UNIX_PORT=${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@} -MYSQL_TCP_PORT=${MYSQL_TCP_PORT:-@MYSQL_TCP_PORT@} +safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}} user=@MYSQLD_USER@ niceness=0 @@ -171,9 +170,14 @@ else fi test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err -export MYSQL_UNIX_PORT -export MYSQL_TCP_PORT - +if test -n "$mysql_unix_port" +then + args="--socket=$mysql_unix_port $args" +fi +if test -n "$mysql_tcp_port" +then + args="--port=$mysql_tcp_port $args" +fi if test $niceness -eq 0 then @@ -296,7 +300,7 @@ echo "Starting $MYSQLD daemon with databases from $DATADIR" echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log while true do - rm -f $MYSQL_UNIX_PORT $pid_file # Some extra safety + rm -f $safe_mysql_unix_port $pid_file # Some extra safety if test -z "$args" then $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1 From 9e68df23333ecb21ed776fcb983e2f98ca2d1721 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Sun, 28 Sep 2003 21:35:47 +0200 Subject: [PATCH 5/6] typo fixed (bug #1390 - incorrect mysql_config output) --- scripts/mysql_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 3cc5b3a5016..f7c4b4ff381 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -62,7 +62,7 @@ get_full_path () { case $1 in /*) echo "$1";; - ./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/./;/;' ;; + ./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/\./;/;' ;; *) which $1 ;; esac } From 8c7c4de0b4a7bcffe27e4549ed4dd242d71056df Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Mon, 29 Sep 2003 11:21:17 +0200 Subject: [PATCH 6/6] enum options renamed to avoid possible name conflicts --- client/client_priv.h | 2 +- myisam/myisamchk.c | 2 +- sql/mysqld.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/client_priv.h b/client/client_priv.h index 85c99951532..5029f219494 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -26,7 +26,7 @@ /* We have to define 'enum options' identical in all files to keep OS2 happy */ -enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET, +enum options_client { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET, OPT_PAGER, OPT_NOPAGER, OPT_TEE, OPT_NOTEE, OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS, OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE, diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 83edadf153f..b7627fc59fd 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -144,7 +144,7 @@ int main(int argc, char **argv) #endif } /* main */ -enum options { +enum options_mc { OPT_CHARSETS_DIR=256, OPT_SET_CHARSET,OPT_START_CHECK_POS, OPT_CORRECT_CHECKSUM, OPT_KEY_BUFFER_SIZE, OPT_MYISAM_BLOCK_SIZE, OPT_READ_BUFFER_SIZE, OPT_WRITE_BUFFER_SIZE, OPT_SORT_BUFFER_SIZE, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index bcf115feccc..cc870ed3e36 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3130,7 +3130,7 @@ extern "C" pthread_handler_decl(handle_connections_namedpipes,arg) ** handle start options ******************************************************************************/ -enum options { +enum options_mysqld { OPT_ISAM_LOG=256, OPT_SKIP_NEW, OPT_SKIP_GRANT, OPT_SKIP_LOCK, OPT_ENABLE_LOCK, OPT_USE_LOCKING,