2007-06-01 07:13:20 +02:00
|
|
|
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;
|
|
|
|
**** On Slave ****
|
|
|
|
STOP SLAVE;
|
|
|
|
**** On Master ****
|
|
|
|
SET SESSION BINLOG_FORMAT=ROW;
|
|
|
|
CREATE TABLE t1 (a INT, b INT);
|
|
|
|
CREATE TABLE t2 (c INT, d INT);
|
|
|
|
INSERT INTO t1 VALUES (1,1),(2,4),(3,9);
|
|
|
|
INSERT INTO t2 VALUES (1,1),(2,8),(3,27);
|
|
|
|
UPDATE t1,t2 SET b = d, d = b * 2 WHERE a = c;
|
|
|
|
show binlog events from <binlog_start>;
|
|
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
|
|
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b INT)
|
|
|
|
master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (c INT, d INT)
|
2008-03-28 13:16:41 +01:00
|
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
2007-06-01 07:13:20 +02:00
|
|
|
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
|
|
|
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
2008-03-28 13:16:41 +01:00
|
|
|
master-bin.000001 # Query # # use `test`; COMMIT
|
|
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
2007-06-01 07:13:20 +02:00
|
|
|
master-bin.000001 # Table_map # # table_id: # (test.t2)
|
|
|
|
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
2008-03-28 13:16:41 +01:00
|
|
|
master-bin.000001 # Query # # use `test`; COMMIT
|
|
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
2007-06-01 07:13:20 +02:00
|
|
|
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
|
|
|
master-bin.000001 # Table_map # # table_id: # (test.t2)
|
|
|
|
master-bin.000001 # Update_rows # # table_id: #
|
|
|
|
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
|
2008-03-28 13:16:41 +01:00
|
|
|
master-bin.000001 # Query # # use `test`; COMMIT
|
2007-06-01 07:13:20 +02:00
|
|
|
SELECT * FROM t1;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
2 8
|
|
|
|
3 27
|
|
|
|
SELECT * FROM t2;
|
|
|
|
c d
|
|
|
|
1 2
|
|
|
|
2 16
|
|
|
|
3 54
|
|
|
|
**** On Slave ****
|
2008-03-28 13:16:41 +01:00
|
|
|
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=762;
|
2007-06-01 07:13:20 +02:00
|
|
|
SHOW SLAVE STATUS;
|
|
|
|
Slave_IO_State #
|
|
|
|
Master_Host 127.0.0.1
|
|
|
|
Master_User root
|
|
|
|
Master_Port MASTER_PORT
|
|
|
|
Connect_Retry 1
|
|
|
|
Master_Log_File master-bin.000001
|
2008-03-28 13:16:41 +01:00
|
|
|
Read_Master_Log_Pos 1133
|
2007-06-01 07:13:20 +02:00
|
|
|
Relay_Log_File #
|
|
|
|
Relay_Log_Pos #
|
|
|
|
Relay_Master_Log_File master-bin.000001
|
|
|
|
Slave_IO_Running Yes
|
|
|
|
Slave_SQL_Running No
|
|
|
|
Replicate_Do_DB
|
|
|
|
Replicate_Ignore_DB
|
|
|
|
Replicate_Do_Table
|
|
|
|
Replicate_Ignore_Table
|
|
|
|
Replicate_Wild_Do_Table
|
|
|
|
Replicate_Wild_Ignore_Table
|
|
|
|
Last_Errno 0
|
|
|
|
Last_Error
|
|
|
|
Skip_Counter 0
|
2008-03-28 13:16:41 +01:00
|
|
|
Exec_Master_Log_Pos 762
|
2007-06-01 07:13:20 +02:00
|
|
|
Relay_Log_Space #
|
|
|
|
Until_Condition Master
|
|
|
|
Until_Log_File master-bin.000001
|
2008-03-28 13:16:41 +01:00
|
|
|
Until_Log_Pos 762
|
2007-06-01 07:13:20 +02:00
|
|
|
Master_SSL_Allowed No
|
|
|
|
Master_SSL_CA_File
|
|
|
|
Master_SSL_CA_Path
|
|
|
|
Master_SSL_Cert
|
|
|
|
Master_SSL_Cipher
|
|
|
|
Master_SSL_Key
|
|
|
|
Seconds_Behind_Master #
|
|
|
|
Master_SSL_Verify_Server_Cert No
|
2007-06-13 15:16:33 +02:00
|
|
|
Last_IO_Errno #
|
|
|
|
Last_IO_Error #
|
2007-06-11 22:15:39 +02:00
|
|
|
Last_SQL_Errno 0
|
|
|
|
Last_SQL_Error
|
2007-06-01 07:13:20 +02:00
|
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
|
|
START SLAVE;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
2 4
|
|
|
|
3 9
|
|
|
|
SELECT * FROM t2;
|
|
|
|
c d
|
|
|
|
1 1
|
|
|
|
2 8
|
|
|
|
3 27
|
|
|
|
STOP SLAVE;
|
|
|
|
RESET SLAVE;
|
|
|
|
RESET MASTER;
|
|
|
|
SET SESSION BINLOG_FORMAT=STATEMENT;
|
|
|
|
SET @foo = 12;
|
|
|
|
INSERT INTO t1 VALUES(@foo, 2*@foo);
|
|
|
|
show binlog events from <binlog_start>;
|
|
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
|
|
master-bin.000001 # User var # # @`foo`=12
|
|
|
|
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES(@foo, 2*@foo)
|
|
|
|
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=106;
|
|
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
|
|
START SLAVE;
|
|
|
|
SHOW SLAVE STATUS;
|
|
|
|
Slave_IO_State #
|
|
|
|
Master_Host 127.0.0.1
|
|
|
|
Master_User root
|
|
|
|
Master_Port MASTER_PORT
|
|
|
|
Connect_Retry 1
|
|
|
|
Master_Log_File master-bin.000001
|
|
|
|
Read_Master_Log_Pos 248
|
|
|
|
Relay_Log_File #
|
|
|
|
Relay_Log_Pos #
|
|
|
|
Relay_Master_Log_File master-bin.000001
|
|
|
|
Slave_IO_Running Yes
|
|
|
|
Slave_SQL_Running Yes
|
|
|
|
Replicate_Do_DB
|
|
|
|
Replicate_Ignore_DB
|
|
|
|
Replicate_Do_Table
|
|
|
|
Replicate_Ignore_Table
|
|
|
|
Replicate_Wild_Do_Table
|
|
|
|
Replicate_Wild_Ignore_Table
|
|
|
|
Last_Errno 0
|
|
|
|
Last_Error
|
|
|
|
Skip_Counter 0
|
|
|
|
Exec_Master_Log_Pos 248
|
|
|
|
Relay_Log_Space #
|
|
|
|
Until_Condition None
|
|
|
|
Until_Log_File
|
|
|
|
Until_Log_Pos 0
|
|
|
|
Master_SSL_Allowed No
|
|
|
|
Master_SSL_CA_File
|
|
|
|
Master_SSL_CA_Path
|
|
|
|
Master_SSL_Cert
|
|
|
|
Master_SSL_Cipher
|
|
|
|
Master_SSL_Key
|
|
|
|
Seconds_Behind_Master #
|
|
|
|
Master_SSL_Verify_Server_Cert No
|
2007-06-13 15:16:33 +02:00
|
|
|
Last_IO_Errno #
|
|
|
|
Last_IO_Error #
|
2007-06-11 22:15:39 +02:00
|
|
|
Last_SQL_Errno 0
|
|
|
|
Last_SQL_Error
|
2007-06-01 07:13:20 +02:00
|
|
|
**** On Master ****
|
|
|
|
DROP TABLE t1, t2;
|
BUG#28618 (Skipping into the middle of a group with SQL_SLAVE_SKIP_COUNTER
is possible):
When skipping the beginning of a transaction starting with BEGIN, the OPTION_BEGIN
flag was not set correctly, which caused the slave to not recognize that it was
inside a group. This patch sets the OPTION_BEGIN flag for BEGIN, COMMIT, ROLLBACK,
and XID events. It also adds checks if inside a group before decreasing the
slave skip counter to zero.
Begin_query_log_event was not marked that it could not end a group, which is now
corrected.
mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test:
Correcting slave skip counter to get the correct behaviour.
mysql-test/suite/rpl/r/rpl_slave_skip.result:
Result change.
mysql-test/suite/rpl/t/rpl_slave_skip.test:
Adding tests to check that skipping works for transactions:
- Skipping one group with BEGIN first
- Skipping two groups with BEGIN first
- Skipping one group without BEGIN first but with AUTOCOMMIT=0
- LOAD DATA INFILE under statement-based replication
mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result:
Result change.
sql/log_event.cc:
Adding checks if we're in a group when the slave skip counter is 1.
In that case, we should keep going.
Adding helping member function Log_event::continue_group() denoting
that this event cannot end a group, and if the skip counter indicates
that the group ends after this event, it should not decrease the skip
counter.
Query_log_event will change the OPTION_BEGIN flag for BEGIN, COMMIT, and
ROLLBACK, even when skipping because of a positive skip count, and
Xid_log_event will also affect the OPTION_BEGIN flag, even when being
skipped.
Begin_load_query_log_event cannot end a group, so it is marked to
continue the group.
sql/log_event.h:
Adding helper function Log_event::continue_group().
sql/rpl_rli.h:
Adding Relay_log_info::get_flag() to get the value of a
replication flag.
sql/slave.cc:
Adding debug output and changing debug message.
mysql-test/suite/rpl/data/rpl_bug28618.dat:
New BitKeeper file ``mysql-test/suite/rpl/data/rpl_bug28618.dat''
mysql-test/suite/rpl/t/rpl_slave_skip-slave.opt:
New BitKeeper file ``mysql-test/suite/rpl/t/rpl_slave_skip-slave.opt''
2007-10-19 14:18:41 +02:00
|
|
|
SET SESSION BINLOG_FORMAT=ROW;
|
|
|
|
SET AUTOCOMMIT=0;
|
|
|
|
CREATE TABLE t1 (a INT, b VARCHAR(20)) ENGINE=myisam;
|
|
|
|
CREATE TABLE t2 (a INT, b VARCHAR(20)) ENGINE=myisam;
|
|
|
|
CREATE TABLE t3 (a INT, b VARCHAR(20)) ENGINE=myisam;
|
|
|
|
INSERT INTO t1 VALUES (1,'master/slave');
|
|
|
|
INSERT INTO t2 VALUES (1,'master/slave');
|
|
|
|
INSERT INTO t3 VALUES (1,'master/slave');
|
|
|
|
CREATE TRIGGER tr1 AFTER UPDATE on t1 FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
INSERT INTO t2 VALUES (NEW.a,NEW.b);
|
|
|
|
DELETE FROM t2 WHERE a < NEW.a;
|
|
|
|
END|
|
|
|
|
CREATE TRIGGER tr2 AFTER INSERT on t2 FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
UPDATE t3 SET a =2, b = 'master only';
|
|
|
|
END|
|
|
|
|
**** On Slave ****
|
|
|
|
STOP SLAVE;
|
|
|
|
**** On Master ****
|
|
|
|
UPDATE t1 SET a = 2, b = 'master only' WHERE a = 1;
|
|
|
|
DROP TRIGGER tr1;
|
|
|
|
DROP TRIGGER tr2;
|
|
|
|
INSERT INTO t1 VALUES (3,'master/slave');
|
|
|
|
INSERT INTO t2 VALUES (3,'master/slave');
|
|
|
|
INSERT INTO t3 VALUES (3,'master/slave');
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
SELECT * FROM t2 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
SELECT * FROM t3 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
*** On Slave ***
|
|
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
|
|
START SLAVE;
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
a b
|
|
|
|
1 master/slave
|
|
|
|
3 master/slave
|
|
|
|
SELECT * FROM t2 ORDER BY a;
|
|
|
|
a b
|
|
|
|
1 master/slave
|
|
|
|
3 master/slave
|
|
|
|
SELECT * FROM t3 ORDER BY a;
|
|
|
|
a b
|
|
|
|
1 master/slave
|
|
|
|
3 master/slave
|
|
|
|
DROP TABLE t1, t2, t3;
|
|
|
|
**** Case 2: Row binlog format and transactional tables ****
|
|
|
|
*** On Master ***
|
|
|
|
CREATE TABLE t4 (a INT, b VARCHAR(20)) ENGINE=innodb;
|
|
|
|
CREATE TABLE t5 (a INT, b VARCHAR(20)) ENGINE=innodb;
|
|
|
|
CREATE TABLE t6 (a INT, b VARCHAR(20)) ENGINE=innodb;
|
|
|
|
**** On Slave ****
|
|
|
|
STOP SLAVE;
|
|
|
|
*** On Master ***
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t4 VALUES (2, 'master only');
|
|
|
|
INSERT INTO t5 VALUES (2, 'master only');
|
|
|
|
INSERT INTO t6 VALUES (2, 'master only');
|
|
|
|
COMMIT;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t4 VALUES (3, 'master/slave');
|
|
|
|
INSERT INTO t5 VALUES (3, 'master/slave');
|
|
|
|
INSERT INTO t6 VALUES (3, 'master/slave');
|
|
|
|
COMMIT;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
SELECT * FROM t5 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
*** On Slave ***
|
|
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
|
|
START SLAVE;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
|
|
a b
|
|
|
|
3 master/slave
|
|
|
|
SELECT * FROM t5 ORDER BY a;
|
|
|
|
a b
|
|
|
|
3 master/slave
|
|
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
a b
|
|
|
|
3 master/slave
|
|
|
|
**** On Slave ****
|
|
|
|
STOP SLAVE;
|
|
|
|
*** On Master ***
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t4 VALUES (6, 'master only');
|
|
|
|
INSERT INTO t5 VALUES (6, 'master only');
|
|
|
|
INSERT INTO t6 VALUES (6, 'master only');
|
|
|
|
COMMIT;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t4 VALUES (7, 'master only');
|
|
|
|
INSERT INTO t5 VALUES (7, 'master only');
|
|
|
|
INSERT INTO t6 VALUES (7, 'master only');
|
|
|
|
COMMIT;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
6 master only
|
|
|
|
7 master only
|
|
|
|
SELECT * FROM t5 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
6 master only
|
|
|
|
7 master only
|
|
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
6 master only
|
|
|
|
7 master only
|
|
|
|
*** On Slave ***
|
|
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=10;
|
|
|
|
START SLAVE;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
|
|
a b
|
|
|
|
3 master/slave
|
|
|
|
SELECT * FROM t5 ORDER BY a;
|
|
|
|
a b
|
|
|
|
3 master/slave
|
|
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
a b
|
|
|
|
3 master/slave
|
|
|
|
STOP SLAVE;
|
|
|
|
SET AUTOCOMMIT=0;
|
|
|
|
INSERT INTO t4 VALUES (4, 'master only');
|
|
|
|
INSERT INTO t5 VALUES (4, 'master only');
|
|
|
|
INSERT INTO t6 VALUES (4, 'master only');
|
|
|
|
COMMIT;
|
|
|
|
INSERT INTO t4 VALUES (5, 'master/slave');
|
|
|
|
INSERT INTO t5 VALUES (5, 'master/slave');
|
|
|
|
INSERT INTO t6 VALUES (5, 'master/slave');
|
|
|
|
COMMIT;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
4 master only
|
|
|
|
5 master/slave
|
|
|
|
6 master only
|
|
|
|
7 master only
|
|
|
|
SELECT * FROM t5 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
4 master only
|
|
|
|
5 master/slave
|
|
|
|
6 master only
|
|
|
|
7 master only
|
|
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
a b
|
|
|
|
2 master only
|
|
|
|
3 master/slave
|
|
|
|
4 master only
|
|
|
|
5 master/slave
|
|
|
|
6 master only
|
|
|
|
7 master only
|
|
|
|
*** On Slave ***
|
|
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
|
|
START SLAVE;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
|
|
a b
|
|
|
|
3 master/slave
|
|
|
|
5 master/slave
|
|
|
|
SELECT * FROM t5 ORDER BY a;
|
|
|
|
a b
|
|
|
|
3 master/slave
|
|
|
|
5 master/slave
|
|
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
a b
|
|
|
|
3 master/slave
|
|
|
|
5 master/slave
|
|
|
|
DROP TABLE t4, t5, t6;
|
|
|
|
**** Case 3: Statement logging format and LOAD DATA with non-transactional table ****
|
|
|
|
*** On Master ***
|
|
|
|
CREATE TABLE t10 (a INT, b VARCHAR(20)) ENGINE=myisam;
|
|
|
|
*** On Slave ***
|
|
|
|
STOP SLAVE;
|
|
|
|
*** On Master ***
|
|
|
|
SET SESSION BINLOG_FORMAT=STATEMENT;
|
|
|
|
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|';
|
|
|
|
SELECT * FROM t10 ORDER BY a;
|
|
|
|
a b
|
|
|
|
1 master only
|
|
|
|
2 master only
|
|
|
|
3 master only
|
|
|
|
*** On Slave ***
|
|
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
|
|
START SLAVE;
|
|
|
|
SELECT * FROM t10 ORDER BY a;
|
|
|
|
a b
|
|
|
|
DROP TABLE t10;
|