-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
let rpl_repl_slave_acl can use binlog
Summary: Context: If we use SUPER_USER priv to replay binlog and write metadata to dst replicaset, SUPER_USER writing to read-only master can cause GTID not generated and therefore these events will not be replicated to slaves and will be ignored by promotion, causing a silent dataloss Fix: To fix this we extend REPL_SLAVE_ACL so that binlog can bypass it and run like SUPER_USER but without causing GTID not generated. Reviewed By: yoshinorim Differential Revision: D17004347 fbshipit-source-id: 1a67821
- Loading branch information
1 parent
27ccf9e
commit cfd9b93
Showing
7 changed files
with
172 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
include/master-slave.inc | ||
Warnings: | ||
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. | ||
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. | ||
[connection master] | ||
create table tbl (id int primary key, value int); | ||
insert into tbl values (1, 1); | ||
update tbl set value=value+1 where id=1; | ||
insert into tbl values (2, 10); | ||
flush logs; | ||
select id, value from tbl; | ||
id value | ||
1 2 | ||
2 10 | ||
drop table tbl; | ||
include/sync_slave_sql_with_master.inc | ||
show tables like 'tbl'; | ||
Tables_in_test (tbl) | ||
create user 'olm'@'localhost' IDENTIFIED BY 'password'; | ||
grant all privileges on *.* to 'olm'@'localhost'; | ||
revoke super on *.* from 'olm'@'localhost'; | ||
show tables like 'tbl'; | ||
Tables_in_test (tbl) | ||
create user 'normal'@'localhost' IDENTIFIED BY 'password'; | ||
grant all privileges on *.* to 'normal'@'localhost'; | ||
revoke super on *.* from 'normal'@'localhost'; | ||
revoke REPLICATION SLAVE on *.* from 'normal'@'localhost'; | ||
revoke Admin port on *.* from 'normal'@'localhost'; | ||
show tables like 'tbl'; | ||
Tables_in_test (tbl) | ||
User without replication slave privilege can't replay binlog | ||
select * from test.tbl; | ||
ERROR 42S02: Table 'test.tbl' doesn't exist | ||
grant REPLICATION SLAVE on *.* to 'normal'@'localhost'; | ||
User without replication slave privilege can't replay binlog | ||
select * from test.tbl; | ||
ERROR 42S02: Table 'test.tbl' doesn't exist | ||
revoke REPLICATION SLAVE on *.* from 'normal'@'localhost'; | ||
grant Admin port on *.* to 'normal'@'localhost'; | ||
User without admin port privilege can't replay binlog | ||
select * from test.tbl; | ||
ERROR 42S02: Table 'test.tbl' doesn't exist | ||
User user who has replication slave privilege and admin port can replay binlog | ||
include/sync_slave_sql_with_master.inc | ||
select * from test.tbl; | ||
id value | ||
1 2 | ||
2 10 | ||
select * from test.tbl; | ||
id value | ||
1 2 | ||
2 10 | ||
DROP user 'olm'@'localhost'; | ||
DROP user 'normal'@'localhost'; | ||
DROP table tbl; | ||
include/rpl_end.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
source include/have_gtid.inc; | ||
source include/master-slave.inc; | ||
|
||
connection master; | ||
create table tbl (id int primary key, value int); | ||
insert into tbl values (1, 1); | ||
update tbl set value=value+1 where id=1; | ||
insert into tbl values (2, 10); | ||
|
||
let $MYSQLD_DATADIR= `select @@datadir;`; | ||
let $BINLOG_NAME = query_get_value(show master status, File, 1); | ||
--copy_file $MYSQLD_DATADIR/$BINLOG_NAME $MYSQLD_DATADIR/master-bin.saved | ||
|
||
flush logs; | ||
connection master; | ||
select id, value from tbl; | ||
drop table tbl; | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
connection slave; | ||
show tables like 'tbl'; | ||
|
||
connection master; | ||
create user 'olm'@'localhost' IDENTIFIED BY 'password'; | ||
grant all privileges on *.* to 'olm'@'localhost'; | ||
revoke super on *.* from 'olm'@'localhost'; | ||
show tables like 'tbl'; | ||
|
||
connection master; | ||
create user 'normal'@'localhost' IDENTIFIED BY 'password'; | ||
grant all privileges on *.* to 'normal'@'localhost'; | ||
revoke super on *.* from 'normal'@'localhost'; | ||
revoke REPLICATION SLAVE on *.* from 'normal'@'localhost'; | ||
revoke Admin port on *.* from 'normal'@'localhost'; | ||
show tables like 'tbl'; | ||
|
||
--echo User without replication slave privilege can't replay binlog | ||
--disable_abort_on_error | ||
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.saved --skip-gtids --skip-empty-trans --database test | $MYSQL --user='normal' --password='password' --port=$MASTER_MYPORT --host=127.0.0.1 | ||
--enable_abort_on_error | ||
connection master; | ||
# Table 'test.tbl' doesn't exist | ||
--error 1146 | ||
select * from test.tbl; | ||
|
||
grant REPLICATION SLAVE on *.* to 'normal'@'localhost'; | ||
--echo User without replication slave privilege can't replay binlog | ||
--disable_abort_on_error | ||
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.saved --skip-gtids --skip-empty-trans --database test | $MYSQL --user='normal' --password='password' --port=$MASTER_MYPORT --host=127.0.0.1 | ||
--enable_abort_on_error | ||
connection master; | ||
# Table 'test.tbl' doesn't exist | ||
--error 1146 | ||
select * from test.tbl; | ||
revoke REPLICATION SLAVE on *.* from 'normal'@'localhost'; | ||
|
||
grant Admin port on *.* to 'normal'@'localhost'; | ||
--echo User without admin port privilege can't replay binlog | ||
--disable_abort_on_error | ||
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.saved --skip-gtids --skip-empty-trans --database test | $MYSQL --user='normal' --password='password' --port=$MASTER_MYPORT --host=127.0.0.1 | ||
--enable_abort_on_error | ||
connection master; | ||
# Table 'test.tbl' doesn't exist | ||
--error 1146 | ||
select * from test.tbl; | ||
|
||
|
||
--echo User user who has replication slave privilege and admin port can replay binlog | ||
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.saved --skip-gtids --skip-empty-trans --database test | $MYSQL --user='olm' --password='password' --port=$MASTER_MYPORT --host=127.0.0.1 | ||
--remove_file $MYSQLD_DATADIR/master-bin.saved | ||
|
||
# with replication privilege, mysqlbinlog can generate binlog and gtid | ||
--source include/sync_slave_sql_with_master.inc | ||
connection master; | ||
select * from test.tbl; | ||
|
||
connection slave; | ||
select * from test.tbl; | ||
|
||
connection master; | ||
DROP user 'olm'@'localhost'; | ||
DROP user 'normal'@'localhost'; | ||
DROP table tbl; | ||
--source include/rpl_end.inc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters