DDL is replicated even when sql_log_bin=0, and GTID is incremented in remote node
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Percona XtraDB Cluster moved to https://jira.percona.com/projects/PXC | Status tracked in 5.6 | |||||
| 5.6 |
Fix Released
|
Undecided
|
Unassigned | ||
| 5.7 |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
On PXC 5.7.18, CREATE TABLE is replicated even when sql_log_bin=0; And on top of that, GTID is incremented in remote node but not where the CREATE has run:
On node1:
PXC: root@localhost (sbtest) > show master status\G
*******
File: pxc1-bin.000006
Position: 1065
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
PXC: root@localhost (sbtest) > set sql_log_bin=0;
Query OK, 0 rows affected (0.00 sec)
PXC: root@localhost (sbtest) > create table nobinlog (i int not null auto_increment primary key) engine innodb;
Query OK, 0 rows affected (0.00 sec)
-- after the CREATE the local GTID was NOT incremented
PXC: root@localhost (sbtest) > show master status\G
*******
File: pxc1-bin.000006
Position: 1065
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
On node2:
-- before the CREATE
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc2-bin.000002
Position: 641
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
-- after the CREATE GTID was in fact incremented
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc2-bin.000002
Position: 863
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
PXC: root@localhost ((none)) > use sbtest;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
-- and the table was replicated!
Database changed
PXC: root@localhost (sbtest) > show tables;
+------
| Tables_in_sbtest |
+------
| nobinlog |
| sbtest1 |
+------
2 rows in set (0.00 sec)
Not sure whether to file separate bug; Critical part seems to be the GTID bit since it makes the sequence inconsistent. But replicating tables when it's not desired seems a bug as well. If a separate bug is necessary, keep this for GTID part please and Support will file separate one.
Sample cnf:
[root@pxc2 /]# cat /etc/my.cnf
[mysql]
port = 3306
socket = /var/lib/
prompt='PXC: \u@\h (\d) > '
[client]
port = 3306
socket = /var/lib/
[mysqld]
socket = /var/lib/
datadir=
user=mysql
wsrep_cluster_
wsrep_provider=
wsrep_provider_
wsrep_slave_threads = 2
wsrep_auto_
wsrep_sst_
wsrep_sst_
wsrep_cluster_
wsrep_node_
wsrep_node_
innodb_
innodb_
innodb_
innodb-
innodb-
innodb-
innodb_
log_bin
server_id=1
log_slave_updates
binlog_format=ROW
enforce_
gtid_mode=on
[sst]
streamfmt=xbstream
Changed in percona-xtradb-cluster: | |
status: | New → Confirmed |
Jericho Rivera (jericho-rivera) wrote : | #1 |
Jericho Rivera (jericho-rivera) wrote : | #2 |
When wsrep_on is used to prevent replicating the CREATE:
On node1:
mysql> show master status;
+------
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------
| mysql-bin.000001 | 320 | | | 4dd1edef-
+------
1 row in set (0.01 sec)
mysql> set wsrep_on=OFF;
Query OK, 0 rows affected (0.00 sec)
mysql> select @@wsrep_on;
+------------+
| @@wsrep_on |
+------------+
| 0 |
+------------+
1 row in set (0.00 sec)
mysql> create table nobinlog2 (id int primary key auto_increment, s varchar(10)) engine=innodb;
Query OK, 0 rows affected (0.03 sec)
mysql> show master status;
+------
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------
| mysql-bin.000001 | 534 | | | 4dd1edef-
5eab47c5-
+------
1 row in set (0.00 sec)
On node2 before and after CREATE GTID did not increment:
mysql> show master status;
+------
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------
| mysql-bin.000001 | 320 | | | 4dd1edef-
+------
1 row in set (0.00 sec)
mysql> show master status;
+------
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------
| mysql-bin.000001 | 320 | | | 4dd1edef-
+------
1 row in set (0.00 sec)
Jericho Rivera (jericho-rivera) wrote : | #3 |
Comment #2 though is just to illustrate that with wsrep_on=OFF the CREATE TABLE is not replicated to the other node.
markus_albe (markus-albe) wrote : | #4 |
The same happens with user management statements; On the same setup I did my initial testing:
node1, with sql_log_bin=1:
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc1-bin.000006
Position: 1065
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
PXC: root@localhost ((none)) > CREATE USER 'demo'@'localhost' IDENTIFIED BY 's3kr3t';
Query OK, 0 rows affected (0.01 sec)
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc1-bin.000006
Position: 1318
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
PXC: root@localhost ((none)) > SET sql_log_bin=0;
Query OK, 0 rows affected (0.00 sec)
PXC: root@localhost ((none)) > CREATE USER 'demo2'@'localhost' IDENTIFIED BY 's3kr3t';
Query OK, 0 rows affected (0.00 sec)
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc1-bin.000006
Position: 1318
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
PXC: root@localhost ((none)) > DROP USER 'demo2'@'localhost' ;
Query OK, 0 rows affected (0.00 sec)
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc1-bin.000006
Position: 1318
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
PXC: root@localhost ((none)) > GRANT ALL PRIVILEGES ON *.* TO 'demo'@'localhost';
Query OK, 0 rows affected (0.01 sec)
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc1-bin.000006
Position: 1318
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
On node2 I ran SHOW MASTER STATUS after each command on node1:
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc2-bin.000002
Position: 863
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec) ...
Krunal Bauskar (krunal-bauskar) wrote : | #5 |
Let me re-define the problem.
* CREATE TABLE (or any DDL) is replicated using TOI and TOI doesn't need binlog write-set as it is statement level replication.
* DML needs binlog for write-set creation and so if DML is executed under sql_log_bin=0 then DML is not replicated.
Check the following test-case:
-------
create database test;
use test;
select @@global.
create table nobinlog (i int not null auto_increment primary key) engine innodb;
insert into nobinlog values (1);
select @@global.
set sql_log_bin=0;
insert into nobinlog values (2);
select * from nobinlog;
select @@global.
set sql_log_bin=1;
insert into nobinlog values (3);
select @@global.
------
In above test-case nobinlog table is replicated whether it is inside sql_log_bin=0 or 1.
DML statement insert (2) is not replicated and neither is GTID incremented as binlog is not written.
Sveta Smirnova (svetasmirnova) wrote : | #6 |
Workaround: wsrep_replicate
markus_albe (markus-albe) wrote : | #7 |
The same happens with user management statements; On the same setup I did my initial testing:
node1, with sql_log_bin=1:
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc1-bin.000006
Position: 1065
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
PXC: root@localhost ((none)) > CREATE USER 'demo'@'localhost' IDENTIFIED BY 's3kr3t';
Query OK, 0 rows affected (0.01 sec)
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc1-bin.000006
Position: 1318
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
PXC: root@localhost ((none)) > SET sql_log_bin=0;
Query OK, 0 rows affected (0.00 sec)
PXC: root@localhost ((none)) > CREATE USER 'demo2'@'localhost' IDENTIFIED BY 's3kr3t';
Query OK, 0 rows affected (0.00 sec)
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc1-bin.000006
Position: 1318
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
PXC: root@localhost ((none)) > DROP USER 'demo2'@'localhost' ;
Query OK, 0 rows affected (0.00 sec)
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc1-bin.000006
Position: 1318
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
PXC: root@localhost ((none)) > GRANT ALL PRIVILEGES ON *.* TO 'demo'@'localhost';
Query OK, 0 rows affected (0.01 sec)
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc1-bin.000006
Position: 1318
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec)
On node2 I ran SHOW MASTER STATUS after each command on node1:
PXC: root@localhost ((none)) > show master status\G
*******
File: pxc2-bin.000002
Position: 863
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: f1474806-
1 row in set (0.00 sec) ...
Sveta Smirnova (svetasmirnova) wrote : | #8 |
Suggested fix: all statements to be not written into binary log if sql_log_bin=0 and the GTID sequence of all nodes will remain in-sync.
Krunal Bauskar (krunal-bauskar) wrote : | #9 |
commit 183043e54f41d2d
Author: Krunal Bauskar <email address hidden>
Date: Mon Jul 31 13:11:50 2017 +0530
- PXC#841: DDL is replicated even when sql_log_bin=0, and GTID is
incremented in remote node
sql_log_bin=0 will stop generation of binary logs data.
In turn it will also stop replication and GTID increment.
PXC executes DDL through TOI and DML through normal replication.
Since binary log is not-generated DML replication was already blocked.
DDL path didn't had a check for sql_log_bin.
Added the needed check.
Percona now uses JIRA for bug reports so this bug report is migrated to: https:/
Confirming bug on 5.6 as well but slightly different outcome:
On node1: ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- --+ ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- --+ 5c99-11e7- b402-00163e4de3 0b:1-4 | ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- --+
mysql> show master status;
+------
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------
| mysql-bin.000003 | 191 | | | 34408038-
+------
1 row in set (0.00 sec)
mysql> select @@sql_log_bin;
+---------------+
| @@sql_log_bin |
+---------------+
| 1 |
+---------------+
1 row in set (0.00 sec)
mysql> select @@global. sql_log_ bin; ------- ------- --+ sql_log_ bin | ------- ------- --+ ------- ------- --+
+------
| @@global.
+------
| 1 |
+------
1 row in set (0.00 sec)
mysql> set sql_log_bin=0;
Query OK, 0 rows affected (0.01 sec)
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> create table nobinlog (id int primary key auto_increment not null, s varchar(10)) engine=innodb;
Query OK, 0 rows affected (0.03 sec)
mysql> show master status; ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- --+ ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- --+ 5c99-11e7- b402-00163e4de3 0b:1-4 | ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- --+
+------
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------
| mysql-bin.000003 | 191 | | | 34408038-
+------
1 row in set (0.00 sec)
One node2: ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- --+ ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- --+ 5c99-11e7- b402-00163e4de3 0b:1-4 | ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- --+
before create table:
mysql> show master status;
+------
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------
| mysql-bin.000004 | 191 | | | 34408038-
+------
1 row in set (0.00 sec)
after create table: ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- + ------- -----+- ------- --+---- ------- ---+--- ------- ------- -+----- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- + 5c99-11e7- b402-00163e4de3 0b:1-4,
mysql> show master status;
+------
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------
| mysql-bin.000004 | 408 | | | 34408038-
4...