Cluster node acting as async slave stops with the wrong position after hitting max write set size
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
MySQL patches by Codership |
Fix Released
|
Low
|
Seppo Jaakola | |||
Percona XtraDB Cluster moved to https://jira.percona.com/projects/PXC | Status tracked in 5.6 | |||||
5.5 |
Invalid
|
Undecided
|
Unassigned | |||
5.6 |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
PXC version:
Server version: 5.6.15-rel63.0-log 5.6.15-, Percona XtraDB Cluster - binary (GPL), Release: 25.5, Revision 759 wsrep_25.5.r4061, wsrep_25.5.r4061
I have a three node cluster and one of the nodes is acting as an async slave of MySQL 5.6.15 master. When a write set exceeds the wsrep_max_ws_size limit and replication fails on the PXC node upon commit, then the node reports the wrong stopping position. It basically skips over to the next binlog event.
Suppose the wsrep_max_ws_size variable is set as follows on node1 which is replicating off the async master:
node1 [localhost] {msandbox} (test) > set global wsrep_max_
Query OK, 0 rows affected (0.00 sec)
And suppose following sequence of events are executed on the master:
master [localhost] {msandbox} (test) > insert into t1 values(null, 'test');
Query OK, 1 row affected (0.00 sec)
master [localhost] {msandbox} (test) > create table L (i int primAry key auto_increment, s varchar(1024));
Query OK, 0 rows affected (0.14 sec)
master [localhost] {msandbox} (test) > insert into L (s) values (repeat('i',1024));
Query OK, 1 row affected (0.03 sec)
master [localhost] {msandbox} (test) > insert into t1 values(null, 'boo');
Query OK, 1 row affected (0.00 sec)
master [localhost] {msandbox} (test) > select * from t1;
+---+------+
| i | c |
+---+------+
| 1 | test |
| 2 | boo |
+---+------+
2 rows in set (0.00 sec)
When the insert into the table `L` is replicated it causes the replication to break on PXC node node1.
mysql [localhost] {msandbox} (test) > show slave status\G
*******
Replicate
Replicate_
Master_
Replicate_
Slave_
Last_
Last_
Check the value up to which the binlog events have been executed as reported by slave status:
Exec_Master_
This is where replication will restart from when "START SLAVE" is executed again. Looking at the master's binlogs we see the following:
# at 20058959
#140418 19:28:25 server id 1 end_log_pos 20059038 CRC32 0x72427f1f Query thread_id=577 exec_time=0 error_code=0
SET TIMESTAMP=
BEGIN
/*!*/;
# at 20059038
# at 20059070
#140418 19:28:25 server id 1 end_log_pos 20059070 CRC32 0x04f4f858 Intvar
SET INSERT_ID=1/*!*/;
#140418 19:28:25 server id 1 end_log_pos 20059179 CRC32 0x02bc455a Query thread_id=577 exec_time=0 error_code=0
SET TIMESTAMP=
insert into t1 values(null, 'test')
/*!*/;
# at 20059179
#140418 19:28:25 server id 1 end_log_pos 20059210 CRC32 0x39d62eab Xid = 1832
COMMIT/*!*/;
# at 20059210
#140418 19:29:06 server id 1 end_log_pos 20059350 CRC32 0x6a880863 Query thread_id=577 exec_time=0 error_code=0
SET TIMESTAMP=
create table L (i int primAry key auto_increment, s varchar(1024))
/*!*/;
# at 20059350
#140418 19:29:22 server id 1 end_log_pos 20059429 CRC32 0x20d2f809 Query thread_id=577 exec_time=0 error_code=0
SET TIMESTAMP=
BEGIN
/*!*/;
# at 20059429
# at 20059461
#140418 19:29:22 server id 1 end_log_pos 20059461 CRC32 0x08179788 Intvar
SET INSERT_ID=1/*!*/;
#140418 19:29:22 server id 1 end_log_pos 20059578 CRC32 0x7b6cc5b6 Query thread_id=577 exec_time=0 error_code=0
SET TIMESTAMP=
insert into L (s) values (repeat('i',1024))
/*!*/;
# at 20059578
#140418 19:29:22 server id 1 end_log_pos 20059609 CRC32 0xec70565a Xid = 1834
COMMIT/*!*/;
# at 20059609
#140418 19:30:37 server id 1 end_log_pos 20059688 CRC32 0xd93485b0 Query thread_id=577 exec_time=0 error_code=0
SET TIMESTAMP=
BEGIN
/*!*/;
# at 20059688
# at 20059720
#140418 19:30:37 server id 1 end_log_pos 20059720 CRC32 0xd65c0e86 Intvar
SET INSERT_ID=2/*!*/;
#140418 19:30:37 server id 1 end_log_pos 20059828 CRC32 0x228ecfc3 Query thread_id=577 exec_time=0 error_code=0
SET TIMESTAMP=
insert into t1 values(null, 'boo')
/*!*/;
# at 20059828
#140418 19:30:37 server id 1 end_log_pos 20059859 CRC32 0x8e3d246d Xid = 1836
COMMIT/*!*/;
Now we can see that the position 20059609 is the position of the next binlog event group and not the one that failed:
# at 20059609
#140418 19:30:37 server id 1 end_log_pos 20059688 CRC32 0xd93485b0 Query thread_id=577 exec_time=0 error_code=0
SET TIMESTAMP=
BEGIN
/*!*/;
# at 20059688
# at 20059720
#140418 19:30:37 server id 1 end_log_pos 20059720 CRC32 0xd65c0e86 Intvar
SET INSERT_ID=2/*!*/;
#140418 19:30:37 server id 1 end_log_pos 20059828 CRC32 0x228ecfc3 Query thread_id=577 exec_time=0 error_code=0
SET TIMESTAMP=
insert into t1 values(null, 'boo')
/*!*/;
# at 20059828
#140418 19:30:37 server id 1 end_log_pos 20059859 CRC32 0x8e3d246d Xid = 1836
COMMIT/*!*/;
So executing a subsequent "START SLAVE" on the failed slave, causes it to restart the replication from the next binlog event skipping the one where it failed:
mysql [localhost] {msandbox} (test) > start slave;
Query OK, 0 rows affected (0.01 sec)
mysql [localhost] {msandbox} (test) > select * from t1;
+---+------+
| i | c |
+---+------+
| 1 | test |
| 2 | boo |
+---+------+
2 rows in set (0.00 sec)
As we can see that the slave proceeded to execute the next INSERT into the table `t` after the failed one. And this leads to data inconsistencies.
Changed in codership-mysql: | |
status: | Fix Committed → Fix Released |
milestone: | 5.6.20-25.6 → 5.6.21-25.9 |
As per Alex (https:/ /bugs.launchpad .net/codership- mysql/+ bug/1280557/ comments/ 12) this is related to lp:1280557 and lp:1270920