Commit 5a5fc343 authored by unknown's avatar unknown

Last part of fix for BUG#7998 "Replication should be more clever about when to...

Last part of fix for BUG#7998 "Replication should be more clever about when to replicate RELEASE_LOCK()" + fixes after merge


mysql-test/r/drop_temp_table.result:
  result update
mysql-test/r/mix_innodb_myisam_binlog.result:
  result update
mysql-test/r/rpl000001.result:
  result update
mysql-test/r/rpl_change_master.result:
  result update
mysql-test/r/rpl_deadlock.result:
  result update (merge)
mysql-test/t/rpl000001.test:
  can't rely on GET_LOCK() to do slave synchro (use table lock instead)
mysql-test/t/rpl_change_master.test:
  changing the test as we can't use GET_LOCK() for slave synchro
mysql-test/t/rpl_deadlock.test:
  update (merge) binlog positions
mysql-test/t/rpl_get_lock.test:
  comment
parent 1972aa7d
...@@ -18,5 +18,4 @@ master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table ...@@ -18,5 +18,4 @@ master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table
master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table `table:name` (a int) master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table `table:name` (a int)
master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table shortn2 (a int) master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table shortn2 (a int)
master-bin.000001 # Query 1 # use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`shortn2`,`drop-temp+table-test`.`table:name`,`drop-temp+table-test`.`shortn1` master-bin.000001 # Query 1 # use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`shortn2`,`drop-temp+table-test`.`table:name`,`drop-temp+table-test`.`shortn1`
master-bin.000001 # Query 1 # use `drop-temp+table-test`; DO RELEASE_LOCK("a")
drop database `drop-temp+table-test`; drop database `drop-temp+table-test`;
...@@ -93,7 +93,6 @@ master-bin.000001 96 Query 1 # use `test`; BEGIN ...@@ -93,7 +93,6 @@ master-bin.000001 96 Query 1 # use `test`; BEGIN
master-bin.000001 165 Query 1 # use `test`; insert into t1 values(8) master-bin.000001 165 Query 1 # use `test`; insert into t1 values(8)
master-bin.000001 253 Query 1 # use `test`; insert into t2 select * from t1 master-bin.000001 253 Query 1 # use `test`; insert into t2 select * from t1
master-bin.000001 348 Query 1 # use `test`; ROLLBACK master-bin.000001 348 Query 1 # use `test`; ROLLBACK
master-bin.000001 420 Query 1 # use `test`; DO RELEASE_LOCK("a")
delete from t1; delete from t1;
delete from t2; delete from t2;
reset master; reset master;
......
...@@ -33,27 +33,12 @@ select sum(length(word)) from t1; ...@@ -33,27 +33,12 @@ select sum(length(word)) from t1;
sum(length(word)) sum(length(word))
1022 1022
drop table t1,t3; drop table t1,t3;
create table t1 (n int) engine=myisam;
reset master; reset master;
stop slave; stop slave;
reset slave; reset slave;
create table t1(n int); lock tables t1 read;
select get_lock("hold_slave",10);
get_lock("hold_slave",10)
1
explain extended select get_lock("hold_slave",10);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select sql_no_cache get_lock(_latin1'hold_slave',10) AS `get_lock("hold_slave",10)`
start slave; start slave;
select release_lock("hold_slave");
release_lock("hold_slave")
1
explain extended select release_lock("hold_slave");
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select sql_no_cache release_lock(_latin1'hold_slave') AS `release_lock("hold_slave")`
unlock tables; unlock tables;
create table t2(id int); create table t2(id int);
insert into t2 values(connection_id()); insert into t2 values(connection_id());
......
...@@ -4,26 +4,20 @@ reset master; ...@@ -4,26 +4,20 @@ reset master;
reset slave; 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;
select get_lock("a",5);
get_lock("a",5)
1
create table t1(n int); create table t1(n int);
insert into t1 values(1+get_lock("a",15)*0);
insert into t1 values(2);
stop slave;
select * from t1; select * from t1;
n n
1 stop slave sql_thread;
insert into t1 values(1);
insert into t1 values(2);
stop slave;
show slave status; show slave status;
Slave_IO_State 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 Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Slave_IO_State 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 Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 377 # # master-bin.000001 No No 0 0 289 # None 0 No # # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 358 # # master-bin.000001 No No 0 0 182 # None 0 No #
change master to master_user='root'; change master to master_user='root';
show slave status; show slave status;
Slave_IO_State 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 Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Slave_IO_State 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 Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 289 # # master-bin.000001 No No 0 0 289 # None 0 No # # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 182 # # master-bin.000001 No No 0 0 182 # None 0 No #
select release_lock("a");
release_lock("a")
1
start slave; start slave;
select * from t1; select * from t1;
n n
......
...@@ -11,13 +11,13 @@ create table t4 (a int) engine=innodb; ...@@ -11,13 +11,13 @@ create table t4 (a int) engine=innodb;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0', `a` int(11) NOT NULL,
KEY `a` (`a`) KEY `a` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
show create table t2; show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` int(11) NOT NULL default '0', `a` int(11) NOT NULL,
KEY `a` (`a`) KEY `a` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
stop slave; stop slave;
...@@ -39,9 +39,9 @@ a ...@@ -39,9 +39,9 @@ a
22 22
show slave status; show slave status;
Slave_IO_State 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 Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Slave_IO_State 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 Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 13110 # # master-bin.000001 Yes Yes 0 0 13110 # None 0 No # # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 19116 # # master-bin.000001 Yes Yes 0 0 19116 # None 0 No #
stop slave; stop slave;
change master to master_log_pos=401; change master to master_log_pos=534;
begin; begin;
select * from t2 for update; select * from t2 for update;
a a
...@@ -57,10 +57,10 @@ a ...@@ -57,10 +57,10 @@ a
22 22
show slave status; show slave status;
Slave_IO_State 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 Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Slave_IO_State 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 Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 13110 # # master-bin.000001 Yes Yes 0 0 13110 # None 0 No # # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 19116 # # master-bin.000001 Yes Yes 0 0 19116 # None 0 No #
set global max_relay_log_size=0; set global max_relay_log_size=0;
stop slave; stop slave;
change master to master_log_pos=401; change master to master_log_pos=534;
begin; begin;
select * from t2 for update; select * from t2 for update;
a a
...@@ -77,5 +77,5 @@ a ...@@ -77,5 +77,5 @@ a
22 22
show slave status; show slave status;
Slave_IO_State 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 Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Slave_IO_State 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 Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 13110 # # master-bin.000001 Yes Yes 0 0 13110 # None 0 No # # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 19116 # # master-bin.000001 Yes Yes 0 0 19116 # None 0 No #
drop table t1,t2; drop table t1,t2;
...@@ -39,7 +39,13 @@ save_master_pos; ...@@ -39,7 +39,13 @@ save_master_pos;
connection slave; connection slave;
sync_with_master; sync_with_master;
#test handling of aborted connection in the middle of update # Test if the slave SQL thread can be more than 16K behind the slave
# I/O thread (> IO_SIZE)
connection master;
# we'll use table-level locking to delay slave SQL thread
create table t1 (n int) engine=myisam;
sync_slave_with_master;
connection master; connection master;
reset master; reset master;
connection slave; connection slave;
...@@ -47,29 +53,26 @@ stop slave; ...@@ -47,29 +53,26 @@ stop slave;
reset slave; reset slave;
connection master; connection master;
create table t1(n int);
#we want the log to exceed 16K to test deal with the log that is bigger than
#IO_SIZE
let $1=5000; let $1=5000;
# Generate 16K of relay log
disable_query_log; disable_query_log;
while ($1) while ($1)
{ {
eval insert into t1 values($1+get_lock("hold_slave",10)*0); eval insert into t1 values($1);
dec $1; dec $1;
} }
enable_query_log; enable_query_log;
# Try to cause a large relay log lag on the slave # Try to cause a large relay log lag on the slave by locking t1
connection slave; connection slave;
select get_lock("hold_slave",10); lock tables t1 read;
explain extended select get_lock("hold_slave",10);
start slave; start slave;
#hope this is long enough for I/O thread to fetch over 16K relay log data #hope this is long enough for I/O thread to fetch over 16K relay log data
sleep 3; sleep 3;
select release_lock("hold_slave");
explain extended select release_lock("hold_slave");
unlock tables; unlock tables;
#test handling of aborted connection in the middle of update
connection master; connection master;
create table t2(id int); create table t2(id int);
insert into t2 values(connection_id()); insert into t2 values(connection_id());
......
# Verify that after CHANGE MASTER, replication (I/O thread and SQL
# thread) restart from where SQL thread left, not from where
# I/O thread left (some old bug fixed in 4.0.17)
source include/master-slave.inc; source include/master-slave.inc;
connection slave;
select get_lock("a",5);
connection master; connection master;
# Make SQL slave thread advance a bit
create table t1(n int); create table t1(n int);
insert into t1 values(1+get_lock("a",15)*0); sync_slave_with_master;
select * from t1;
# Now stop it and make I/O slave thread be ahead
stop slave sql_thread;
connection master;
insert into t1 values(1);
insert into t1 values(2); insert into t1 values(2);
save_master_pos; save_master_pos;
connection slave; connection slave;
--real_sleep 3; # can't sync_with_master as we should be blocked --real_sleep 3; # wait for I/O thread to have read updates
stop slave; stop slave;
select * from t1;
--replace_result $MASTER_MYPORT MASTER_MYPORT --replace_result $MASTER_MYPORT MASTER_MYPORT
--replace_column 1 # 8 # 9 # 23 # 33 # --replace_column 1 # 8 # 9 # 23 # 33 #
show slave status; show slave status;
...@@ -18,8 +25,6 @@ change master to master_user='root'; ...@@ -18,8 +25,6 @@ change master to master_user='root';
--replace_result $MASTER_MYPORT MASTER_MYPORT --replace_result $MASTER_MYPORT MASTER_MYPORT
--replace_column 1 # 8 # 9 # 23 # 33 # --replace_column 1 # 8 # 9 # 23 # 33 #
show slave status; show slave status;
# Will restart from after the values(2), which is bug
select release_lock("a");
start slave; start slave;
sync_with_master; sync_with_master;
select * from t1; select * from t1;
......
...@@ -68,7 +68,7 @@ show slave status; ...@@ -68,7 +68,7 @@ show slave status;
# 2) Test lock wait timeout # 2) Test lock wait timeout
stop slave; stop slave;
change master to master_log_pos=401; # the BEGIN log event change master to master_log_pos=534; # the BEGIN log event
begin; begin;
select * from t2 for update; # hold lock select * from t2 for update; # hold lock
start slave; start slave;
...@@ -89,7 +89,7 @@ set global max_relay_log_size=0; ...@@ -89,7 +89,7 @@ set global max_relay_log_size=0;
# This is really copy-paste of 2) of above # This is really copy-paste of 2) of above
stop slave; stop slave;
change master to master_log_pos=401; change master to master_log_pos=534;
begin; begin;
select * from t2 for update; select * from t2 for update;
start slave; start slave;
......
...@@ -22,6 +22,13 @@ connection slave; ...@@ -22,6 +22,13 @@ connection slave;
sync_with_master; sync_with_master;
select get_lock("lock",3); select get_lock("lock",3);
select * from t1; select * from t1;
# There is no point in testing REPLICATIION of the IS_*_LOCK
# functions; slave does not run with the same concurrency context as
# master (generally in slave we can't know that on master this lock
# was already held by another connection and so that the the
# get_lock() we're replicating timed out on master hence returned 0,
# or that the is_free_lock() we're playing returned 0 etc.
# But here all we do is test these functions outside of replication.
select is_free_lock("lock"), is_used_lock("lock") = connection_id(); select is_free_lock("lock"), is_used_lock("lock") = connection_id();
explain extended select is_free_lock("lock"), is_used_lock("lock"); explain extended select is_free_lock("lock"), is_used_lock("lock");
# Check lock functions # Check lock functions
......
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