From 0880795793f7c0c468bdb23f65050cc8ffd22d24 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Jun 2003 23:29:49 +0200 Subject: More error messages. This is intended to help debugging; presently I have a support issue with an unclear message which can have N reasons for appearing. This should help us know at which point it failed, and get the errno when my_open was involved (as the reason for the unclear message is often a permission problem). RESET SLAVE resets last_error and last_errno in SHOW SLAVE STATUS (without this, rpl_loaddata.test, which is expected to generate an error in last_error, influenced rpl_log_pos.test). A small test update. Added STOP SLAVE to mysql-test-run to get rid of several stupid error messages which are printed while the master restarts and the slave attempts/manages to connect to it and sends it nonsense binlog requests. mysql-test/mysql-test-run.sh: Before running a test, stop slave threads if they exist (if they don't the script goes on fine). This also works fine with the manager. Before this change, when the master was stopped/restarted (which happened before the slave server was stopped/restarted), the slave threads noticed the stop (so printed an error message in slave.err), then managed to reconnect (to the new master, the one that is running for the _next_ test), and this reconnection had time to produce error messages (because, for example, the binlog the slave thread was asking had been deleted) before the slave server was killed. This change reduces by 10% (40 lines) slave.err in replication tests. mysql-test/r/rpl000018.result: Result update. mysql-test/t/rpl000018.test: This test does "show master logs" so should do "reset master" instead of relying on the previous tests. sql/slave.cc: More error messages. sql/sql_repl.cc: More error messages. RESET SLAVE resets last_error and last_errno in SHOW SLAVE STATUS. --- sql/sql_repl.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ca993c053a1..a651d8002fd 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -159,10 +159,18 @@ File open_binlog(IO_CACHE *log, const char *log_file_name, File file; DBUG_ENTER("open_binlog"); - if ((file = my_open(log_file_name, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0 || - init_io_cache(log, file, IO_SIZE*2, READ_CACHE, 0, 0, + if ((file = my_open(log_file_name, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0) + { + sql_print_error("Failed to open log (\ +file '%s', errno %d)", log_file_name, my_errno); + *errmsg = "Could not open log file"; // This will not be sent + goto err; + } + if (init_io_cache(log, file, IO_SIZE*2, READ_CACHE, 0, 0, MYF(MY_WME | MY_DONT_CHECK_FILESIZE))) { + sql_print_error("Failed to create a cache on log (\ +file '%s')", log_file_name); *errmsg = "Could not open log file"; // This will not be sent goto err; } @@ -743,6 +751,9 @@ int reset_slave(THD *thd, MASTER_INFO* mi) //Clear master's log coordinates (only for good display of SHOW SLAVE STATUS) mi->master_log_name[0]= 0; mi->master_log_pos= BIN_LOG_HEADER_SIZE; + //Clear the errors displayed by SHOW SLAVE STATUS + mi->rli.last_slave_error[0]=0; + mi->rli.last_slave_errno=0; //close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0 end_master_info(mi); //and delete these two files -- cgit v1.2.1 From b518744d16a516c842c4ec0382c8ab44a38aebca Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Jun 2003 23:19:38 +0200 Subject: Changed change_master() to use ER_MASTER_INFO (better display). mysql-test/r/rpl_rotate_logs.result: result update mysql-test/t/rpl_rotate_logs.test: comments and test update with the error code sql/slave.cc: A DBUG_PRINT sql/sql_repl.cc: Use ER_MASTER_INFO instead of custom message and zero error code (which display badly). --- sql/sql_repl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index a651d8002fd..e3af076da1f 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -828,7 +828,7 @@ int change_master(THD* thd, MASTER_INFO* mi) // TODO: see if needs re-write if (init_master_info(mi, master_info_file, relay_log_info_file, 0)) { - send_error(&thd->net, 0, "Could not initialize master info"); + send_error(&thd->net, ER_MASTER_INFO); unlock_slave_threads(mi); DBUG_RETURN(1); } -- cgit v1.2.1 From 5c9b87ce08a1651c6a26509cd2e65a23a20d2cc7 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 21 Jun 2003 18:10:59 +0200 Subject: Always send a fake Rotate event (this is roughly 70 bytes) when starting binlog_dump. This way 3.23.58 slaves will always detect a 4.0.14 master (and stop) immediately. BUG#198. mysql-test/r/rpl_log.result: result update (the relay log now contains a fake Rotate_log_event). mysql-test/r/rpl_log_pos.result: result update (the relay log now contains a fake Rotate_log_event). --- sql/sql_repl.cc | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index e3af076da1f..a3cfe442b0f 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -51,7 +51,7 @@ int check_binlog_magic(IO_CACHE* log, const char** errmsg) } static int fake_rotate_event(NET* net, String* packet, char* log_file_name, - const char**errmsg) + ulonglong position, const char**errmsg) { char header[LOG_EVENT_HEADER_LEN], buf[ROTATE_HEADER_LEN]; memset(header, 0, 4); // when does not matter @@ -69,7 +69,7 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name, packet->append(header, sizeof(header)); /* We need to split the next statement because of problem with cxx */ - int4store(buf,4); // tell slave to skip magic number + int4store(buf,position); int4store(buf+4,0); packet->append(buf, ROTATE_HEADER_LEN); packet->append(p,ident_len); @@ -382,17 +382,30 @@ impossible position"; */ packet->set("\0", 1); - // if we are at the start of the log - if (pos == BIN_LOG_HEADER_SIZE) + /* + Before 4.0.14 we called fake_rotate_event below only if + (pos == BIN_LOG_HEADER_SIZE), because if this is false then the slave + already knows the binlog's name. + Now we always call fake_rotate_event; if the slave already knew the log's + name (ex: CHANGE MASTER TO MASTER_LOG_FILE=...) this is useless but does not + harm much. It is nice for 3.23 (>=.58) slaves which test Rotate events + to see if the master is 4.0 (then they choose to stop because they can't + replicate 4.0); by always calling fake_rotate_event we are sure that 3.23.58 + and newer will detect the problem as soon as replication starts (BUG#198). + Always calling fake_rotate_event makes sending of normal + (=from-binlog) Rotate events a priori unneeded, but it is not so simple: the + 2 Rotate events are not equivalent, the normal one is before the Stop event, + the fake one is after. If we don't send the normal one, then the Stop event + will be interpreted (by existing 4.0 slaves) as "the master stopped", which + is wrong. So for safety, given that we want minimum modification of 4.0, we + send the normal and fake Rotates. + */ + if (fake_rotate_event(net, packet, log_file_name, pos, &errmsg)) { - // tell the client log name with a fake rotate_event - if (fake_rotate_event(net, packet, log_file_name, &errmsg)) - { - my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG; - goto err; - } - packet->set("\0", 1); + my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG; + goto err; } + packet->set("\0", 1); while (!net->error && net->vio != 0 && !thd->killed) { @@ -585,10 +598,12 @@ Increase max_allowed_packet on master"; end_io_cache(&log); (void) my_close(file, MYF(MY_WME)); - // fake Rotate_log event just in case it did not make it to the log - // otherwise the slave make get confused about the offset + /* + Even if the previous log contained a Rotate_log_event, we still fake + one. + */ if ((file=open_binlog(&log, log_file_name, &errmsg)) < 0 || - fake_rotate_event(net, packet, log_file_name, &errmsg)) + fake_rotate_event(net, packet, log_file_name, BIN_LOG_HEADER_SIZE, &errmsg)) { my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG; goto err; -- cgit v1.2.1 From f403da4bf2dba7f21c1076d986c73ef5d1ce2025 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 22 Jun 2003 14:10:46 +0200 Subject: Fixed cleanup_load_tmpdir() which deleted nothing. sql/log_event.cc: - cleanup_load_tmpdir() did not work at all because it forgot to indicate the directory part of the path when calling my_delete(). - A misplaced R_POS_OFFSET (fortunately this was no bug as this constant is 0). sql/sql_repl.cc: - fix fake_rotate_event() for pos>4G (correction of a change I pushed yesterday). --- sql/sql_repl.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index a3cfe442b0f..d0ed1a19d96 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -68,9 +68,12 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name, int4store(header + LOG_POS_OFFSET, 0); packet->append(header, sizeof(header)); - /* We need to split the next statement because of problem with cxx */ - int4store(buf,position); - int4store(buf+4,0); + /* + An old comment said talked about a need for splitting the int8store below + into 2 int4store because of a problem with cxx; I can't understand that as + we already use int8store in Rotatel_log_event::write_data(). + */ + int8store(buf+R_POS_OFFSET,position); packet->append(buf, ROTATE_HEADER_LEN); packet->append(p,ident_len); if (my_net_write(net, (char*)packet->ptr(), packet->length())) -- cgit v1.2.1 From 68524c81feac77d7d0e8dca716738b5b59d98e3f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 23 Jun 2003 20:05:54 +0300 Subject: Simple code cleanup mysql-test/r/innodb.result: Fixed test case after innodb optimize->analyze fix mysys/mf_pack.c: Added comments sql/log_event.cc: Fixed usage of fn_format() sql/slave.cc: Indentation fixes and comments cleanup sql/sql_repl.cc: Comment cleanup --- sql/sql_repl.cc | 5 ----- 1 file changed, 5 deletions(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index d0ed1a19d96..ae9bd8b7727 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -68,11 +68,6 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name, int4store(header + LOG_POS_OFFSET, 0); packet->append(header, sizeof(header)); - /* - An old comment said talked about a need for splitting the int8store below - into 2 int4store because of a problem with cxx; I can't understand that as - we already use int8store in Rotatel_log_event::write_data(). - */ int8store(buf+R_POS_OFFSET,position); packet->append(buf, ROTATE_HEADER_LEN); packet->append(p,ident_len); -- cgit v1.2.1 From 71373afb5c48a27bde3e80a5207a14101d740cc8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Jul 2003 16:56:27 -0400 Subject: fixed bug #672 client/mysqlbinlog.cc: changed format of eof-packet for protocol 4.1 --- sql/sql_repl.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 283dd20a56c..bc833d7e759 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -503,6 +503,11 @@ Increase max_allowed_packet on master"; case LOG_READ_EOF: DBUG_PRINT("wait",("waiting for data in binary log")); + if (thd->server_id==0) + { + pthread_mutex_unlock(log_lock); + goto end; + } if (!thd->killed) { /* Note that the following call unlocks lock_log */ @@ -590,6 +595,7 @@ Increase max_allowed_packet on master"; } } +end: end_io_cache(&log); (void)my_close(file, MYF(MY_WME)); @@ -600,7 +606,7 @@ Increase max_allowed_packet on master"; pthread_mutex_unlock(&LOCK_thread_count); DBUG_VOID_RETURN; - err: +err: thd->proc_info = "waiting to finalize termination"; end_io_cache(&log); /* -- cgit v1.2.1 From 34b4da78bcd05978e0a5dd617fc8950d67dbfc0b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Jul 2003 19:08:31 -0400 Subject: add comment for BUG 672 --- sql/sql_repl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 12228ec3ac8..bf4b1eb0c70 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -522,7 +522,7 @@ Increase max_allowed_packet on master"; case LOG_READ_EOF: DBUG_PRINT("wait",("waiting for data in binary log")); - if (thd->server_id==0) + if (thd->server_id==0) // for mysqlbinlog (mysqlbinlog.server_id==0) { pthread_mutex_unlock(log_lock); goto end; -- cgit v1.2.1 From e22a31f173d52e494baa547657ef090d83abd263 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Jul 2003 01:08:36 +0200 Subject: I committed the same changeset in my tree yesterday, but broke the tree since, so I commit again in a fresh tree. Fix for bug#763 (Relay_log_space too big by 4 bytes), plus comments and DBUG_PRINT, and we don't start replication if --bootstrap. mysql-test/r/rpl_log.result: Result update mysql-test/r/rpl_log_pos.result: Result update sql/mysqld.cc: Don't start replication if in bootstrap mode (bootstrap isn't supposed to have several threads). sql/slave.cc: Fix for bug 763 (Relay_log_space too big by 4 bytes). A DBUG_PRINT. sql/sql_acl.cc: Replaced a return by DBUG_RETURN (happened to find this reading a debug log). sql/sql_repl.cc: A comment. --- sql/sql_repl.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index bf4b1eb0c70..8fb82798a45 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -796,6 +796,25 @@ err: DBUG_RETURN(error); } +/* + + Kill all Binlog_dump threads which previously talked to the same slave + ("same" means with the same server id). Indeed, if the slave stops, if the + Binlog_dump thread is waiting (pthread_cond_wait) for binlog update, then it + will keep existing until a query is written to the binlog. If the master is + idle, then this could last long, and if the slave reconnects, we could have 2 + Binlog_dump threads in SHOW PROCESSLIST, until a query is written to the + binlog. To avoid this, when the slave reconnects and sends COM_BINLOG_DUMP, + the master kills any existing thread with the slave's server id (if this id is + not zero; it will be true for real slaves, but false for mysqlbinlog when it + sends COM_BINLOG_DUMP to get a remote binlog dump). + + SYNOPSIS + kill_zombie_dump_threads() + slave_server_id the slave's server id + +*/ + void kill_zombie_dump_threads(uint32 slave_server_id) { -- cgit v1.2.1 From 2d5d754c8c28ca087f44f479e0fca614789b42e5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Jul 2003 03:18:15 +0300 Subject: Status query on killed mysql connection results in segmentation fault (Bug #738) Added MAX_PASSWORD_LENGTH. This increased master-slave passwords to 32 bytes (Bug #766) Fixed server crash on purge master logs or show master logs when binlog is off. (Bug #733) client/mysql.cc: status query on killed mysql connection results in segmentation fault (Bug #738) configure.in: Portability fix for Unixware include/my_global.h: Removed wrong patch from previous changeset sql/mysql_priv.h: Added MAX_PASSWORD_LENGTH. This increased master-slave passwords to 32 bytes sql/slave.h: Optimized structure sql/sql_repl.cc: Memory overrun safety fixes (not critical) Fixed server crash on purge master logs or show master logs when binlog is off. (Bug #733) sql/sql_repl.h: Fixed to use right define strings/strmake.c: Fixed comment --- sql/sql_repl.cc | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 8fb82798a45..e775a5d712e 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -267,9 +267,13 @@ int purge_master_logs(THD* thd, const char* to_log) { char search_file_name[FN_REFLEN]; const char* errmsg = 0; + int res; + + if (!mysql_bin_log.is_open()) + goto end; mysql_bin_log.make_log_name(search_file_name, to_log); - int res = mysql_bin_log.purge_logs(thd, search_file_name); + res = mysql_bin_log.purge_logs(thd, search_file_name); switch(res) { case 0: break; @@ -292,9 +296,9 @@ binlog purge"; break; send_error(&thd->net, 0, errmsg); return 1; } - else - send_ok(&thd->net); +end: + send_ok(&thd->net); return 0; } @@ -886,7 +890,7 @@ int change_master(THD* thd, MASTER_INFO* mi) if (lex_mi->log_file_name) strmake(mi->master_log_name, lex_mi->log_file_name, - sizeof(mi->master_log_name)); + sizeof(mi->master_log_name)-1); if (lex_mi->pos) { mi->master_log_pos= lex_mi->pos; @@ -895,11 +899,11 @@ int change_master(THD* thd, MASTER_INFO* mi) DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); if (lex_mi->host) - strmake(mi->host, lex_mi->host, sizeof(mi->host)); + strmake(mi->host, lex_mi->host, sizeof(mi->host)-1); if (lex_mi->user) - strmake(mi->user, lex_mi->user, sizeof(mi->user)); + strmake(mi->user, lex_mi->user, sizeof(mi->user)-1); if (lex_mi->password) - strmake(mi->password, lex_mi->password, sizeof(mi->password)); + strmake(mi->password, lex_mi->password, sizeof(mi->password)-1); if (lex_mi->port) mi->port = lex_mi->port; if (lex_mi->connect_retry) @@ -1137,7 +1141,6 @@ int show_binlog_info(THD* thd) int show_binlogs(THD* thd) { - const char *errmsg; IO_CACHE *index_file; char fname[FN_REFLEN]; NET* net = &thd->net; @@ -1148,8 +1151,8 @@ int show_binlogs(THD* thd) if (!mysql_bin_log.is_open()) { //TODO: Replace with ER() error message - errmsg= "You are not using binary logging"; - goto err_with_msg; + send_error(net, 0, "You are not using binary logging"); + return 1; } field_list.push_back(new Item_empty_string("Log_name", 255)); @@ -1174,8 +1177,6 @@ int show_binlogs(THD* thd) send_eof(net); return 0; -err_with_msg: - send_error(net, 0, errmsg); err: mysql_bin_log.unlock_index(); return 1; -- cgit v1.2.1 From d974959b4f5a965d217597c4d979fee4a7a70506 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Jul 2003 14:26:44 +0200 Subject: Fix for BUG#791: a safer way of initing the mutexes in MYSQL_LOG. is_open() is now always thread-safe. See each file for details. sql/handler.cc: is_open() with locks sql/item_func.cc: is_open() with locks sql/log.cc: No more 'inited'. We now always use is_open() in a thread-safe manner. This simplifies some functions (no more need to test is_open() twice). sql/log_event.cc: is_open() with locks sql/mysqld.cc: Init mutexes for the global MYSQL_LOG objects. We care about no_rotate, because we can't do it in open() anymore (because we don't have 'inited' anymore). sql/repl_failsafe.cc: is_open() with locks sql/slave.cc: init pthread objects (mutexes, conds) in the constructor of st_relay_log_info. Some better locking in rotate_relay_log(). sql/sql_base.cc: is_open() with locks sql/sql_class.h: Before, we inited LOCK_log in MYSQL_LOG::open(), so in other places of the code when we were never 100% sure that it had been inited. For example, if the server was running without --log-bin, ::open() was not called so the mutex was not inited. We could detect it with !inited, but not safely as 'inited' was not protected by any mutex. So now: we *always* init the LOCK_log mutex, even if the log is not used. We can't init the mutex in MYSQL_LOG's constructor, because for global objects like mysql_bin_log, mysql_log etc, the constructor is called before MY_INIT(), but safe_mutex depends on MY_INIT(). So we have a new function MYSQL_LOG::init_pthread_objects which we call in main(), after MY_INIT(). For the relay log, we call this function in the constructor of st_relay_log_info, which is called before any function tries to use the relay log (the relay log is always invoked as rli.relay_log). So now we should be safe in all cases and we don't need 'inited'. sql/sql_db.cc: is_open() with locks sql/sql_delete.cc: is_open() with locks sql/sql_insert.cc: is_open() with locks sql/sql_load.cc: is_open() with locks sql/sql_parse.cc: is_open() with locks sql/sql_rename.cc: is_open() with locks sql/sql_repl.cc: is_open() with locks sql/sql_table.cc: is_open() with locks sql/sql_update.cc: is_open() with locks --- sql/sql_repl.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index e775a5d712e..a671facdc08 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -269,7 +269,7 @@ int purge_master_logs(THD* thd, const char* to_log) const char* errmsg = 0; int res; - if (!mysql_bin_log.is_open()) + if (!mysql_bin_log.is_open(1)) goto end; mysql_bin_log.make_log_name(search_file_name, to_log); @@ -335,7 +335,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, } #endif - if (!mysql_bin_log.is_open()) + if (!mysql_bin_log.is_open(1)) { errmsg = "Binary log is not open"; my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG; @@ -972,7 +972,7 @@ int change_master(THD* thd, MASTER_INFO* mi) int reset_master(THD* thd) { - if (!mysql_bin_log.is_open()) + if (!mysql_bin_log.is_open(1)) { my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG)); return 1; @@ -1010,7 +1010,7 @@ int show_binlog_events(THD* thd) if (send_fields(thd, field_list, 1)) DBUG_RETURN(-1); - if (mysql_bin_log.is_open()) + if (mysql_bin_log.is_open(1)) { LEX_MASTER_INFO *lex_mi = &thd->lex.mi; ha_rows event_count, limit_start, limit_end; @@ -1110,7 +1110,7 @@ int show_binlog_info(THD* thd) String* packet = &thd->packet; packet->length(0); - if (mysql_bin_log.is_open()) + if (mysql_bin_log.is_open(1)) { LOG_INFO li; mysql_bin_log.get_current_log(&li); @@ -1128,7 +1128,7 @@ int show_binlog_info(THD* thd) /* - Send a lost of all binary logs to client + Send a list of all binary logs to client SYNOPSIS show_binlogs() @@ -1148,7 +1148,7 @@ int show_binlogs(THD* thd) String *packet = &thd->packet; uint length; - if (!mysql_bin_log.is_open()) + if (!mysql_bin_log.is_open(1)) { //TODO: Replace with ER() error message send_error(net, 0, "You are not using binary logging"); -- cgit v1.2.1 From 9480ec828948191b4a924c36a5b183aab74ef27b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Jul 2003 16:04:42 +0200 Subject: Cleaning after removing LOG_INFO_PURGE_NO_ROTATE. sql/sql_repl.cc: In my previous change I removed 'no_rotate' from MYSQL_LOG, so this made LOG_INFO_PURGE_NO_ROTATE useless (an error code which was never returned), so I remove it of the 'switch'. --- sql/sql_repl.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index a671facdc08..6f0ee69413d 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -282,8 +282,6 @@ int purge_master_logs(THD* thd, const char* to_log) case LOG_INFO_INVALID: errmsg = "Server configuration does not permit \ binlog purge"; break; case LOG_INFO_SEEK: errmsg = "Failed on fseek()"; break; - case LOG_INFO_PURGE_NO_ROTATE: errmsg = "Cannot purge unrotatable log"; - break; case LOG_INFO_MEM: errmsg = "Out of memory"; break; case LOG_INFO_FATAL: errmsg = "Fatal error during purge"; break; case LOG_INFO_IN_USE: errmsg = "A purgeable log is in use, will not purge"; -- cgit v1.2.1 From e1a30696034b70e3bf78036aa75a6e8389ebb2c4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Jul 2003 10:12:05 +0300 Subject: Safety and speedup fixes: Changed is_open() to work as before. Added back inited argument to LOG mysql-test/r/rpl_flush_log_loop.result: Fixed results (probably bug in previous rpatch) sql/handler.cc: Changed is_open() to work as before sql/item_func.cc: Changed is_open() to work as before sql/log.cc: Part revert of previous patch. The reason for adding back 'inited' is that is that we can't be 100 % sure that init_pthread_objects() is called before mysqld dies (for example on windows) I removed mutex lock handling in is_open() as the new code didn't have ANY affect except beeing slower. Added back checking of is_open() to some functions as we don't want to do a mutex lock when we are not using logging. Indentation/comment fixes sql/log_event.cc: Changed is_open() to work as before sql/repl_failsafe.cc: Changed is_open() to work as before sql/sql_base.cc: Changed is_open() to work as before sql/sql_class.h: Changed is_open() to work as before. Added back 'inited' variable sql/sql_db.cc: Changed is_open() to work as before sql/sql_delete.cc: Changed is_open() to work as before sql/sql_insert.cc: Changed is_open() to work as before sql/sql_load.cc: Changed is_open() to work as before sql/sql_parse.cc: Changed is_open() to work as before sql/sql_rename.cc: Changed is_open() to work as before sql/sql_repl.cc: Changed is_open() to work as before sql/sql_table.cc: Changed is_open() to work as before sql/sql_update.cc: Changed is_open() to work as before --- sql/sql_repl.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 6f0ee69413d..13b22d6a221 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -269,7 +269,7 @@ int purge_master_logs(THD* thd, const char* to_log) const char* errmsg = 0; int res; - if (!mysql_bin_log.is_open(1)) + if (!mysql_bin_log.is_open()) goto end; mysql_bin_log.make_log_name(search_file_name, to_log); @@ -333,7 +333,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, } #endif - if (!mysql_bin_log.is_open(1)) + if (!mysql_bin_log.is_open()) { errmsg = "Binary log is not open"; my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG; @@ -970,7 +970,7 @@ int change_master(THD* thd, MASTER_INFO* mi) int reset_master(THD* thd) { - if (!mysql_bin_log.is_open(1)) + if (!mysql_bin_log.is_open()) { my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG)); return 1; @@ -1008,7 +1008,7 @@ int show_binlog_events(THD* thd) if (send_fields(thd, field_list, 1)) DBUG_RETURN(-1); - if (mysql_bin_log.is_open(1)) + if (mysql_bin_log.is_open()) { LEX_MASTER_INFO *lex_mi = &thd->lex.mi; ha_rows event_count, limit_start, limit_end; @@ -1108,7 +1108,7 @@ int show_binlog_info(THD* thd) String* packet = &thd->packet; packet->length(0); - if (mysql_bin_log.is_open(1)) + if (mysql_bin_log.is_open()) { LOG_INFO li; mysql_bin_log.get_current_log(&li); @@ -1146,7 +1146,7 @@ int show_binlogs(THD* thd) String *packet = &thd->packet; uint length; - if (!mysql_bin_log.is_open(1)) + if (!mysql_bin_log.is_open()) { //TODO: Replace with ER() error message send_error(net, 0, "You are not using binary logging"); -- cgit v1.2.1 From 14d9a2e5e700afc0562b21fbc97412092a81656f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Jul 2003 22:29:09 +0200 Subject: Fix for BUG#858 "CHANGE MASTER forgets to update relay-log.info"; just a flush_relay_log_info() at the end of CHANGE MASTER (there was already flush_master_info()). sql/sql_repl.cc: Comments. Flush relay-log.info after CHANGE MASTER, or the changes to the relay log parameters (relay log name and position, and the corresponding master's binlog name and position) will be lost if the slave mysqld is shutdown immediately after the CHANGE MASTER (without the slave threads being started). --- sql/sql_repl.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 13b22d6a221..faa18b146bb 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -878,9 +878,14 @@ int change_master(THD* thd, MASTER_INFO* mi) and we have the hold on the run locks which will keep all threads that could possibly modify the data structures from running */ + + /* + If the user specified host or port without binlog or position, + reset binlog's name to FIRST and position to 4. + */ + if ((lex_mi->host || lex_mi->port) && !lex_mi->log_file_name && !lex_mi->pos) { - // if we change host or port, we must reset the postion mi->master_log_name[0] = 0; mi->master_log_pos= BIN_LOG_HEADER_SIZE; mi->rli.pending = 0; @@ -950,15 +955,24 @@ int change_master(THD* thd, MASTER_INFO* mi) DBUG_RETURN(1); } } - mi->rli.master_log_pos = mi->master_log_pos; 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: */ + 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); if (!mi->rli.master_log_name[0]) // uninitialized case mi->rli.master_log_pos=0; pthread_mutex_lock(&mi->rli.data_lock); - mi->rli.abort_pos_wait++; + mi->rli.abort_pos_wait++; /* for MASTER_POS_WAIT() to abort */ + /* + If we don't write new coordinates to disk now, then old will remain in + relay-log.info until START SLAVE is issued; but if mysqld is shutdown + before START SLAVE, then old will remain in relay-log.info, and will be the + in-memory value at restart (thus causing errors, as the old relay log does + not exist anymore). + */ + flush_relay_log_info(&mi->rli); pthread_cond_broadcast(&mi->data_cond); pthread_mutex_unlock(&mi->rli.data_lock); -- cgit v1.2.1 From d8df84aa438a2dfe4a90d7889713c2ccd52cca1d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Aug 2003 10:59:44 +0200 Subject: 2 bugfixes: - Bug #985: "Between RESET SLAVE and START SLAVE, SHOW SLAVE STATUS is wrong." Now RESET SLAVE puts correct info in mi->host etc. A new test rpl_reset_slave for that. - Bug #986: "CHANGE MASTER & START SLAVE do not reset error columns in SHOW SLAVE STATUS". Now these reset the errors. mysql-test/r/rpl_loaddata.result: result update. mysql-test/t/rpl_loaddata.test: Test that RESET SLAVE, START SLAVE and CHANGE MASTER all reset Last_slave_error and Last_slave_errno (columns of SHOW SLAVE STATUS). We do it in this test because that's one of tests which have an intentional query error on the slave. sql/slave.cc: As we need TWICE the code to copy command-line options (--master-host etc) to mi (we already had it in init_master_info, but we also need it in RESET SLAVE to fix bug#985), I make a function of this code. And a function to reset Last_slave_error and Last_slave_errno (we need it in CHANGE MASTER, RESET SLAVE, and at the start of the SQL thread). sql/slave.h: declarations for new functions. sql/sql_repl.cc: copy --master-host etc to mi in RESET SLAVE, so that SHOW SLAVE STATUS shows correct information. --- sql/sql_repl.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'sql/sql_repl.cc') diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index faa18b146bb..cdd0bca4a0e 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -769,12 +769,15 @@ int reset_slave(THD *thd, MASTER_INFO* mi) &errmsg))) goto err; - //Clear master's log coordinates (only for good display of SHOW SLAVE STATUS) - mi->master_log_name[0]= 0; - mi->master_log_pos= BIN_LOG_HEADER_SIZE; - //Clear the errors displayed by SHOW SLAVE STATUS - mi->rli.last_slave_error[0]=0; - mi->rli.last_slave_errno=0; + /* + Clear master's log coordinates and reset host/user/etc to the values + specified in mysqld's options (only for good display of SHOW SLAVE STATUS; + next init_master_info() (in start_slave() for example) would have set them + the same way; but here this is for the case where the user does SHOW SLAVE + STATUS; before doing START SLAVE; + */ + init_master_info_with_options(mi); + clear_last_slave_error(&mi->rli); //close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0 end_master_info(mi); //and delete these two files @@ -965,6 +968,8 @@ int change_master(THD* thd, MASTER_INFO* mi) pthread_mutex_lock(&mi->rli.data_lock); mi->rli.abort_pos_wait++; /* for MASTER_POS_WAIT() to abort */ + /* Clear the error, for a clean start. */ + clear_last_slave_error(&mi->rli); /* If we don't write new coordinates to disk now, then old will remain in relay-log.info until START SLAVE is issued; but if mysqld is shutdown -- cgit v1.2.1