Commit e22a31f1 authored by unknown's avatar unknown

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.
parent c0eb4485
...@@ -93,6 +93,6 @@ slave-bin.002 62 Query 1 168 use test; insert into t1 values (1) ...@@ -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 slave-bin.002 122 Query 1 228 use test; drop table t1
show slave status; 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 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; show binlog events in 'slave-bin.005' from 4;
Error when executing command SHOW BINLOG EVENTS: Could not find target log Error when executing command SHOW BINLOG EVENTS: Could not find target log
...@@ -9,7 +9,7 @@ File Position Binlog_do_db Binlog_ignore_db ...@@ -9,7 +9,7 @@ File Position Binlog_do_db Binlog_ignore_db
master-bin.001 79 master-bin.001 79
show slave status; 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 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; slave stop;
change master to master_log_pos=73; change master to master_log_pos=73;
slave start; slave start;
......
...@@ -2293,6 +2293,8 @@ int main(int argc, char **argv) ...@@ -2293,6 +2293,8 @@ int main(int argc, char **argv)
if (!opt_noacl) if (!opt_noacl)
udf_init(); udf_init();
#endif #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() must be called after the thread keys are created */
init_slave(); init_slave();
......
...@@ -1424,6 +1424,12 @@ static int count_relay_log_space(RELAY_LOG_INFO* rli) ...@@ -1424,6 +1424,12 @@ static int count_relay_log_space(RELAY_LOG_INFO* rli)
if (add_relay_log(rli,&linfo)) if (add_relay_log(rli,&linfo))
DBUG_RETURN(1); DBUG_RETURN(1);
} while (!rli->relay_log.find_next_log(&linfo, 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); DBUG_RETURN(0);
} }
...@@ -3213,8 +3219,25 @@ Log_event* next_event(RELAY_LOG_INFO* rli) ...@@ -3213,8 +3219,25 @@ Log_event* next_event(RELAY_LOG_INFO* rli)
hot_log=0; // Using old binary log hot_log=0; // Using old binary log
} }
} }
#ifndef DBUG_OFF
{
DBUG_ASSERT(my_b_tell(cur_log) >= BIN_LOG_HEADER_SIZE); 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); 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 Relay log is always in new format - if the master is 3.23, the
I/O thread will convert the format for us I/O thread will convert the format for us
......
...@@ -2250,7 +2250,7 @@ int mysql_grant (THD *thd, const char *db, List <LEX_USER> &list, ...@@ -2250,7 +2250,7 @@ int mysql_grant (THD *thd, const char *db, List <LEX_USER> &list,
if (!initialized) if (!initialized)
{ {
send_error(&(thd->net), ER_UNKNOWN_COM_ERROR); /* purecov: tested */ 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) if (lower_case_table_names && db)
......
...@@ -796,6 +796,25 @@ err: ...@@ -796,6 +796,25 @@ err:
DBUG_RETURN(error); 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) void kill_zombie_dump_threads(uint32 slave_server_id)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment