From e6298f379e642a8e3867c7cb185ae5fa1615b497 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Nov 2003 02:23:13 +0500 Subject: [PATCH 1/6] compile-pentium-gcov: Stop the line wrapping for warnings. it needs for warnings statistic in code coverage BUILD/compile-pentium-gcov: Stop the line wrapping for warnings. it needs for warnings statistic in code coverage --- BUILD/compile-pentium-gcov | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD/compile-pentium-gcov b/BUILD/compile-pentium-gcov index 873d1d0d8e8..0bc7eb2a8fa 100755 --- a/BUILD/compile-pentium-gcov +++ b/BUILD/compile-pentium-gcov @@ -3,7 +3,7 @@ path=`dirname $0` . "$path/SETUP.sh" -extra_flags="$pentium_cflags -O2 -fprofile-arcs -ftest-coverage" +extra_flags="$pentium_cflags -O2 -fprofile-arcs -ftest-coverage -fmessage-length=0 " extra_configs="$pentium_configs $debug_configs --disable-shared $static_link" . "$path/FINISH.sh" From 194dbe1a9a53cd1b3f3614a8764f8c35587f70e0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 15 Nov 2003 19:37:54 -0400 Subject: [PATCH 2/6] fixed bug #1650 "mysql_config --libmysqd-libs misses libwrap" scripts/Makefile.am: added processing of @WRAPLIBS@ in scripts scripts/mysql_config.sh: added @WRAPLIBS@ to embedded_libs option line --- scripts/Makefile.am | 1 + scripts/mysql_config.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.am b/scripts/Makefile.am index e846976eceb..d14d7f38deb 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -114,6 +114,7 @@ SUFFIXES = .sh -e 's!@''LDFLAGS''@!@SAVE_LDFLAGS@!'\ -e 's!@''CLIENT_LIBS''@!@CLIENT_LIBS@!' \ -e 's!@''LIBS''@!@LIBS@!' \ + -e 's!@''WRAPLIBS''@!@WRAPLIBS@!' \ -e 's!@''innodb_system_libs''@!@innodb_system_libs@!' \ -e 's!@''openssl_libs''@!@openssl_libs@!' \ -e 's!@''VERSION''@!@VERSION@!' \ diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 6b543bf4a07..051f3fa9c14 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -92,7 +92,7 @@ libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @LIBS@ @openssl_libs@" libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` cflags="-I$pkgincludedir @CFLAGS@" include="-I$pkgincludedir" -embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @innodb_system_libs@" +embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @WRAPLIBS@ @innodb_system_libs@" embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` # Remove some options that a client doesn't have to care about From b57a1dd22731b436c52bddd2fe4f368429ebb59c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 Nov 2003 12:59:07 +0200 Subject: [PATCH 3/6] Safety fix for alarms on windows. mysys/thr_alarm.c: Safety fix for alarms on windows sql/mini_client.cc: Added comments --- mysys/thr_alarm.c | 3 ++- sql/mini_client.cc | 17 +++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index f51f27b7f51..564d46aca3a 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -638,7 +638,8 @@ bool thr_got_alarm(thr_alarm_t *alrm_ptr) void thr_end_alarm(thr_alarm_t *alrm_ptr) { thr_alarm_t alrm= *alrm_ptr; - if (alrm->crono) + /* alrm may be zero if thr_alarm aborted with an error */ + if (alrm && alrm->crono) { KillTimer(NULL, alrm->crono); alrm->crono = 0; diff --git a/sql/mini_client.cc b/sql/mini_client.cc index c7beeea37b8..cd56081e6a8 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -15,13 +15,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - mini MySQL client to be included into the server to do server to server - commincation by Sasha Pachev + mini MySQL client to be included into the server to do server to server + commincation by Sasha Pachev - Note: all file-global symbols must begin with mc_ , even the static ones, just - in case we decide to make them external at some point - */ + Note: all file-global symbols must begin with mc_ , even the static + ones, just in case we decide to make them external at some point +*/ +#include #define DONT_USE_RAID #if defined(__WIN__) #include @@ -40,7 +41,6 @@ inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __a #define thr_got_alarm(A) 0 #endif -#include #include #include #include @@ -597,6 +597,11 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host); DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port)); thr_alarm_init(&alarmed); + /* + We don't have to check status for thr_alarm as it's not fatal if + we didn't manage to set an alarm. (In this case the socket call + will just block for a while). + */ thr_alarm(&alarmed, net_read_timeout, &alarm_buff); sock = (my_socket) socket(AF_INET,SOCK_STREAM,0); thr_end_alarm(&alarmed); From 348416e930dd37137fc74f17c67d84d3e7274ce9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 Nov 2003 13:06:32 +0200 Subject: [PATCH 4/6] Fix for service names on windows; Now we always put the service name last when we create a service myisam/mi_test2.c: Moved test so that resize_key_cache() is always tested mysys/mf_keycache.c: Fixed comment --- myisam/mi_test2.c | 4 ++-- mysys/mf_keycache.c | 2 +- sql/mysqld.cc | 14 ++++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c index 2a658ca2054..11253f1fdee 100644 --- a/myisam/mi_test2.c +++ b/myisam/mi_test2.c @@ -267,9 +267,9 @@ int main(int argc, char *argv[]) puts("got error from mi_extra(HA_EXTRA_NO_CACHE)"); goto end; } - if (key_cacheing) - resize_key_cache(key_cache_size*2); } + if (key_cacheing) + resize_key_cache(key_cache_size*2); if (!silent) printf("- Delete\n"); diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 4cb3681b8b8..977ca6b11a7 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -669,7 +669,7 @@ static int flush_key_blocks_int(File file, enum flush_type type) Flush all blocks for a specific file to disk SYNOPSIS - flush_all_key_blocks() + flush_key_blocks() file File descriptor type Type of flush operation diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 811984e50b4..5073f8e1c40 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1958,7 +1958,7 @@ extern "C" pthread_handler_decl(handle_shutdown,arg) #endif -const char *load_default_groups[]= { "mysqld","server",MYSQL_BASE_VERSION,0 }; +const char *load_default_groups[]= { "mysqld","server",MYSQL_BASE_VERSION,0,0}; bool open_log(MYSQL_LOG *log, const char *hostname, const char *opt_name, const char *extension, @@ -2561,7 +2561,7 @@ default_service_handling(char **argv, const char *extra_opt) { char path_and_service[FN_REFLEN+FN_REFLEN+32], *pos, *end; - end= path_and_service + sizeof(path_and_service)-1; + end= path_and_service + sizeof(path_and_service)-3; /* We have to quote filename if it contains spaces */ pos= add_quoted_string(path_and_service, file_path, end); @@ -2571,7 +2571,9 @@ default_service_handling(char **argv, *pos++= ' '; pos= add_quoted_string(pos, extra_opt, end); } - *pos= 0; // Ensure end null + /* We must have servicename last */ + *pos++= ' '; + strmake(pos, servicename, (uint) (end+2 - pos)); if (Service.got_service_option(argv, "install")) { @@ -2616,7 +2618,7 @@ int main(int argc, char **argv) if (Service.IsService(argv[1])) { /* start an optional service */ - load_default_groups[0]= argv[1]; + load_default_groups[3]= argv[1]; start_mode= 1; Service.Init(argv[1], mysql_service); return 0; @@ -2624,8 +2626,7 @@ int main(int argc, char **argv) } else if (argc == 3) /* install or remove any optional service */ { - if (!default_service_handling(argv, argv[2], argv[2], file_path, - argv[2])) + if (!default_service_handling(argv, argv[2], argv[2], file_path, "")) return 0; if (Service.IsService(argv[2])) { @@ -2637,6 +2638,7 @@ int main(int argc, char **argv) opt_argc= 2; // Skip service-name opt_argv=argv; start_mode= 1; + load_default_groups[3]= argv[2]; Service.Init(argv[2], mysql_service); return 0; } From 80649ee8746aab02a198285248668cb49ce70f33 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Nov 2003 17:31:17 +0100 Subject: [PATCH 5/6] Fix for BUG#1870 "CHANGE MASTER makes SQL thread restart from coordinates of I/O thread". So, in CHANGE MASTER: when it seems reasonable that the user did not want to discontinue its replication (i.e. when he is not specifying host or port or master_log_file or master_log_pos; this will be documented), set the coordinates of the I/O thread to those of the SQL thread. This way, the SQL thread will see no discontinuity in the relay log (i.e. will skip no events), because the I/O thread will fill the brand new relay log with the events which are just after the position where the SQL thread had stopped (before CHANGE MASTER was issued). And a new test for this bug. mysql-test/r/rpl_loaddata.result: Now, after CHANGE MASTER the coordinates of the I/O thread are the last ones of the SQL thread, so result update. sql/sql_repl.cc: Fix for BUG#1870 "CHANGE MASTER makes SQL thread restart from coordinates of I/O thread". So, in CHANGE MASTER: when it seems reasonable that the user did not want to discontinue its replication (i.e. when he is not specifying host or port or master_log_file or master_log_pos; this will be documented), set the coordinates of the I/O thread to those of the SQL thread. This way, the SQL thread will see no discontinuity in the relay log (i.e. will skip no events), because the I/O thread will fill the brand new relay log with the events which are just after the position where the SQL thread had stopped (before CHANGE MASTER was issued). --- mysql-test/r/rpl_change_master.result | 32 +++++++++++++++++ mysql-test/r/rpl_loaddata.result | 2 +- mysql-test/t/rpl_change_master.test | 26 ++++++++++++++ sql/sql_repl.cc | 49 ++++++++++++++++++++++++--- 4 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 mysql-test/r/rpl_change_master.result create mode 100644 mysql-test/t/rpl_change_master.test diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result new file mode 100644 index 00000000000..be2aec616b0 --- /dev/null +++ b/mysql-test/r/rpl_change_master.result @@ -0,0 +1,32 @@ +slave stop; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +slave start; +select get_lock("a",5); +get_lock("a",5) +1 +create table t1(n int); +insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(2); +stop slave; +select * from t1; +n +1 +show slave status; +Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space +127.0.0.1 root 9306 1 master-bin.001 273 slave-relay-bin.002 255 master-bin.001 No No 0 0 214 314 +change master to master_user='root'; +show slave status; +Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space +127.0.0.1 root 9306 1 master-bin.001 214 slave-relay-bin.001 4 master-bin.001 No No 0 0 214 4 +select release_lock("a"); +release_lock("a") +1 +start slave; +select * from t1; +n +1 +2 +drop table t1; diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index 8b910d0d183..268e383ce69 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -43,7 +43,7 @@ change master to master_user='test'; change master to master_user='root'; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.001 1442 slave-relay-bin.001 4 master-bin.001 No No 0 0 1442 4 +127.0.0.1 root MASTER_PORT 1 master-bin.001 1419 slave-relay-bin.001 4 master-bin.001 No No 0 0 1419 4 set global sql_slave_skip_counter=1; start slave; set sql_log_bin=0; diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test new file mode 100644 index 00000000000..61de22fe57b --- /dev/null +++ b/mysql-test/t/rpl_change_master.test @@ -0,0 +1,26 @@ +source include/master-slave.inc; + +connection slave; +select get_lock("a",5); +connection master; +create table t1(n int); +insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(2); +save_master_pos; +connection slave; +sleep 3; # can't sync_with_master as we should be blocked +stop slave; +select * from t1; +show slave status; +change master to master_user='root'; +show slave status; +# Will restart from after the values(2), which is bug +select release_lock("a"); +start slave; +sync_with_master; +select * from t1; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 10581431c72..c95cdc1b04e 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -853,8 +853,8 @@ void kill_zombie_dump_threads(uint32 slave_server_id) int change_master(THD* thd, MASTER_INFO* mi) { int thread_mask; - const char* errmsg=0; - bool need_relay_log_purge=1; + const char* errmsg= 0; + bool need_relay_log_purge= 1; DBUG_ENTER("change_master"); lock_slave_threads(mi); @@ -928,6 +928,36 @@ int change_master(THD* thd, MASTER_INFO* mi) mi->rli.relay_log_pos=lex_mi->relay_log_pos; } + /* + If user did specify neither host nor port nor any log name nor any log + pos, i.e. he specified only user/password/master_connect_retry, he probably + wants replication to resume from where it had left, i.e. from the + coordinates of the **SQL** thread (imagine the case where the I/O is ahead + of the SQL; restarting from the coordinates of the I/O would lose some + events which is probably unwanted when you are just doing minor changes + like changing master_connect_retry). + A side-effect is that if only the I/O thread was started, this thread may + restart from ''/4 after the CHANGE MASTER. That's a minor problem (it is a + much more unlikely situation than the one we are fixing here). + Note: coordinates of the SQL thread must be read here, before the + 'if (need_relay_log_purge)' block which resets them. + */ + if (!lex_mi->host && !lex_mi->port && + !lex_mi->log_file_name && !lex_mi->pos && + need_relay_log_purge) + { + /* + Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is + not initialized), so we use a max(). + What happens to mi->rli.master_log_pos during the initialization stages + of replication is not 100% clear, so we guard against problems using + max(). + */ + mi->master_log_pos = max(BIN_LOG_HEADER_SIZE, mi->rli.master_log_pos); + strmake(mi->master_log_name,mi->rli.master_log_name, + sizeof(mi->master_log_name)-1); + } + flush_master_info(mi); if (need_relay_log_purge) { @@ -959,10 +989,21 @@ int change_master(THD* thd, MASTER_INFO* mi) } } DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); - /* If changing RELAY_LOG_FILE or RELAY_LOG_POS, this will be nonsense: */ + + /* + Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block, + so restore them to good values. If we left them to ''/0, that would work; + but that would fail in the case of 2 successive CHANGE MASTER (without a + START SLAVE in between): because first one would set the coords in mi to + the good values of those in rli, the set those in rli to ''/0, then + second CHANGE MASTER would set the coords in mi to those of rli, i.e. to + ''/0: we have lost all copies of the original good coordinates. + That's why we always save good coords in rli. + */ mi->rli.master_log_pos = mi->master_log_pos; strmake(mi->rli.master_log_name,mi->master_log_name, - sizeof(mi->rli.master_log_name)-1); + sizeof(mi->rli.master_log_name)-1); + if (!mi->rli.master_log_name[0]) // uninitialized case mi->rli.master_log_pos=0; From c9b59bccb3da2ac065c3aaa883b8d6c0792f7a17 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Nov 2003 16:38:01 +0100 Subject: [PATCH 6/6] - removed some undefined non-weak symbols in libmysqlclient_r by setting LIBS to include @openss_libs@ (BUG#1652) --- libmysql_r/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index e01fc7634a1..ae091d86a88 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -19,7 +19,7 @@ target = libmysqlclient_r.la target_defs = -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ -## LIBS = @LIBS@ +LIBS = @LIBS@ @openssl_libs@ INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include \ -I$(srcdir)/.. -I$(top_srcdir) -I.. $(openssl_includes)