Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This diff is a combination of the following two commits from Percona: percona/percona-server@725a238c percona/percona-server@85c461c8 Adds two new variables `max_slowlog_size` and `max_slowlog_files` as documented here: https://www.percona.com/doc/percona-server/LATEST/flexibility/slowlog_rotation.html Reviewed By: hermanlee Differential Revision: D5394337 fbshipit-source-id: 746c6bf
- Loading branch information
1 parent
d99f329
commit 3445f81
Showing
14 changed files
with
410 additions
and
10 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
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,21 @@ | ||
SET @old_max_slowlog_size = @@global.max_slowlog_size; | ||
SET @old_slow_query_log = @@global.slow_query_log; | ||
SET @old_slow_query_log_file = @@global.slow_query_log_file; | ||
SET @old_long_query_time = @@long_query_time; | ||
SET GLOBAL max_slowlog_size=10240000; | ||
SET long_query_time=0; | ||
SET GLOBAL slow_query_log_file='MYSQLTEST_VARDIR/abcd'; | ||
SET GLOBAL slow_query_log=1; | ||
SET GLOBAL slow_query_log=0; | ||
SET GLOBAL slow_query_log=1; | ||
SET GLOBAL slow_query_log=0; | ||
SET GLOBAL slow_query_log=1; | ||
FLUSH LOGS; | ||
FLUSH LOGS; | ||
FLUSH LOGS; | ||
slow query log files count: | ||
1 | ||
SET @@global.max_slowlog_size = @old_max_slowlog_size; | ||
SET @@global.slow_query_log = @old_slow_query_log; | ||
SET @@global.slow_query_log_file = @old_slow_query_log_file; | ||
SET @@long_query_time = @old_long_query_time; |
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,21 @@ | ||
SET @old_slow_query_log = @@global.slow_query_log; | ||
SET @old_log_output = @@global.log_output; | ||
SET @old_slow_query_log_file = @@global.slow_query_log_file; | ||
SET @old_max_slowlog_size = @@global.max_slowlog_size; | ||
SET @old_max_slowlog_files = @@global.max_slowlog_files; | ||
SET @old_long_query_time = @@long_query_time; | ||
SET GLOBAL slow_query_log=1; | ||
SET GLOBAL log_output=FILE; | ||
SET GLOBAL max_slowlog_size=4096; | ||
SET GLOBAL max_slowlog_files=5; | ||
SET long_query_time=0; | ||
SET GLOBAL slow_query_log_file='MYSQLTEST_VARDIR/abcd'; | ||
5 | ||
SET GLOBAL slow_query_log_file='MYSQLTEST_VARDIR/zxcv'; | ||
5 | ||
SET @@global.slow_query_log = @old_slow_query_log; | ||
SET @@global.log_output = @old_log_output; | ||
SET @@global.slow_query_log_file = @old_slow_query_log_file; | ||
SET @@global.max_slowlog_size = @old_max_slowlog_size; | ||
SET @@global.max_slowlog_files = @old_max_slowlog_files; | ||
SET @@long_query_time = @old_long_query_time; |
30 changes: 30 additions & 0 deletions
30
mysql-test/suite/sys_vars/r/max_slowlog_files_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,30 @@ | ||
SET @old = @@global.max_slowlog_files; | ||
SET GLOBAL max_slowlog_files = 0; | ||
SELECT @@global.max_slowlog_files; | ||
@@global.max_slowlog_files | ||
0 | ||
SET GLOBAL max_slowlog_files = 4096; | ||
SELECT @@global.max_slowlog_files; | ||
@@global.max_slowlog_files | ||
4096 | ||
SET GLOBAL max_slowlog_files = 1000; | ||
SELECT @@global.max_slowlog_files; | ||
@@global.max_slowlog_files | ||
1000 | ||
SET GLOBAL max_slowlog_files = -1; | ||
Warnings: | ||
Warning 1292 Truncated incorrect max_slowlog_files value: '-1' | ||
SELECT @@global.max_slowlog_files; | ||
@@global.max_slowlog_files | ||
0 | ||
SET GLOBAL max_slowlog_files = 102400; | ||
SELECT @@global.max_slowlog_files; | ||
@@global.max_slowlog_files | ||
102400 | ||
SET GLOBAL max_slowlog_files = 102401; | ||
Warnings: | ||
Warning 1292 Truncated incorrect max_slowlog_files value: '102401' | ||
SELECT @@global.max_slowlog_files; | ||
@@global.max_slowlog_files | ||
102400 | ||
SET @@global.max_slowlog_files = @old; |
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,32 @@ | ||
SET @old = @@global.max_slowlog_size; | ||
SET GLOBAL max_slowlog_size = 0; | ||
SELECT @@global.max_slowlog_size; | ||
@@global.max_slowlog_size | ||
0 | ||
SET GLOBAL max_slowlog_size = 4096; | ||
SELECT @@global.max_slowlog_size; | ||
@@global.max_slowlog_size | ||
4096 | ||
SET GLOBAL max_slowlog_size = 1000; | ||
Warnings: | ||
Warning 1292 Truncated incorrect max_slowlog_size value: '1000' | ||
SELECT @@global.max_slowlog_size; | ||
@@global.max_slowlog_size | ||
0 | ||
SET GLOBAL max_slowlog_size = -1; | ||
Warnings: | ||
Warning 1292 Truncated incorrect max_slowlog_size value: '-1' | ||
SELECT @@global.max_slowlog_size; | ||
@@global.max_slowlog_size | ||
0 | ||
SET GLOBAL max_slowlog_size = 1024*1024*1024; | ||
SELECT @@global.max_slowlog_size; | ||
@@global.max_slowlog_size | ||
1073741824 | ||
SET GLOBAL max_slowlog_size = 1024*1024*1024+1; | ||
Warnings: | ||
Warning 1292 Truncated incorrect max_slowlog_size value: '1073741825' | ||
SELECT @@global.max_slowlog_size; | ||
@@global.max_slowlog_size | ||
1073741824 | ||
SET @@global.max_slowlog_size = @old; |
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,18 @@ | ||
# | ||
# Test max_slowlog_files | ||
# | ||
|
||
SET @old = @@global.max_slowlog_files; | ||
SET GLOBAL max_slowlog_files = 0; | ||
SELECT @@global.max_slowlog_files; | ||
SET GLOBAL max_slowlog_files = 4096; | ||
SELECT @@global.max_slowlog_files; | ||
SET GLOBAL max_slowlog_files = 1000; | ||
SELECT @@global.max_slowlog_files; | ||
SET GLOBAL max_slowlog_files = -1; | ||
SELECT @@global.max_slowlog_files; | ||
SET GLOBAL max_slowlog_files = 102400; | ||
SELECT @@global.max_slowlog_files; | ||
SET GLOBAL max_slowlog_files = 102401; | ||
SELECT @@global.max_slowlog_files; | ||
SET @@global.max_slowlog_files = @old; |
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,18 @@ | ||
# | ||
# Test max_slowlog_size | ||
# | ||
|
||
SET @old = @@global.max_slowlog_size; | ||
SET GLOBAL max_slowlog_size = 0; | ||
SELECT @@global.max_slowlog_size; | ||
SET GLOBAL max_slowlog_size = 4096; | ||
SELECT @@global.max_slowlog_size; | ||
SET GLOBAL max_slowlog_size = 1000; | ||
SELECT @@global.max_slowlog_size; | ||
SET GLOBAL max_slowlog_size = -1; | ||
SELECT @@global.max_slowlog_size; | ||
SET GLOBAL max_slowlog_size = 1024*1024*1024; | ||
SELECT @@global.max_slowlog_size; | ||
SET GLOBAL max_slowlog_size = 1024*1024*1024+1; | ||
SELECT @@global.max_slowlog_size; | ||
SET @@global.max_slowlog_size = @old; |
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,38 @@ | ||
# | ||
# Bug 1416582: Slow query log is rotated before it should | ||
# when using max_slowlog_size | ||
# | ||
|
||
SET @old_max_slowlog_size = @@global.max_slowlog_size; | ||
SET @old_slow_query_log = @@global.slow_query_log; | ||
SET @old_slow_query_log_file = @@global.slow_query_log_file; | ||
SET @old_long_query_time = @@long_query_time; | ||
SET GLOBAL max_slowlog_size=10240000; | ||
SET long_query_time=0; | ||
|
||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR | ||
eval SET GLOBAL slow_query_log_file='$MYSQLTEST_VARDIR/abcd'; | ||
|
||
# start/stop slog log should not cause log number increment | ||
SET GLOBAL slow_query_log=1; | ||
SET GLOBAL slow_query_log=0; | ||
SET GLOBAL slow_query_log=1; | ||
SET GLOBAL slow_query_log=0; | ||
SET GLOBAL slow_query_log=1; | ||
|
||
# FLUSH LOGS should not cause log number increment | ||
FLUSH LOGS; | ||
FLUSH LOGS; | ||
FLUSH LOGS; | ||
|
||
--echo slow query log files count: | ||
perl; | ||
my @files = <$ENV{'MYSQLTEST_VARDIR'}/abcd*>; | ||
printf "%d\n", scalar(@files); | ||
EOF | ||
|
||
|
||
SET @@global.max_slowlog_size = @old_max_slowlog_size; | ||
SET @@global.slow_query_log = @old_slow_query_log; | ||
SET @@global.slow_query_log_file = @old_slow_query_log_file; | ||
SET @@long_query_time = @old_long_query_time; |
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,60 @@ | ||
# | ||
# Test slowlog size limiting and rotation | ||
# | ||
|
||
SET @old_slow_query_log = @@global.slow_query_log; | ||
SET @old_log_output = @@global.log_output; | ||
SET @old_slow_query_log_file = @@global.slow_query_log_file; | ||
SET @old_max_slowlog_size = @@global.max_slowlog_size; | ||
SET @old_max_slowlog_files = @@global.max_slowlog_files; | ||
SET @old_long_query_time = @@long_query_time; | ||
|
||
SET GLOBAL slow_query_log=1; | ||
SET GLOBAL log_output=FILE; | ||
SET GLOBAL max_slowlog_size=4096; | ||
SET GLOBAL max_slowlog_files=5; | ||
SET long_query_time=0; | ||
|
||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR | ||
eval SET GLOBAL slow_query_log_file='$MYSQLTEST_VARDIR/abcd'; | ||
|
||
# avoid 1000 selects 1 in .result | ||
let $i=1000; | ||
disable_query_log; | ||
disable_result_log; | ||
while($i) { | ||
eval select $i; | ||
dec $i; | ||
} | ||
enable_query_log; | ||
enable_result_log; | ||
|
||
perl; | ||
my @files = <$ENV{'MYSQLTEST_VARDIR'}/abcd*>; | ||
printf "%d\n", scalar(@files); | ||
EOF | ||
|
||
|
||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR | ||
eval SET GLOBAL slow_query_log_file='$MYSQLTEST_VARDIR/zxcv'; | ||
|
||
let $i=1000; | ||
disable_query_log; | ||
disable_result_log; | ||
while($i) { | ||
eval select $i; | ||
dec $i; | ||
} | ||
enable_query_log; | ||
enable_result_log; | ||
perl; | ||
my @files = <$ENV{'MYSQLTEST_VARDIR'}/zxcv*>; | ||
printf "%d\n", scalar(@files); | ||
EOF | ||
|
||
SET @@global.slow_query_log = @old_slow_query_log; | ||
SET @@global.log_output = @old_log_output; | ||
SET @@global.slow_query_log_file = @old_slow_query_log_file; | ||
SET @@global.max_slowlog_size = @old_max_slowlog_size; | ||
SET @@global.max_slowlog_files = @old_max_slowlog_files; | ||
SET @@long_query_time = @old_long_query_time; |
Oops, something went wrong.
3445f81
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a heads up that a straightforward port from Percona Server is probably affected by https://bugs.launchpad.net/percona-server/+bug/1288232 (slowlog rotation and expiration doesn't work with the default slow query log name)