forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a flag to delay auto binlog rotation when a raft purge is active
Summary: Purging logs in raft is very expensive because we read logs to find the last opid for every to-be-purged binlog. Ideally we should be storing this info in the index file like the prev gtid set but that is a big work item. Purge can cause stalls in the commit pipeline when auto rotation is triggered (current binlog goes beyond max_binlog_size). To quick fix added an atomic to indicate if a raft purge is active, if yes, we delay to auto rotate operation in group commit, avoiding stalls at the cost of slighly exceeding max_binlog_size. Reviewed By: anirbanr-fb Differential Revision: D40743288 fbshipit-source-id: f51a654
- Loading branch information
1 parent
fa585fd
commit 350c622
Showing
10 changed files
with
188 additions
and
4 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
52 changes: 52 additions & 0 deletions
52
mysql-test/suite/rpl_raft/r/rpl_raft_delay_rotation_on_raft_log_purge.result
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,52 @@ | ||
include/raft_3_node.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. | ||
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] | ||
include/rpl_connect.inc [creating server_4] | ||
include/rpl_connect.inc [creating server_5] | ||
show status like 'rpl_raft_role'; | ||
Variable_name Value | ||
Rpl_raft_role LEADER | ||
show status like 'rpl_raft_role'; | ||
Variable_name Value | ||
Rpl_raft_role FOLLOWER | ||
reset master; | ||
show status like 'rpl_raft_role'; | ||
Variable_name Value | ||
Rpl_raft_role FOLLOWER | ||
reset master; | ||
FLUSH BINARY LOGS; | ||
FLUSH BINARY LOGS; | ||
FLUSH BINARY LOGS; | ||
FLUSH BINARY LOGS; | ||
SELECT SLEEP(1); | ||
SLEEP(1) | ||
0 | ||
SET @@GLOBAL.max_binlog_size = 4096; | ||
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT); | ||
SET debug_sync='raft_purge_flag_set SIGNAL purge_reached WAIT_FOR purge_continue'; | ||
PURGE RAFT LOGS BEFORE NOW(); | ||
SET debug_sync='now WAIT_FOR purge_reached'; | ||
INSERT INTO t1 VALUES(1, REPEAT('a', 5000)); | ||
SET debug_sync='now SIGNAL purge_continue'; | ||
Warnings: | ||
Warning 1868 file ./binary-logs-13000.000006 was not purged because it is the active log file. | ||
"There should be only one raft log:" | ||
SHOW RAFT LOGS; | ||
Log_name File_size Encrypted | ||
# # No | ||
INSERT INTO t1 VALUES(2, ""); | ||
"Now we should have two raft logs:" | ||
SHOW RAFT LOGS; | ||
Log_name File_size Encrypted | ||
# # No | ||
# # No | ||
SET @@GLOBAL.max_binlog_size = default; | ||
DROP TABLE t1; | ||
include/sync_slave_sql_with_master.inc | ||
include/sync_slave_sql_with_master.inc | ||
include/rpl_end.inc |
43 changes: 43 additions & 0 deletions
43
mysql-test/suite/rpl_raft/t/rpl_raft_delay_rotation_on_raft_log_purge.test
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,43 @@ | ||
source include/have_debug_sync.inc; | ||
source ../include/raft_3_node.inc; | ||
|
||
connection server_1; | ||
FLUSH BINARY LOGS; | ||
FLUSH BINARY LOGS; | ||
FLUSH BINARY LOGS; | ||
FLUSH BINARY LOGS; | ||
SELECT SLEEP(1); | ||
|
||
SET @@GLOBAL.max_binlog_size = 4096; | ||
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT); | ||
|
||
SET debug_sync='raft_purge_flag_set SIGNAL purge_reached WAIT_FOR purge_continue'; | ||
send PURGE RAFT LOGS BEFORE NOW(); | ||
|
||
connection server_1_1; | ||
SET debug_sync='now WAIT_FOR purge_reached'; | ||
INSERT INTO t1 VALUES(1, REPEAT('a', 5000)); | ||
SET debug_sync='now SIGNAL purge_continue'; | ||
|
||
connection server_1; | ||
reap; | ||
|
||
echo "There should be only one raft log:"; | ||
replace_column 1 # 2 #; | ||
SHOW RAFT LOGS; | ||
INSERT INTO t1 VALUES(2, ""); | ||
echo "Now we should have two raft logs:"; | ||
replace_column 1 # 2 #; | ||
SHOW RAFT LOGS; | ||
|
||
# Cleanup | ||
connection server_1; | ||
SET @@GLOBAL.max_binlog_size = default; | ||
DROP TABLE t1; | ||
|
||
let $sync_slave_connection= server_2; | ||
source include/sync_slave_sql_with_master.inc; | ||
let $sync_slave_connection= server_3; | ||
source include/sync_slave_sql_with_master.inc; | ||
|
||
source include/rpl_end.inc; |
20 changes: 20 additions & 0 deletions
20
mysql-test/suite/sys_vars/r/delay_auto_rotation_on_raft_log_purge_basic.result
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,20 @@ | ||
Default value of delay_auto_rotation_on_raft_log_purge is 1 | ||
SELECT @@global.delay_auto_rotation_on_raft_log_purge; | ||
@@global.delay_auto_rotation_on_raft_log_purge | ||
1 | ||
SELECT @@session.delay_auto_rotation_on_raft_log_purge; | ||
ERROR HY000: Variable 'delay_auto_rotation_on_raft_log_purge' is a GLOBAL variable | ||
Expected error 'Variable is a GLOBAL variable' | ||
delay_auto_rotation_on_raft_log_purge is a dynamic variable | ||
SET @@global.delay_auto_rotation_on_raft_log_purge = 1; | ||
SELECT @@global.delay_auto_rotation_on_raft_log_purge; | ||
@@global.delay_auto_rotation_on_raft_log_purge | ||
1 | ||
SET @@global.delay_auto_rotation_on_raft_log_purge = 0; | ||
SELECT @@global.delay_auto_rotation_on_raft_log_purge; | ||
@@global.delay_auto_rotation_on_raft_log_purge | ||
0 | ||
SET @@global.delay_auto_rotation_on_raft_log_purge = default; | ||
SELECT @@global.delay_auto_rotation_on_raft_log_purge; | ||
@@global.delay_auto_rotation_on_raft_log_purge | ||
1 |
27 changes: 27 additions & 0 deletions
27
mysql-test/suite/sys_vars/t/delay_auto_rotation_on_raft_log_purge_basic.test
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,27 @@ | ||
-- source include/load_sysvars.inc | ||
|
||
#### | ||
# Verify default value 1 | ||
#### | ||
--echo Default value of delay_auto_rotation_on_raft_log_purge is 1 | ||
SELECT @@global.delay_auto_rotation_on_raft_log_purge; | ||
|
||
#### | ||
# Verify that this is not a session variable # | ||
#### | ||
--Error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
SELECT @@session.delay_auto_rotation_on_raft_log_purge; | ||
--echo Expected error 'Variable is a GLOBAL variable' | ||
|
||
#### | ||
## Verify that the variable is dynamic | ||
#### | ||
--echo delay_auto_rotation_on_raft_log_purge is a dynamic variable | ||
SET @@global.delay_auto_rotation_on_raft_log_purge = 1; | ||
SELECT @@global.delay_auto_rotation_on_raft_log_purge; | ||
|
||
SET @@global.delay_auto_rotation_on_raft_log_purge = 0; | ||
SELECT @@global.delay_auto_rotation_on_raft_log_purge; | ||
|
||
SET @@global.delay_auto_rotation_on_raft_log_purge = default; | ||
SELECT @@global.delay_auto_rotation_on_raft_log_purge; |
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
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
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