Commit 9c435716 authored by unknown's avatar unknown

replication updates and bugfixes. Still not perfect - there is some strange

memory corruption I can only repeat on one system.


mysql-test/r/multi_update.result:
  extended test trying to find why the old one was failing
mysql-test/r/rpl000015.result:
  result update
mysql-test/t/multi_update.test:
  updated test to do more intermediate result checks
mysql-test/t/rpl000014.test:
  cosmetic change
mysql-test/t/rpl000015-slave-master-info.opt:
  reduce connect retry trying to simulate a bug
mysql-test/t/rpl000015.test:
  cosmetic change
sql/lex.h:
  added RELAY_LOG_FILE and RELAY_LOG_POS to CHANGE MASTER TO
sql/log.cc:
  fixed replication bug
sql/log_event.cc:
  properly ignore replication errors according to error mask
sql/mysqld.cc:
  handle SIGFPE in the coredump handler
sql/slave.cc:
  do not kick slave if it has already exited and freed the structures
sql/sql_lex.cc:
  fixed initialization bug in CHANGE MASTER TO
sql/sql_lex.h:
  CHANGE MASTER TO .. RELAY_LOG_FILE=,RELAY_LOG_POS=
sql/sql_repl.cc:
  CHANGE MASTER TO .. RELAY_LOG_FILE=,RELAY_LOG_POS=
sql/sql_yacc.yy:
  CHANGE MASTER TO .. RELAY_LOG_FILE=,RELAY_LOG_POS=
