diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 316bf1f3dd03125cc49f8e99bc93ed97e0b56ca8..616ad319880a8765ed5a775ee2a089a802194843 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -93,6 +93,6 @@ slave-bin.002 62 Query 1 168 use test; insert into t1 values (1) slave-bin.002 122 Query 1 228 use test; drop table t1 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.002 276 slave-relay-bin.002 1563 master-bin.002 Yes Yes 0 0 276 1567 +127.0.0.1 root MASTER_PORT 1 master-bin.002 276 slave-relay-bin.002 1563 master-bin.002 Yes Yes 0 0 276 1563 show binlog events in 'slave-bin.005' from 4; Error when executing command SHOW BINLOG EVENTS: Could not find target log diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result index 3224e84fa310185cd5e90ca5097559fb412c33f5..f7e59e55577f4df6d1362536a7637ad5a0590308 100644 --- a/mysql-test/r/rpl_log_pos.result +++ b/mysql-test/r/rpl_log_pos.result @@ -9,7 +9,7 @@ File Position Binlog_do_db Binlog_ignore_db master-bin.001 79 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 79 slave-relay-bin.002 120 master-bin.001 Yes Yes 0 0 79 124 +127.0.0.1 root MASTER_PORT 1 master-bin.001 79 slave-relay-bin.002 120 master-bin.001 Yes Yes 0 0 79 120 slave stop; change master to master_log_pos=73; slave start; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f27ba435729634eb5328eb3f2b531cd9398e3934..4f6f55bce0b3a66ab3fbb78165dfa8495cbe991b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2293,6 +2293,8 @@ int main(int argc, char **argv) if (!opt_noacl) udf_init(); #endif + if (opt_bootstrap) /* If running with bootstrap, do not start replication. */ + opt_skip_slave_start= 1; /* init_slave() must be called after the thread keys are created */ init_slave(); diff --git a/sql/slave.cc b/sql/slave.cc index bc9528ae2c7a3799cd87a782aa5bc472c95f60ad..aa9dd14b1c74b605dadc22d4f89c82719fa23087 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1424,6 +1424,12 @@ static int count_relay_log_space(RELAY_LOG_INFO* rli) if (add_relay_log(rli,&linfo)) DBUG_RETURN(1); } while (!rli->relay_log.find_next_log(&linfo, 1)); + /* + As we have counted everything, including what may have written in a + preceding write, we must reset bytes_written, or we may count some space + twice. + */ + rli->relay_log.reset_bytes_written(); DBUG_RETURN(0); } @@ -3213,8 +3219,25 @@ Log_event* next_event(RELAY_LOG_INFO* rli) hot_log=0; // Using old binary log } } - DBUG_ASSERT(my_b_tell(cur_log) >= BIN_LOG_HEADER_SIZE); - DBUG_ASSERT(my_b_tell(cur_log) == rli->relay_log_pos + rli->pending); +#ifndef DBUG_OFF + { + DBUG_ASSERT(my_b_tell(cur_log) >= BIN_LOG_HEADER_SIZE); + /* The next assertion sometimes (very rarely) fails, let's try to track it */ + char llbuf1[22], llbuf2[22]; + /* Merging man, please be careful with this; in 4.1, the assertion below is + replaced by + DBUG_ASSERT(my_b_tell(cur_log) == rli->event_relay_log_pos); + so you should not merge blindly (fortunately it won't build then), and + instead modify the merged code. Thanks. */ + DBUG_PRINT("info", ("Before assert, my_b_tell(cur_log)=%s \ +rli->relay_log_pos=%s rli->pending=%lu", + llstr(my_b_tell(cur_log),llbuf1), + llstr(rli->relay_log_pos,llbuf2), + rli->pending)); + DBUG_ASSERT(my_b_tell(cur_log) == rli->relay_log_pos + rli->pending); + } +#endif + /* Relay log is always in new format - if the master is 3.23, the I/O thread will convert the format for us diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 225d84f47513068f4da986a3f00edd92b2a3ad09..697b5d8ffd694d70de0055ce10cd2b9b6b7f77f3 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2250,7 +2250,7 @@ int mysql_grant (THD *thd, const char *db, List <LEX_USER> &list, if (!initialized) { send_error(&(thd->net), ER_UNKNOWN_COM_ERROR); /* purecov: tested */ - return 1; /* purecov: tested */ + DBUG_RETURN(1); /* purecov: tested */ } if (lower_case_table_names && db) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index bf4b1eb0c700612f25e24b560ae557b76633dfde..8fb82798a4585fa97df7e731e7f4d3395ae45ccc 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) {