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.
check for sql_bin_log = 0 with write throttling
Summary: Adds extra check to ensure writes aren't throttled if sql_bin_log = 0. See T90163290 Reviewed By: satya-valluri Differential Revision: D28712613 fbshipit-source-id: a773d7d3e1b
- Loading branch information
Showing
3 changed files
with
195 additions
and
1 deletion.
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,77 @@ | ||
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 test(a int, b int, c int) engine=innodb; | ||
Set CPU limit for milliseconds to 1 | ||
set @@GLOBAL.write_cpu_limit_milliseconds=1; | ||
connect to master | ||
setting dbug.force_long_running_query which will | ||
make the query long running after processing number | ||
of rows determined by write_time_check_batch | ||
set @@global.debug= '+d,dbug.force_long_running_query'; | ||
Set the batch size for checking CPU time to 3 | ||
set @@GLOBAL.write_time_check_batch=3; | ||
Test 1.1: Long running query to force throttling level=NOTE | ||
set @@GLOBAL.write_control_level=NOTE; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
this query raises warning | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
show warnings; | ||
Level Code Message | ||
Note 50091 Write CPU time exceeded (controlled by write_cpu_limit_milliseconds) | ||
Test 1.2: Long running query to force throttling level=WARN | ||
set @@GLOBAL.write_control_level=WARN; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
this query raises warning | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
show warnings; | ||
Level Code Message | ||
Warning 50091 Write CPU time exceeded (controlled by write_cpu_limit_milliseconds) | ||
Test 1.3: Long running query to force throttling level=ERROR | ||
set @@GLOBAL.write_control_level=ERROR; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
this query raises error | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
ERROR HY000: Write CPU time exceeded (controlled by write_cpu_limit_milliseconds) | ||
show errors; | ||
Level Code Message | ||
Error 50091 Write CPU time exceeded (controlled by write_cpu_limit_milliseconds) | ||
Set sql_log_bin to 0 | ||
set sql_log_bin=0; | ||
Test 2.1: Repeat query with sql_log_bin = 0 level=NOTE | ||
set @@GLOBAL.write_control_level=NOTE; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
this query should not raise warning | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
show warnings; | ||
Level Code Message | ||
Test 2.2: Repeat query with sql_log_bin = 0 level=WARN | ||
set @@GLOBAL.write_control_level=WARN; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
this query should not raise warning | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
show warnings; | ||
Level Code Message | ||
Test 2.3: Repeat query with sql_log_bin = 0 level=ERROR | ||
set @@GLOBAL.write_control_level=ERROR; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
this query should not raise error | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
show errors; | ||
Level Code Message | ||
Finished tests begining cleanup | ||
set @@GLOBAL.write_control_level=OFF; | ||
set @@GLOBAL.write_cpu_limit_milliseconds=0; | ||
set @@GLOBAL.write_time_check_batch=0; | ||
set @@global.debug= '-d,dbug.force_long_running_query'; | ||
set sql_log_bin=1; | ||
drop table test; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
source include/master-slave.inc; | ||
source include/have_binlog_format_row.inc; | ||
source include/have_debug_sync.inc; | ||
|
||
--disable_warnings | ||
|
||
#################################################### | ||
### Tests no throttling with sql_log_bin = 0 | ||
#################################################### | ||
|
||
### Setup | ||
connection master; | ||
|
||
create table test(a int, b int, c int) engine=innodb; | ||
|
||
--echo Set CPU limit for milliseconds to 1 | ||
set @@GLOBAL.write_cpu_limit_milliseconds=1; | ||
|
||
--echo connect to master | ||
connection master; | ||
|
||
--echo setting dbug.force_long_running_query which will | ||
--echo make the query long running after processing number | ||
--echo of rows determined by write_time_check_batch | ||
set @@global.debug= '+d,dbug.force_long_running_query'; | ||
|
||
--echo Set the batch size for checking CPU time to 3 | ||
set @@GLOBAL.write_time_check_batch=3; | ||
|
||
#################################################### | ||
### Test 1: Query throttling with sql_log_bin = 1 | ||
#################################################### | ||
|
||
--echo Test 1.1: Long running query to force throttling level=NOTE | ||
|
||
set @@GLOBAL.write_control_level=NOTE; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
--echo this query raises warning | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
|
||
show warnings; | ||
|
||
--echo Test 1.2: Long running query to force throttling level=WARN | ||
|
||
set @@GLOBAL.write_control_level=WARN; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
--echo this query raises warning | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
|
||
show warnings; | ||
|
||
--echo Test 1.3: Long running query to force throttling level=ERROR | ||
|
||
set @@GLOBAL.write_control_level=ERROR; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
--echo this query raises error | ||
--error ER_WARN_WRITE_EXCEEDED_CPU_LIMIT_MILLISECONDS | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
|
||
show errors; | ||
|
||
#################################################### | ||
### Test 1: No query throttling with sql_log_bin = 0 | ||
#################################################### | ||
|
||
--echo Set sql_log_bin to 0 | ||
set sql_log_bin=0; | ||
|
||
--echo Test 2.1: Repeat query with sql_log_bin = 0 level=NOTE | ||
|
||
set @@GLOBAL.write_control_level=NOTE; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
--echo this query should not raise warning | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
|
||
show warnings; | ||
|
||
--echo Test 2.2: Repeat query with sql_log_bin = 0 level=WARN | ||
|
||
set @@GLOBAL.write_control_level=WARN; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
--echo this query should not raise warning | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
|
||
show warnings; | ||
|
||
--echo Test 2.3: Repeat query with sql_log_bin = 0 level=ERROR | ||
|
||
set @@GLOBAL.write_control_level=ERROR; | ||
insert into test values(1, 1, 1); | ||
insert into test values(2, 2, 2), (3, 3, 3); | ||
--echo this query should not raise error | ||
insert into test values(4, 4, 4), (5, 5, 5), (6, 6, 6); | ||
|
||
show errors; | ||
|
||
|
||
### Clean Up | ||
--echo Finished tests begining cleanup | ||
connection master; | ||
|
||
set @@GLOBAL.write_control_level=OFF; | ||
set @@GLOBAL.write_cpu_limit_milliseconds=0; | ||
set @@GLOBAL.write_time_check_batch=0; | ||
set @@global.debug= '-d,dbug.force_long_running_query'; | ||
set sql_log_bin=1; | ||
drop table test; | ||
|
||
--source include/rpl_end.inc | ||
--enable_warnings |
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