parent b8a9ea66
...@@ -2,7 +2,34 @@ drop table if exists t1,t2,t3; ...@@ -2,7 +2,34 @@ drop table if exists t1,t2,t3;
create table t1(id1 int not null auto_increment primary key, t char(12)); create table t1(id1 int not null auto_increment primary key, t char(12));
create table t2(id2 int not null, t char(12)); create table t2(id2 int not null, t char(12));
create table t3(id3 int not null, t char(12), index(id3)); create table t3(id3 int not null, t char(12), index(id3));
select count(*) from t1 where id1 > 95;
count(*)
5
select count(*) from t2 where id2 > 95;
count(*)
25
select count(*) from t3 where id3 > 95;
count(*)
250
update t1,t2,t3 set t1.t="aaa", t2.t="bbb", t3.t="cc" where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 90; update t1,t2,t3 set t1.t="aaa", t2.t="bbb", t3.t="cc" where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 90;
select count(*) from t1 where t = "aaa";
count(*)
10
select count(*) from t1 where id1 > 90;
count(*)
10
select count(*) from t2 where t = "bbb";
count(*)
10
select count(*) from t2 where id2 > 90;
count(*)
50
select count(*) from t3 where t = "cc";
count(*)
500
select count(*) from t3 where id3 > 90;
count(*)
500
delete t1.*, t2.*, t3.* from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 95; delete t1.*, t2.*, t3.* from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 95;
check table t1, t2, t3; check table t1, t2, t3;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
......
...@@ -9,16 +9,16 @@ Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Lo ...@@ -9,16 +9,16 @@ Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Lo
change master to master_host='127.0.0.1'; change master to master_host='127.0.0.1';
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 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
127.0.0.1 test MASTER_PORT 60 4 slave-relay-bin.001 4 No No 0 0 0 127.0.0.1 test MASTER_PORT 7 4 slave-relay-bin.001 4 No No 0 0 0
change master to master_host='127.0.0.1',master_user='root', change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=MASTER_PORT; master_password='',master_port=MASTER_PORT;
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 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
127.0.0.1 root MASTER_PORT 60 4 slave-relay-bin.001 4 No No 0 0 0 127.0.0.1 root MASTER_PORT 7 4 slave-relay-bin.001 4 No No 0 0 0
slave start; slave start;
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 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
127.0.0.1 root MASTER_PORT 60 master-bin.001 79 slave-relay-bin.001 120 master-bin.001 Yes Yes 0 0 79 127.0.0.1 root MASTER_PORT 7 master-bin.001 79 slave-relay-bin.001 120 master-bin.001 Yes Yes 0 0 79
drop table if exists t1; drop table if exists t1;
create table t1 (n int); create table t1 (n int);
insert into t1 values (10),(45),(90); insert into t1 values (10),(45),(90);
......
...@@ -29,7 +29,18 @@ while ($1) ...@@ -29,7 +29,18 @@ while ($1)
dec $1; dec $1;
} }
enable_query_log; enable_query_log;
select count(*) from t1 where id1 > 95;
select count(*) from t2 where id2 > 95;
select count(*) from t3 where id3 > 95;
update t1,t2,t3 set t1.t="aaa", t2.t="bbb", t3.t="cc" where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 90; update t1,t2,t3 set t1.t="aaa", t2.t="bbb", t3.t="cc" where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 90;
select count(*) from t1 where t = "aaa";
select count(*) from t1 where id1 > 90;
select count(*) from t2 where t = "bbb";
select count(*) from t2 where id2 > 90;
select count(*) from t3 where t = "cc";
select count(*) from t3 where id3 > 90;
delete t1.*, t2.*, t3.* from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 95; delete t1.*, t2.*, t3.* from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 95;
check table t1, t2, t3; check table t1, t2, t3;
......
...@@ -8,6 +8,7 @@ sync_with_master; ...@@ -8,6 +8,7 @@ sync_with_master;
show slave status; show slave status;
change master to master_log_pos=73; change master to master_log_pos=73;
slave stop; slave stop;
change master to master_log_pos=73; change master to master_log_pos=73;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status; show slave status;
......
--server-id=2 --server-id=22 --master-connect-retry=7
...@@ -8,6 +8,7 @@ connection slave; ...@@ -8,6 +8,7 @@ connection slave;
reset slave; reset slave;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
show slave status; show slave status;
change master to master_host='127.0.0.1'; change master to master_host='127.0.0.1';
# The following needs to be cleaned up when change master is fixed # The following needs to be cleaned up when change master is fixed
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
......
...@@ -280,6 +280,8 @@ static SYMBOL symbols[] = { ...@@ -280,6 +280,8 @@ static SYMBOL symbols[] = {
{ "READ", SYM(READ_SYM),0,0}, { "READ", SYM(READ_SYM),0,0},
{ "REAL", SYM(REAL),0,0}, { "REAL", SYM(REAL),0,0},
{ "REFERENCES", SYM(REFERENCES),0,0}, { "REFERENCES", SYM(REFERENCES),0,0},
{ "RELAY_LOG_FILE", SYM(RELAY_LOG_FILE_SYM),0,0},
{ "RELAY_LOG_POS", SYM(RELAY_LOG_POS_SYM),0,0},
{ "RELOAD", SYM(RELOAD),0,0}, { "RELOAD", SYM(RELOAD),0,0},
{ "REGEXP", SYM(REGEXP),0,0}, { "REGEXP", SYM(REGEXP),0,0},
{ "RENAME", SYM(RENAME),0,0}, { "RENAME", SYM(RENAME),0,0},
......
...@@ -479,6 +479,7 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli) ...@@ -479,6 +479,7 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli)
rli->relay_log_pos = 4; rli->relay_log_pos = 4;
strnmov(rli->relay_log_name,rli->linfo.log_file_name, strnmov(rli->relay_log_name,rli->linfo.log_file_name,
sizeof(rli->relay_log_name)); sizeof(rli->relay_log_name));
flush_relay_log_info(rli);
} }
/* /*
No need to free io_buf because we allocated both fname and io_buf in No need to free io_buf because we allocated both fname and io_buf in
......
...@@ -1607,7 +1607,8 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -1607,7 +1607,8 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
{ {
mysql_parse(thd, thd->query, q_len); mysql_parse(thd, thd->query, q_len);
if (expected_error != if (expected_error !=
(actual_error = thd->net.last_errno) && expected_error) (actual_error = thd->net.last_errno) && expected_error &&
!ignored_error_code(actual_error))
{ {
const char* errmsg = "Slave: did not get the expected error\ const char* errmsg = "Slave: did not get the expected error\
running query from master - expected: '%s' (%d), got '%s' (%d)"; running query from master - expected: '%s' (%d), got '%s' (%d)";
......
...@@ -1377,6 +1377,7 @@ static void init_signals(void) ...@@ -1377,6 +1377,7 @@ static void init_signals(void)
sigaction(SIGBUS, &sa, NULL); sigaction(SIGBUS, &sa, NULL);
#endif #endif
sigaction(SIGILL, &sa, NULL); sigaction(SIGILL, &sa, NULL);
sigaction(SIGFPE, &sa, NULL);
} }
(void) sigemptyset(&set); (void) sigemptyset(&set);
#ifdef THREAD_SPECIFIC_SIGPIPE #ifdef THREAD_SPECIFIC_SIGPIPE
......
...@@ -345,7 +345,13 @@ int terminate_slave_thread(THD* thd, pthread_mutex_t* term_lock, ...@@ -345,7 +345,13 @@ int terminate_slave_thread(THD* thd, pthread_mutex_t* term_lock,
} }
} }
DBUG_ASSERT(thd != 0); DBUG_ASSERT(thd != 0);
KICK_SLAVE(thd); /* is is criticate to test if the slave is running. Otherwise, we might
be referening freed memory trying to kick it
*/
if (*slave_running)
{
KICK_SLAVE(thd);
}
while (*slave_running) while (*slave_running)
{ {
/* there is a small chance that slave thread might miss the first /* there is a small chance that slave thread might miss the first
...@@ -367,7 +373,9 @@ int terminate_slave_thread(THD* thd, pthread_mutex_t* term_lock, ...@@ -367,7 +373,9 @@ int terminate_slave_thread(THD* thd, pthread_mutex_t* term_lock,
DBUG_ASSERT_LOCK(cond_lock); DBUG_ASSERT_LOCK(cond_lock);
pthread_cond_timedwait(term_cond, cond_lock, &abstime); pthread_cond_timedwait(term_cond, cond_lock, &abstime);
if (*slave_running) if (*slave_running)
{
KICK_SLAVE(thd); KICK_SLAVE(thd);
}
} }
if (term_lock) if (term_lock)
pthread_mutex_unlock(term_lock); pthread_mutex_unlock(term_lock);
......
...@@ -151,6 +151,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length) ...@@ -151,6 +151,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length)
lex->yacc_yyss=lex->yacc_yyvs=0; lex->yacc_yyss=lex->yacc_yyvs=0;
lex->ignore_space=test(thd->sql_mode & MODE_IGNORE_SPACE); lex->ignore_space=test(thd->sql_mode & MODE_IGNORE_SPACE);
lex->slave_thd_opt=0; lex->slave_thd_opt=0;
bzero(&lex->mi,sizeof(lex->mi));
return lex; return lex;
} }
......
...@@ -98,6 +98,8 @@ typedef struct st_lex_master_info ...@@ -98,6 +98,8 @@ typedef struct st_lex_master_info
uint port, connect_retry; uint port, connect_retry;
ulonglong pos; ulonglong pos;
ulong server_id; ulong server_id;
char* relay_log_name;
ulong relay_log_pos;
} LEX_MASTER_INFO; } LEX_MASTER_INFO;
......
...@@ -690,6 +690,7 @@ int change_master(THD* thd, MASTER_INFO* mi) ...@@ -690,6 +690,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
{ {
int error=0,restart_thread_mask; int error=0,restart_thread_mask;
const char* errmsg=0; const char* errmsg=0;
bool need_relay_log_purge=1;
// kill slave thread // kill slave thread
lock_slave_threads(mi); lock_slave_threads(mi);
...@@ -742,17 +743,47 @@ int change_master(THD* thd, MASTER_INFO* mi) ...@@ -742,17 +743,47 @@ int change_master(THD* thd, MASTER_INFO* mi)
if (lex_mi->connect_retry) if (lex_mi->connect_retry)
mi->connect_retry = lex_mi->connect_retry; mi->connect_retry = lex_mi->connect_retry;
if (lex_mi->relay_log_name)
{
need_relay_log_purge = 0;
strnmov(mi->rli.relay_log_name,lex_mi->relay_log_name,
sizeof(mi->rli.relay_log_name));
}
if (lex_mi->relay_log_pos)
{
need_relay_log_purge=0;
mi->rli.relay_log_pos=lex_mi->relay_log_pos;
}
flush_master_info(mi); flush_master_info(mi);
pthread_mutex_unlock(&mi->data_lock); if (need_relay_log_purge)
thd->proc_info="purging old relay logs";
if (purge_relay_logs(&mi->rli,0 /* not only reset, but also reinit*/,
&errmsg))
{ {
send_error(&thd->net, 0, "Failed purging old relay logs"); pthread_mutex_unlock(&mi->data_lock);
unlock_slave_threads(mi); thd->proc_info="purging old relay logs";
return 1; if (purge_relay_logs(&mi->rli,0 /* not only reset, but also reinit*/,
&errmsg))
{
send_error(&thd->net, 0, "Failed purging old relay logs");
unlock_slave_threads(mi);
return 1;
}
pthread_mutex_lock(&mi->rli.data_lock);
}
else
{
const char* msg;
if (init_relay_log_pos(&mi->rli,0/*log already inited*/,
0 /*pos already inited*/,
0 /*no data lock*/,
&msg))
{
net_printf(&thd->net,0,"Failed initializing relay log position: %s",msg);
unlock_slave_threads(mi);
return 1;
}
} }
pthread_mutex_lock(&mi->rli.data_lock);
mi->rli.master_log_pos = mi->master_log_pos; mi->rli.master_log_pos = mi->master_log_pos;
strnmov(mi->rli.master_log_name,mi->master_log_name, strnmov(mi->rli.master_log_name,mi->master_log_name,
sizeof(mi->rli.master_log_name)); sizeof(mi->rli.master_log_name));
......
...@@ -241,6 +241,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -241,6 +241,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token MASTER_PORT_SYM %token MASTER_PORT_SYM
%token MASTER_CONNECT_RETRY_SYM %token MASTER_CONNECT_RETRY_SYM
%token MASTER_SERVER_ID_SYM %token MASTER_SERVER_ID_SYM
%token RELAY_LOG_FILE_SYM
%token RELAY_LOG_POS_SYM
%token MATCH %token MATCH
%token MAX_ROWS %token MAX_ROWS
%token MAX_QUERIES_PER_HOUR %token MAX_QUERIES_PER_HOUR
...@@ -700,6 +702,16 @@ master_def: ...@@ -700,6 +702,16 @@ master_def:
{ {
Lex->mi.connect_retry = $3; Lex->mi.connect_retry = $3;
} }
|
RELAY_LOG_FILE_SYM EQ TEXT_STRING
{
Lex->mi.relay_log_name = $3.str;
}
|
RELAY_LOG_POS_SYM EQ ULONG_NUM
{
Lex->mi.relay_log_pos = $3;
}
/* create a table */ /* create a table */
...@@ -3002,6 +3014,7 @@ keyword: ...@@ -3002,6 +3014,7 @@ keyword:
| ISSUER_SYM {} | ISSUER_SYM {}
| INNOBASE_SYM {} | INNOBASE_SYM {}
| INSERT_METHOD {} | INSERT_METHOD {}
| IO_THREAD {}
| LAST_SYM {} | LAST_SYM {}
| LEVEL_SYM {} | LEVEL_SYM {}
| LOCAL_SYM {} | LOCAL_SYM {}
...@@ -3044,6 +3057,8 @@ keyword: ...@@ -3044,6 +3057,8 @@ keyword:
| RAID_CHUNKSIZE {} | RAID_CHUNKSIZE {}
| RAID_STRIPED_SYM {} | RAID_STRIPED_SYM {}
| RAID_TYPE {} | RAID_TYPE {}
| RELAY_LOG_FILE_SYM {}
| RELAY_LOG_POS_SYM {}
| RELOAD {} | RELOAD {}
| REPAIR {} | REPAIR {}
| REPEATABLE_SYM {} | REPEATABLE_SYM {}
...@@ -3063,6 +3078,7 @@ keyword: ...@@ -3063,6 +3078,7 @@ keyword:
| SQL_CACHE_SYM {} | SQL_CACHE_SYM {}
| SQL_NO_CACHE_SYM {} | SQL_NO_CACHE_SYM {}
| SQL_QUERY_CACHE_TYPE_SYM {} | SQL_QUERY_CACHE_TYPE_SYM {}
| SQL_THREAD {}
| START_SYM {} | START_SYM {}
| STATUS_SYM {} | STATUS_SYM {}
| STOP_SYM {} | STOP_SYM {}
......
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