Commit 2f8f0a7e authored by unknown's avatar unknown

Implemented support for START SLAVE UNTIL (WL#868)


include/mysqld_error.h:
  Added error codes for warnings and error messages for START SLAVE UNTIL
mysql-test/r/rpl000015.result:
  Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_empty_master_crash.result:
  Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_flush_log_loop.result:
  Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_log.result:
  Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_log_pos.result:
  Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_redirect.result:
  Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_replicate_do.result:
  Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_rotate_logs.result:
  Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
sql/lex.h:
  Added UNTIL symbol
sql/log.cc:
  Invalidating until_log_name comparison result if group_relay_log_name is changed
sql/log_event.cc:
  Invalidating until_log_name comparison result if group_master_log_name is changed
sql/repl_failsafe.cc:
  Cancel until condition if LOAD MASTER DATA is executed
sql/share/czech/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/danish/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/dutch/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/english/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/estonian/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/french/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/german/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/greek/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/hungarian/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/italian/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/japanese/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/korean/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/norwegian-ny/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/norwegian/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/polish/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/portuguese/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/romanian/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/russian/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/serbian/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/slovak/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/spanish/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/swedish/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/share/ukrainian/errmsg.txt:
  Added error and warning message for START SLAVE UNTIL
sql/slave.cc:
  Fixed wrong locking order in init_relay_log_pos()
  Added until condition fields to SHOW SLAVE STATUS
  Added checking if UNTIL condition is reached 
  (added proper method, added its invocation, reorganized locking 
  in exec_relay_log_event() and next_event())
sql/slave.h:
  Members in RELAY_LOG_INFO for storing UNTIL condition. Also 
  methods for for invalidation of cached UNTIL condition comparison
  results
sql/sql_repl.cc:
  Now honoring UNTIL clause then starting slave thread. Proper 
  errors and warnings.
sql/sql_yacc.yy:
  Added support for UNTIL clause in START SLAVE. This involved 
  extraction of some of master_defs to separate master_file_def
  non-terminal.
parent 6417c182
...@@ -288,4 +288,7 @@ ...@@ -288,4 +288,7 @@
#define ER_CANT_AGGREGATE_NCOLLATIONS 1269 #define ER_CANT_AGGREGATE_NCOLLATIONS 1269
#define ER_VARIABLE_IS_NOT_STRUCT 1270 #define ER_VARIABLE_IS_NOT_STRUCT 1270
#define ER_UNKNOWN_COLLATION 1271 #define ER_UNKNOWN_COLLATION 1271
#define ER_ERROR_MESSAGES 272 #define ER_BAD_SLAVE_UNTIL_COND 1272
#define ER_MISSING_SKIP_SLAVE 1273
#define ER_UNTIL_COND_IGNORED 1274
#define ER_ERROR_MESSAGES 275
...@@ -4,20 +4,20 @@ File Position Binlog_do_db Binlog_ignore_db ...@@ -4,20 +4,20 @@ File Position Binlog_do_db Binlog_ignore_db
master-bin.000001 79 master-bin.000001 79
reset slave; reset slave;
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 test MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 127.0.0.1 test MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 127.0.0.1 root MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0
start slave; start slave;
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 7 master-bin.000001 79 slave-relay-bin.000001 123 master-bin.000001 Yes Yes 0 0 79 123 127.0.0.1 root MASTER_PORT 7 master-bin.000001 79 slave-relay-bin.000001 123 master-bin.000001 Yes Yes 0 0 79 123 None 0
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);
......
...@@ -5,7 +5,7 @@ reset slave; ...@@ -5,7 +5,7 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave; start slave;
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
load table t1 from master; load table t1 from master;
ERROR 08S01: Error connecting to master: Master is not configured ERROR 08S01: Error connecting to master: Master is not configured
load table t1 from master; load table t1 from master;
......
...@@ -13,5 +13,5 @@ master_password='',master_port=SLAVE_PORT; ...@@ -13,5 +13,5 @@ master_password='',master_port=SLAVE_PORT;
start slave; start slave;
flush logs; flush logs;
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 79 relay-log.000001 122 slave-bin.000001 Yes Yes 0 0 79 122 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 79 relay-log.000001 122 slave-bin.000001 Yes Yes 0 0 79 122 None 0
...@@ -92,7 +92,7 @@ slave-bin.000002 4 Query 1 110 use `test`; create table t1 (n int) ...@@ -92,7 +92,7 @@ slave-bin.000002 4 Query 1 110 use `test`; create table t1 (n int)
slave-bin.000002 62 Query 1 168 use `test`; insert into t1 values (1) slave-bin.000002 62 Query 1 168 use `test`; insert into t1 values (1)
slave-bin.000002 122 Query 1 228 use `test`; drop table t1 slave-bin.000002 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 1 master-bin.000002 276 slave-relay-bin.000002 1531 master-bin.000002 Yes Yes 0 0 276 1535 127.0.0.1 root MASTER_PORT 1 master-bin.000002 276 slave-relay-bin.000002 1531 master-bin.000002 Yes Yes 0 0 276 1535 None 0
show binlog events in 'slave-bin.000005' from 4; show binlog events in 'slave-bin.000005' from 4;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log
...@@ -8,26 +8,26 @@ show master status; ...@@ -8,26 +8,26 @@ show master status;
File Position Binlog_do_db Binlog_ignore_db File Position Binlog_do_db Binlog_ignore_db
master-bin.000001 79 master-bin.000001 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 127 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 127 None 0
stop slave; stop slave;
change master to master_log_pos=73; change master to master_log_pos=73;
start slave; start slave;
stop slave; stop slave;
change master to master_log_pos=73; change master to master_log_pos=73;
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 73 4 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 73 4 None 0
start slave; start slave;
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 73 4 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 73 4 None 0
stop slave; stop slave;
change master to master_log_pos=173; change master to master_log_pos=173;
start slave; start slave;
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 1 master-bin.000001 173 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 173 4 127.0.0.1 root MASTER_PORT 1 master-bin.000001 173 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 173 4 None 0
show master status; show master status;
File Position Binlog_do_db Binlog_ignore_db File Position Binlog_do_db Binlog_ignore_db
master-bin.000001 79 master-bin.000001 79
......
...@@ -5,7 +5,7 @@ reset slave; ...@@ -5,7 +5,7 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave; start slave;
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
SHOW SLAVE HOSTS; SHOW SLAVE HOSTS;
Server_id Host Port Rpl_recovery_rank Master_id Server_id Host Port Rpl_recovery_rank Master_id
2 127.0.0.1 SLAVE_PORT 2 1 2 127.0.0.1 SLAVE_PORT 2 1
......
...@@ -27,5 +27,5 @@ select * from t11; ...@@ -27,5 +27,5 @@ select * from t11;
ERROR 42S02: Table 'test.t11' doesn't exist ERROR 42S02: Table 'test.t11' doesn't exist
drop table if exists t1,t2,t11; drop table if exists t1,t2,t11;
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 1 master-bin.000001 1281 slave-relay-bin.000002 1325 master-bin.000001 Yes Yes test.t1 0 0 1281 1329 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1281 slave-relay-bin.000002 1325 master-bin.000001 Yes Yes test.t1 0 0 1281 1329 None 0
...@@ -15,8 +15,8 @@ insert into temp_table values ("testing temporary tables"); ...@@ -15,8 +15,8 @@ insert into temp_table values ("testing temporary tables");
create table t1 (s text); create table t1 (s text);
insert into t1 values('Could not break slave'),('Tried hard'); insert into t1 values('Could not break slave'),('Tried hard');
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 60 master-bin.000001 417 slave-relay-bin.000001 461 master-bin.000001 Yes Yes 0 0 417 461 127.0.0.1 root MASTER_PORT 60 master-bin.000001 417 slave-relay-bin.000001 461 master-bin.000001 Yes Yes 0 0 417 461 None 0
select * from t1; select * from t1;
s s
Could not break slave Could not break slave
...@@ -56,8 +56,8 @@ Log_name ...@@ -56,8 +56,8 @@ Log_name
master-bin.000003 master-bin.000003
insert into t2 values (65); insert into t2 values (65);
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 60 master-bin.000003 290 slave-relay-bin.000001 1088 master-bin.000003 Yes Yes 0 0 290 1088 127.0.0.1 root MASTER_PORT 60 master-bin.000003 290 slave-relay-bin.000001 1088 master-bin.000003 Yes Yes 0 0 290 1088 None 0
select * from t2; select * from t2;
m m
34 34
...@@ -82,8 +82,8 @@ select * from t4; ...@@ -82,8 +82,8 @@ select * from t4;
a a
testing temporary tables part 2 testing temporary tables part 2
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table 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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_PORT 60 master-bin.000006 838 slave-relay-bin.000001 8067 master-bin.000006 Yes Yes 0 0 838 8067 127.0.0.1 root MASTER_PORT 60 master-bin.000006 838 slave-relay-bin.000001 8067 master-bin.000006 Yes Yes 0 0 838 8067 None 0
lock tables t3 read; lock tables t3 read;
select count(*) from t3 where n >= 4; select count(*) from t3 where n >= 4;
count(*) count(*)
......
stop slave;
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;
start slave;
stop slave;
create table t1(n int not null auto_increment primary key);
insert into t1 values (1),(2),(3),(4);
drop table t1;
create table t2(n int not null auto_increment primary key);
insert into t2 values (1),(2);
insert into t2 values (3),(4);
drop table t2;
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 4 Start 1 4 Server ver: 4.1.1-alpha-debug-log, Binlog ver: 3
master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
master-bin.000001 172 Query 1 172 use `test`; insert into t1 values (1),(2),(3),(4)
master-bin.000001 244 Query 1 244 use `test`; drop table t1
master-bin.000001 292 Query 1 292 use `test`; create table t2(n int not null auto_increment primary key)
master-bin.000001 385 Query 1 385 use `test`; insert into t2 values (1),(2)
master-bin.000001 449 Query 1 449 use `test`; insert into t2 values (3),(4)
master-bin.000001 513 Query 1 513 use `test`; drop table t2
start slave until master_log_file='master-bin.000001', master_log_pos=244;
select * from t1;
n
1
2
3
4
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 288 master-bin.000001 Yes No 0 0 244 609 Master master-bin.000001 244
start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
select * from t1;
n
1
2
3
4
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 288 master-bin.000001 Yes No 0 0 244 609 Master master-no-such-bin.000001 291
start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=493;
select * from t2;
n
1
2
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 493 master-bin.000001 Yes No 0 0 449 609 Relay slave-relay-bin.000002 493
start slave;
stop slave;
start slave until master_log_file='master-bin.000001', master_log_pos=561;
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 Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos
127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 605 master-bin.000001 Yes No 0 0 561 609 Master master-bin.000001 561
start slave until master_log_file='master-bin', master_log_pos=561;
ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
start slave until master_log_file='master-bin.000001';
ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
start slave until relay_log_file='slave-relay-bin.000002';
ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
start slave sql_thread;
start slave until master_log_file='master-bin.000001', master_log_pos=561;
Warnings:
Note 1252 The slave was already running
source include/master-slave.inc;
# stop slave before he will start replication
connection slave;
stop slave;
connection master;
# create some events on master
create table t1(n int not null auto_increment primary key);
insert into t1 values (1),(2),(3),(4);
drop table t1;
create table t2(n int not null auto_increment primary key);
insert into t2 values (1),(2);
insert into t2 values (3),(4);
drop table t2;
show binlog events;
# try to replicate all queries until drop of t1
connection slave;
start slave until master_log_file='master-bin.000001', master_log_pos=244;
sleep 2;
# here table should be still not deleted
select * from t1;
--replace_result $MASTER_MYPORT MASTER_MYPORT
show slave status;
# this should fail right after start
start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
# again this table should be still not deleted
select * from t1;
sleep 2;
--replace_result $MASTER_MYPORT MASTER_MYPORT
show slave status;
# try replicate all until second insert to t2;
start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=493;
sleep 2;
select * from t2;
--replace_result $MASTER_MYPORT MASTER_MYPORT
show slave status;
# clean up
start slave;
connection master;
save_master_pos;
connection slave;
sync_with_master;
stop slave;
# this should stop immideately
start slave until master_log_file='master-bin.000001', master_log_pos=561;
sleep 2;
# here the sql slave thread should be stopped
--replace_result $MASTER_MYPORT MASTER_MYPORT
show slave status;
#testing various error conditions
--error 1272
start slave until master_log_file='master-bin', master_log_pos=561;
--error 1272
start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
--error 1272
start slave until master_log_file='master-bin.000001';
--error 1272
start slave until relay_log_file='slave-relay-bin.000002';
--error 1272
start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
start slave sql_thread;
start slave until master_log_file='master-bin.000001', master_log_pos=561;
...@@ -403,6 +403,7 @@ static SYMBOL symbols[] = { ...@@ -403,6 +403,7 @@ static SYMBOL symbols[] = {
{ "USE", SYM(USE_SYM),0,0}, { "USE", SYM(USE_SYM),0,0},
{ "USE_FRM", SYM(USE_FRM),0,0}, { "USE_FRM", SYM(USE_FRM),0,0},
{ "USER", SYM(USER),0,0}, { "USER", SYM(USER),0,0},
{ "UNTIL", SYM(UNTIL_SYM),0,0},
{ "USING", SYM(USING),0,0}, { "USING", SYM(USING),0,0},
{ "UPDATE", SYM(UPDATE_SYM),0,0}, { "UPDATE", SYM(UPDATE_SYM),0,0},
{ "USAGE", SYM(USAGE),0,0}, { "USAGE", SYM(USAGE),0,0},
......
...@@ -692,6 +692,7 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli, bool included) ...@@ -692,6 +692,7 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli, bool included)
rli->group_relay_log_pos = BIN_LOG_HEADER_SIZE; rli->group_relay_log_pos = BIN_LOG_HEADER_SIZE;
strmake(rli->group_relay_log_name,rli->linfo.log_file_name, strmake(rli->group_relay_log_name,rli->linfo.log_file_name,
sizeof(rli->group_relay_log_name)-1); sizeof(rli->group_relay_log_name)-1);
rli->notify_group_relay_log_name_update();
} }
/* Store where we are in the new file for the execution thread */ /* Store where we are in the new file for the execution thread */
......
...@@ -1820,6 +1820,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -1820,6 +1820,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
pthread_mutex_lock(&rli->data_lock); pthread_mutex_lock(&rli->data_lock);
memcpy(log_name, new_log_ident, ident_len+1); memcpy(log_name, new_log_ident, ident_len+1);
rli->notify_group_master_log_name_update();
rli->group_master_log_pos = pos; rli->group_master_log_pos = pos;
rli->event_relay_log_pos += get_event_len(); rli->event_relay_log_pos += get_event_len();
rli->group_relay_log_pos = rli->event_relay_log_pos; rli->group_relay_log_pos = rli->event_relay_log_pos;
......
...@@ -901,6 +901,12 @@ int load_master_data(THD* thd) ...@@ -901,6 +901,12 @@ int load_master_data(THD* thd)
active_mi->rli.group_master_log_pos = active_mi->master_log_pos; active_mi->rli.group_master_log_pos = active_mi->master_log_pos;
strmake(active_mi->rli.group_master_log_name,active_mi->master_log_name, strmake(active_mi->rli.group_master_log_name,active_mi->master_log_name,
sizeof(active_mi->rli.group_master_log_name)-1); sizeof(active_mi->rli.group_master_log_name)-1);
/*
Cancel the previous START SLAVE UNTIL, as the fact to download
a new copy logically makes UNTIL irrelevant.
*/
clear_until_condition(&active_mi->rli);
/* /*
No need to update rli.event* coordinates, they will be when the slave No need to update rli.event* coordinates, they will be when the slave
threads start ; only rli.group* coordinates are necessary here. threads start ; only rli.group* coordinates are necessary here.
......
...@@ -277,3 +277,6 @@ v/* ...@@ -277,3 +277,6 @@ v/*
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -271,3 +271,6 @@ ...@@ -271,3 +271,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -279,3 +279,6 @@ ...@@ -279,3 +279,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -273,3 +273,6 @@ ...@@ -273,3 +273,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -273,3 +273,6 @@ ...@@ -273,3 +273,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -268,3 +268,6 @@ ...@@ -268,3 +268,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -277,3 +277,6 @@ ...@@ -277,3 +277,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -268,3 +268,6 @@ ...@@ -268,3 +268,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -270,3 +270,6 @@ ...@@ -270,3 +270,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -268,3 +268,6 @@ ...@@ -268,3 +268,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -270,3 +270,6 @@ ...@@ -270,3 +270,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -268,3 +268,6 @@ ...@@ -268,3 +268,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -270,3 +270,6 @@ ...@@ -270,3 +270,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -270,3 +270,6 @@ ...@@ -270,3 +270,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -272,3 +272,6 @@ ...@@ -272,3 +272,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -268,3 +268,6 @@ ...@@ -268,3 +268,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -272,3 +272,6 @@ ...@@ -272,3 +272,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -270,3 +270,6 @@ ...@@ -270,3 +270,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -264,3 +264,6 @@ ...@@ -264,3 +264,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -276,3 +276,6 @@ ...@@ -276,3 +276,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -269,3 +269,6 @@ ...@@ -269,3 +269,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -268,3 +268,6 @@ ...@@ -268,3 +268,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -273,3 +273,6 @@ ...@@ -273,3 +273,6 @@
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored"
...@@ -232,10 +232,12 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log, ...@@ -232,10 +232,12 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,
*errmsg=0; *errmsg=0;
pthread_mutex_t *log_lock=rli->relay_log.get_log_lock(); pthread_mutex_t *log_lock=rli->relay_log.get_log_lock();
pthread_mutex_lock(log_lock);
if (need_data_lock) if (need_data_lock)
pthread_mutex_lock(&rli->data_lock); pthread_mutex_lock(&rli->data_lock);
pthread_mutex_lock(log_lock);
/* Close log file and free buffers if it's already open */ /* Close log file and free buffers if it's already open */
if (rli->cur_log_fd >= 0) if (rli->cur_log_fd >= 0)
{ {
...@@ -298,9 +300,11 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log, ...@@ -298,9 +300,11 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,
if (!relay_log_purge) if (!relay_log_purge)
rli->log_space_limit= 0; rli->log_space_limit= 0;
pthread_cond_broadcast(&rli->data_cond); pthread_cond_broadcast(&rli->data_cond);
pthread_mutex_unlock(log_lock);
if (need_data_lock) if (need_data_lock)
pthread_mutex_unlock(&rli->data_lock); pthread_mutex_unlock(&rli->data_lock);
pthread_mutex_unlock(log_lock);
DBUG_RETURN ((*errmsg) ? 1 : 0); DBUG_RETURN ((*errmsg) ? 1 : 0);
} }
...@@ -1410,6 +1414,20 @@ static int count_relay_log_space(RELAY_LOG_INFO* rli) ...@@ -1410,6 +1414,20 @@ static int count_relay_log_space(RELAY_LOG_INFO* rli)
} }
/*
Reset UNTIL condition for RELAY_LOG_INFO
SYNOPSYS
clear_until_condition()
rli - RELAY_LOG_INFO structure where UNTIL condition should be reset
*/
void clear_until_condition(RELAY_LOG_INFO* rli)
{
rli->until_condition= RELAY_LOG_INFO::UNTIL_NONE;
rli->until_log_name[0]= 0;
rli->until_log_pos= 0;
}
int init_master_info(MASTER_INFO* mi, const char* master_info_fname, int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
const char* slave_info_fname, const char* slave_info_fname,
bool abort_if_no_master_info_file) bool abort_if_no_master_info_file)
...@@ -1648,6 +1666,10 @@ int show_master_info(THD* thd, MASTER_INFO* mi) ...@@ -1648,6 +1666,10 @@ int show_master_info(THD* thd, MASTER_INFO* mi)
MYSQL_TYPE_LONGLONG)); MYSQL_TYPE_LONGLONG));
field_list.push_back(new Item_return_int("Relay_log_space", 10, field_list.push_back(new Item_return_int("Relay_log_space", 10,
MYSQL_TYPE_LONGLONG)); MYSQL_TYPE_LONGLONG));
field_list.push_back(new Item_empty_string("Until_condition", 6));
field_list.push_back(new Item_empty_string("Until_Log_File", FN_REFLEN));
field_list.push_back(new Item_return_int("Until_Log_pos", 10,
MYSQL_TYPE_LONGLONG));
if (protocol->send_fields(&field_list, 1)) if (protocol->send_fields(&field_list, 1))
DBUG_RETURN(-1); DBUG_RETURN(-1);
...@@ -1694,6 +1716,14 @@ int show_master_info(THD* thd, MASTER_INFO* mi) ...@@ -1694,6 +1716,14 @@ int show_master_info(THD* thd, MASTER_INFO* mi)
protocol->store((uint32) mi->rli.slave_skip_counter); protocol->store((uint32) mi->rli.slave_skip_counter);
protocol->store((ulonglong) mi->rli.group_master_log_pos); protocol->store((ulonglong) mi->rli.group_master_log_pos);
protocol->store((ulonglong) mi->rli.log_space_total); protocol->store((ulonglong) mi->rli.log_space_total);
protocol->store(
mi->rli.until_condition==RELAY_LOG_INFO::UNTIL_NONE ? "None":
( mi->rli.until_condition==RELAY_LOG_INFO::UNTIL_MASTER_POS? "Master":
"Relay"), &my_charset_bin);
protocol->store(mi->rli.until_log_name, &my_charset_bin);
protocol->store((ulonglong) mi->rli.until_log_pos);
pthread_mutex_unlock(&mi->rli.data_lock); pthread_mutex_unlock(&mi->rli.data_lock);
pthread_mutex_unlock(&mi->data_lock); pthread_mutex_unlock(&mi->data_lock);
...@@ -1727,10 +1757,10 @@ st_relay_log_info::st_relay_log_info() ...@@ -1727,10 +1757,10 @@ st_relay_log_info::st_relay_log_info()
cur_log_old_open_count(0), group_master_log_pos(0), log_space_total(0), cur_log_old_open_count(0), group_master_log_pos(0), log_space_total(0),
ignore_log_space_limit(0), slave_skip_counter(0), abort_pos_wait(0), ignore_log_space_limit(0), slave_skip_counter(0), abort_pos_wait(0),
slave_run_id(0), sql_thd(0), last_slave_errno(0), inited(0), abort_slave(0), slave_run_id(0), sql_thd(0), last_slave_errno(0), inited(0), abort_slave(0),
slave_running(0) slave_running(0), until_condition(UNTIL_NONE), until_log_pos(0)
{ {
group_relay_log_name[0]= event_relay_log_name[0]= group_master_log_name[0]= 0; group_relay_log_name[0]= event_relay_log_name[0]= group_master_log_name[0]= 0;
last_slave_error[0]=0; last_slave_error[0]=0; until_log_name[0]= 0;
bzero(&info_file,sizeof(info_file)); bzero(&info_file,sizeof(info_file));
bzero(&cache_buf, sizeof(cache_buf)); bzero(&cache_buf, sizeof(cache_buf));
...@@ -2151,14 +2181,127 @@ point. If you are sure that your master is ok, run this query manually on the\ ...@@ -2151,14 +2181,127 @@ point. If you are sure that your master is ok, run this query manually on the\
} }
} }
/*
Check if condition stated in UNTIL clause of START SLAVE is reached.
SYNOPSYS
st_relay_log_info::is_until_satisfied()
DESCRIPTION
Checks if UNTIL condition is reached. Uses caching result of last
comparison of current log file name and target log file name. So cached
value should be invalidated if current log file name changes
(see st_relay_log_info::notify_... functions).
This caching is needed to avoid of expensive string comparisons and
strtol() conversions needed for log names comparison. We don't need to
compare them each time this function is called, we only need to do this
when current log name changes. If we have UNTIL_MASTER_POS condition we
need to do this only after Rotate_log_event::exec_event() (which is
rare, so caching gives real benifit), and if we have UNTIL_RELAY_POS
condition then we should invalidate cached comarison value after
inc_group_relay_log_pos() which called for each group of events (so we
have some benefit if we have something like queries that use
autoincrement or if we have transactions).
Should be called ONLY if until_condition != UNTIL_NONE !
RETURN VALUE
true - condition met or error happened (condition seems to have
bad log file name)
false - condition not met
*/
bool st_relay_log_info::is_until_satisfied()
{
const char *log_name;
ulonglong log_pos;
DBUG_ASSERT(until_condition != UNTIL_NONE);
if (until_condition == UNTIL_MASTER_POS)
{
log_name= group_master_log_name;
log_pos= group_master_log_pos;
}
else
{ /* until_condition == UNTIL_RELAY_POS */
log_name= group_relay_log_name;
log_pos= group_relay_log_pos;
}
if (until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_UNKNOWN)
{
/*
We have no cached comaprison results so we should compare log names
and cache result
*/
DBUG_ASSERT(*log_name || log_pos == 0);
if (*log_name)
{
const char *basename= log_name + dirname_length(log_name);
const char *q= (const char*)(fn_ext(basename)+1);
if (strncmp(basename, until_log_name, (int)(q-basename)) == 0)
{
/* Now compare extensions. */
char *q_end;
ulong log_name_extension= strtoul(q, &q_end, 10);
if (log_name_extension < until_log_name_extension)
until_log_names_cmp_result= UNTIL_LOG_NAMES_CMP_LESS;
else
until_log_names_cmp_result=
(log_name_extension > until_log_name_extension) ?
UNTIL_LOG_NAMES_CMP_GREATER : UNTIL_LOG_NAMES_CMP_EQUAL ;
}
else
{
/* Probably error so we aborting */
sql_print_error("Slave SQL thread is stopped because UNTIL "
"condition is bad.");
return true;
}
}
else
return until_log_pos == 0;
}
return ((until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_EQUAL &&
log_pos >= until_log_pos) ||
until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_GREATER);
}
static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
{ {
/*
We acquire this mutex since we need it for all operations except
event execution. But we will release it in places where we will
wait for something for example inside of next_event().
*/
pthread_mutex_lock(&rli->data_lock);
if (rli->until_condition!=RELAY_LOG_INFO::UNTIL_NONE &&
rli->is_until_satisfied())
{
sql_print_error("Slave SQL thread stopped because it reached its"
" UNTIL position");
/*
Setting abort_slave flag because we do not want additional message about
error in query execution to be printed.
*/
rli->abort_slave= 1;
pthread_mutex_unlock(&rli->data_lock);
return 1;
}
Log_event * ev = next_event(rli); Log_event * ev = next_event(rli);
DBUG_ASSERT(rli->sql_thd==thd); DBUG_ASSERT(rli->sql_thd==thd);
if (sql_slave_killed(thd,rli)) if (sql_slave_killed(thd,rli))
{ {
/* do not forget to free ev ! */ /* do not forget to free ev ! */
pthread_mutex_unlock(&rli->data_lock);
if (ev) delete ev; if (ev) delete ev;
return 1; return 1;
} }
...@@ -2166,7 +2309,6 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ...@@ -2166,7 +2309,6 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
{ {
int type_code = ev->get_type_code(); int type_code = ev->get_type_code();
int exec_res; int exec_res;
pthread_mutex_lock(&rli->data_lock);
/* /*
Skip queries originating from this server or number of Skip queries originating from this server or number of
...@@ -2211,6 +2353,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ...@@ -2211,6 +2353,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
} }
else else
{ {
pthread_mutex_unlock(&rli->data_lock);
sql_print_error("\ sql_print_error("\
Could not parse relay log event entry. The possible reasons are: the master's \ Could not parse relay log event entry. The possible reasons are: the master's \
binary log is corrupted (you can check this by running 'mysqlbinlog' on the \ binary log is corrupted (you can check this by running 'mysqlbinlog' on the \
...@@ -3228,17 +3371,18 @@ Log_event* next_event(RELAY_LOG_INFO* rli) ...@@ -3228,17 +3371,18 @@ Log_event* next_event(RELAY_LOG_INFO* rli)
pthread_mutex_t *log_lock = rli->relay_log.get_log_lock(); pthread_mutex_t *log_lock = rli->relay_log.get_log_lock();
const char* errmsg=0; const char* errmsg=0;
THD* thd = rli->sql_thd; THD* thd = rli->sql_thd;
DBUG_ENTER("next_event"); DBUG_ENTER("next_event");
DBUG_ASSERT(thd != 0); DBUG_ASSERT(thd != 0);
/* /*
For most operations we need to protect rli members with data_lock, For most operations we need to protect rli members with data_lock,
so we will hold it for the most of the loop below so we assume calling function acquired this mutex for us and we will
However, we will release it whenever it is worth the hassle, hold it for the most of the loop below However, we will release it
and in the cases when we go into a pthread_cond_wait() with the whenever it is worth the hassle, and in the cases when we go into a
non-data_lock mutex pthread_cond_wait() with the non-data_lock mutex
*/ */
pthread_mutex_lock(&rli->data_lock); safe_mutex_assert_owner(&rli->data_lock);
while (!sql_slave_killed(thd,rli)) while (!sql_slave_killed(thd,rli))
{ {
...@@ -3284,7 +3428,6 @@ Log_event* next_event(RELAY_LOG_INFO* rli) ...@@ -3284,7 +3428,6 @@ Log_event* next_event(RELAY_LOG_INFO* rli)
DBUG_ASSERT(thd==rli->sql_thd); DBUG_ASSERT(thd==rli->sql_thd);
if (hot_log) if (hot_log)
pthread_mutex_unlock(log_lock); pthread_mutex_unlock(log_lock);
pthread_mutex_unlock(&rli->data_lock);
DBUG_RETURN(ev); DBUG_RETURN(ev);
} }
DBUG_ASSERT(thd==rli->sql_thd); DBUG_ASSERT(thd==rli->sql_thd);
...@@ -3460,7 +3603,6 @@ event(errno: %d cur_log->error: %d)", ...@@ -3460,7 +3603,6 @@ event(errno: %d cur_log->error: %d)",
errmsg = "slave SQL thread was killed"; errmsg = "slave SQL thread was killed";
err: err:
pthread_mutex_unlock(&rli->data_lock);
if (errmsg) if (errmsg)
sql_print_error("Error reading relay log event: %s", errmsg); sql_print_error("Error reading relay log event: %s", errmsg);
DBUG_RETURN(0); DBUG_RETURN(0);
......
...@@ -208,9 +208,55 @@ typedef struct st_relay_log_info ...@@ -208,9 +208,55 @@ typedef struct st_relay_log_info
bool inited; bool inited;
volatile bool abort_slave, slave_running; volatile bool abort_slave, slave_running;
/*
Condition and its parameters from START SLAVE UNTIL clause.
UNTIL condition is tested with is_until_satisfied() method that is
called by exec_relay_log_event(). is_until_satisfied() caches the result
of the comparison of log names because log names don't change very often;
this cache is invalidated by parts of code which change log names with
notify_*_log_name_updated() methods. (They need to be called only if SQL
thread is running).
*/
enum {UNTIL_NONE= 0, UNTIL_MASTER_POS, UNTIL_RELAY_POS} until_condition;
char until_log_name[FN_REFLEN];
ulonglong until_log_pos;
/* extension extracted from log_name and converted to int */
ulong until_log_name_extension;
/*
Cached result of comparison of until_log_name and current log name
-2 means unitialised, -1,0,1 are comarison results
*/
enum
{
UNTIL_LOG_NAMES_CMP_UNKNOWN= -2, UNTIL_LOG_NAMES_CMP_LESS= -1,
UNTIL_LOG_NAMES_CMP_EQUAL= 0, UNTIL_LOG_NAMES_CMP_GREATER= 1
} until_log_names_cmp_result;
st_relay_log_info(); st_relay_log_info();
~st_relay_log_info(); ~st_relay_log_info();
/*
Invalidate cached until_log_name and group_relay_log_name comparison
result. Should be called after any update of group_realy_log_name if
there chances that sql_thread is running.
*/
inline void notify_group_relay_log_name_update()
{
if (until_condition==UNTIL_RELAY_POS)
until_log_names_cmp_result= UNTIL_LOG_NAMES_CMP_UNKNOWN;
}
/*
The same as previous but for group_master_log_name.
*/
inline void notify_group_master_log_name_update()
{
if (until_condition==UNTIL_MASTER_POS)
until_log_names_cmp_result= UNTIL_LOG_NAMES_CMP_UNKNOWN;
}
inline void inc_event_relay_log_pos(ulonglong val) inline void inc_event_relay_log_pos(ulonglong val)
{ {
event_relay_log_pos+= val; event_relay_log_pos+= val;
...@@ -224,6 +270,9 @@ typedef struct st_relay_log_info ...@@ -224,6 +270,9 @@ typedef struct st_relay_log_info
group_relay_log_pos= event_relay_log_pos; group_relay_log_pos= event_relay_log_pos;
strmake(group_relay_log_name,event_relay_log_name, strmake(group_relay_log_name,event_relay_log_name,
sizeof(group_relay_log_name)-1); sizeof(group_relay_log_name)-1);
notify_group_relay_log_name_update();
/* /*
If the slave does not support transactions and replicates a transaction, If the slave does not support transactions and replicates a transaction,
users should not trust group_master_log_pos (which they can display with users should not trust group_master_log_pos (which they can display with
...@@ -243,6 +292,10 @@ typedef struct st_relay_log_info ...@@ -243,6 +292,10 @@ typedef struct st_relay_log_info
int wait_for_pos(THD* thd, String* log_name, longlong log_pos, int wait_for_pos(THD* thd, String* log_name, longlong log_pos,
longlong timeout); longlong timeout);
/* Check if UNTIL condition is satisfied. See slave.cc for more. */
bool is_until_satisfied();
} RELAY_LOG_INFO; } RELAY_LOG_INFO;
...@@ -424,6 +477,7 @@ void skip_load_data_infile(NET* net); ...@@ -424,6 +477,7 @@ void skip_load_data_infile(NET* net);
void slave_print_error(RELAY_LOG_INFO* rli,int err_code, const char* msg, ...); void slave_print_error(RELAY_LOG_INFO* rli,int err_code, const char* msg, ...);
void end_slave(); /* clean up */ void end_slave(); /* clean up */
void clear_until_condition(RELAY_LOG_INFO* rli);
int init_master_info(MASTER_INFO* mi, const char* master_info_fname, int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
const char* slave_info_fname, const char* slave_info_fname,
bool abort_if_no_master_info_file); bool abort_if_no_master_info_file);
......
...@@ -632,7 +632,7 @@ Increase max_allowed_packet on master"; ...@@ -632,7 +632,7 @@ Increase max_allowed_packet on master";
int start_slave(THD* thd , MASTER_INFO* mi, bool net_report) int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
{ {
int slave_errno; int slave_errno= 0;
if (!thd) if (!thd)
thd = current_thd; thd = current_thd;
int thread_mask; int thread_mask;
...@@ -656,21 +656,88 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report) ...@@ -656,21 +656,88 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
if (init_master_info(mi,master_info_file,relay_log_info_file, 0)) if (init_master_info(mi,master_info_file,relay_log_info_file, 0))
slave_errno=ER_MASTER_INFO; slave_errno=ER_MASTER_INFO;
else if (server_id_supplied && *mi->host) else if (server_id_supplied && *mi->host)
{
/*
If we will start SQL thread we will care about UNTIL options
If not and they are specified we will ignore them and warn user
about this fact.
*/
if (thread_mask & SLAVE_SQL)
{
pthread_mutex_lock(&mi->rli.data_lock);
if (thd->lex.mi.pos)
{
mi->rli.until_condition= RELAY_LOG_INFO::UNTIL_MASTER_POS;
mi->rli.until_log_pos= thd->lex.mi.pos;
/*
We don't check thd->lex.mi.log_file_name for NULL here
since it is checked in sql_yacc.yy
*/
strmake(mi->rli.until_log_name, thd->lex.mi.log_file_name,
sizeof(mi->rli.until_log_name)-1);
}
else if (thd->lex.mi.relay_log_pos)
{
mi->rli.until_condition= RELAY_LOG_INFO::UNTIL_RELAY_POS;
mi->rli.until_log_pos= thd->lex.mi.relay_log_pos;
strmake(mi->rli.until_log_name, thd->lex.mi.relay_log_name,
sizeof(mi->rli.until_log_name)-1);
}
else
clear_until_condition(&mi->rli);
if (mi->rli.until_condition != RELAY_LOG_INFO::UNTIL_NONE)
{
/* Preparing members for effective until condition checking */
const char *p= fn_ext(mi->rli.until_log_name);
char *p_end;
if (*p)
{
//p points to '.'
mi->rli.until_log_name_extension= strtoul(++p,&p_end, 10);
/*
p_end points to the first invalid character. If it equals
to p, no digits were found, error. If it contains '\0' it
means conversion went ok.
*/
if(p_end==p || *p_end)
slave_errno=ER_BAD_SLAVE_UNTIL_COND;
}
else
slave_errno=ER_BAD_SLAVE_UNTIL_COND;
/* mark the cached result of the UNTIL comparison as "undefined" */
mi->rli.until_log_names_cmp_result=
RELAY_LOG_INFO::UNTIL_LOG_NAMES_CMP_UNKNOWN;
/* Issuing warning then started without --skip-slave-start */
if (!opt_skip_slave_start)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_MISSING_SKIP_SLAVE,
ER(ER_MISSING_SKIP_SLAVE));
}
pthread_mutex_unlock(&mi->rli.data_lock);
}
else if (thd->lex.mi.pos || thd->lex.mi.relay_log_pos)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_UNTIL_COND_IGNORED,
ER(ER_UNTIL_COND_IGNORED));
if(!slave_errno)
slave_errno = start_slave_threads(0 /*no mutex */, slave_errno = start_slave_threads(0 /*no mutex */,
1 /* wait for start */, 1 /* wait for start */,
mi, mi,
master_info_file,relay_log_info_file, master_info_file,relay_log_info_file,
thread_mask); thread_mask);
}
else else
slave_errno = ER_BAD_SLAVE; slave_errno = ER_BAD_SLAVE;
} }
else else
{
//no error if all threads are already started, only a warning //no error if all threads are already started, only a warning
slave_errno= 0;
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SLAVE_WAS_RUNNING, push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SLAVE_WAS_RUNNING,
ER(ER_SLAVE_WAS_RUNNING)); ER(ER_SLAVE_WAS_RUNNING));
}
unlock_slave_threads(mi); unlock_slave_threads(mi);
...@@ -777,6 +844,7 @@ int reset_slave(THD *thd, MASTER_INFO* mi) ...@@ -777,6 +844,7 @@ int reset_slave(THD *thd, MASTER_INFO* mi)
// Clear master's log coordinates (only for good display of SHOW SLAVE STATUS) // Clear master's log coordinates (only for good display of SHOW SLAVE STATUS)
mi->master_log_name[0]= 0; mi->master_log_name[0]= 0;
mi->master_log_pos= BIN_LOG_HEADER_SIZE; mi->master_log_pos= BIN_LOG_HEADER_SIZE;
clear_until_condition(&mi->rli);
// close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0 // close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0
end_master_info(mi); end_master_info(mi);
// and delete these two files // and delete these two files
...@@ -943,6 +1011,7 @@ int change_master(THD* thd, MASTER_INFO* mi) ...@@ -943,6 +1011,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
pthread_mutex_lock(&mi->rli.data_lock); pthread_mutex_lock(&mi->rli.data_lock);
mi->rli.abort_pos_wait++; mi->rli.abort_pos_wait++;
clear_until_condition(&mi->rli);
pthread_cond_broadcast(&mi->data_cond); pthread_cond_broadcast(&mi->data_cond);
pthread_mutex_unlock(&mi->rli.data_lock); pthread_mutex_unlock(&mi->rli.data_lock);
......
...@@ -167,6 +167,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -167,6 +167,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token SUPER_SYM %token SUPER_SYM
%token TRUNCATE_SYM %token TRUNCATE_SYM
%token UNLOCK_SYM %token UNLOCK_SYM
%token UNTIL_SYM
%token UPDATE_SYM %token UPDATE_SYM
%token ACTION %token ACTION
...@@ -665,7 +666,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -665,7 +666,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
query verb_clause create change select do drop insert replace insert2 query verb_clause create change select do drop insert replace insert2
insert_values update delete truncate rename insert_values update delete truncate rename
show describe load alter optimize preload flush show describe load alter optimize preload flush
reset purge begin commit rollback slave master_def master_defs reset purge begin commit rollback slave master_def
master_defs master_file_def
repair restore backup analyze check start repair restore backup analyze check start
field_list field_list_item field_spec kill column_def key_def field_list field_list_item field_spec kill column_def key_def
preload_list preload_keys preload_list preload_keys
...@@ -801,17 +803,25 @@ master_def: ...@@ -801,17 +803,25 @@ master_def:
Lex->mi.password = $3.str; Lex->mi.password = $3.str;
} }
| |
MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys MASTER_PORT_SYM EQ ULONG_NUM
{ {
Lex->mi.log_file_name = $3.str; Lex->mi.port = $3;
} }
| |
MASTER_PORT_SYM EQ ULONG_NUM MASTER_CONNECT_RETRY_SYM EQ ULONG_NUM
{ {
Lex->mi.port = $3; Lex->mi.connect_retry = $3;
} }
| |
MASTER_LOG_POS_SYM EQ ulonglong_num master_file_def
;
master_file_def:
MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys
{
Lex->mi.log_file_name = $3.str;
}
| MASTER_LOG_POS_SYM EQ ulonglong_num
{ {
Lex->mi.pos = $3; Lex->mi.pos = $3;
/* /*
...@@ -827,18 +837,11 @@ master_def: ...@@ -827,18 +837,11 @@ master_def:
*/ */
Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos); Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
} }
| | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
MASTER_CONNECT_RETRY_SYM EQ ULONG_NUM
{
Lex->mi.connect_retry = $3;
}
|
RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
{ {
Lex->mi.relay_log_name = $3.str; Lex->mi.relay_log_name = $3.str;
} }
| | RELAY_LOG_POS_SYM EQ ULONG_NUM
RELAY_LOG_POS_SYM EQ ULONG_NUM
{ {
Lex->mi.relay_log_pos = $3; Lex->mi.relay_log_pos = $3;
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */ /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
...@@ -846,7 +849,6 @@ master_def: ...@@ -846,7 +849,6 @@ master_def:
} }
; ;
/* create a table */ /* create a table */
create: create:
...@@ -1699,7 +1701,11 @@ slave: ...@@ -1699,7 +1701,11 @@ slave:
LEX *lex=Lex; LEX *lex=Lex;
lex->sql_command = SQLCOM_SLAVE_START; lex->sql_command = SQLCOM_SLAVE_START;
lex->type = 0; lex->type = 0;
/* We'll use mi structure for UNTIL options */
bzero((char*) &lex->mi, sizeof(lex->mi));
} }
slave_until
{}
| STOP_SYM SLAVE slave_thread_opts | STOP_SYM SLAVE slave_thread_opts
{ {
LEX *lex=Lex; LEX *lex=Lex;
...@@ -1716,6 +1722,7 @@ start: ...@@ -1716,6 +1722,7 @@ start:
slave_thread_opts: slave_thread_opts:
{ Lex->slave_thd_opt= 0; } { Lex->slave_thd_opt= 0; }
slave_thread_opt_list slave_thread_opt_list
{}
; ;
slave_thread_opt_list: slave_thread_opt_list:
...@@ -1729,6 +1736,28 @@ slave_thread_opt: ...@@ -1729,6 +1736,28 @@ slave_thread_opt:
| RELAY_THREAD { Lex->slave_thd_opt|=SLAVE_IO; } | RELAY_THREAD { Lex->slave_thd_opt|=SLAVE_IO; }
; ;
slave_until:
/*empty*/ {}
| UNTIL_SYM slave_until_opts
{
LEX *lex=Lex;
if ((lex->mi.log_file_name || lex->mi.pos) &&
(lex->mi.relay_log_name || lex->mi.relay_log_pos) ||
!((lex->mi.log_file_name && lex->mi.pos) ||
(lex->mi.relay_log_name && lex->mi.relay_log_pos)))
{
send_error(lex->thd, ER_BAD_SLAVE_UNTIL_COND);
YYABORT;
}
}
;
slave_until_opts:
master_file_def
| slave_until_opts ',' master_file_def ;
restore: restore:
RESTORE_SYM table_or_tables RESTORE_SYM table_or_tables
{ {
...@@ -4520,6 +4549,7 @@ keyword: ...@@ -4520,6 +4549,7 @@ keyword:
| UDF_SYM {} | UDF_SYM {}
| UNCOMMITTED_SYM {} | UNCOMMITTED_SYM {}
| UNICODE_SYM {} | UNICODE_SYM {}
| UNTIL_SYM {}
| USER {} | USER {}
| USE_FRM {} | USE_FRM {}
| VARIABLES {} | VARIABLES {}
......
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