-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mysql-5.6][PR] FB8-78: Add filesort_max_file_size option
Summary: Jira issue: https://jira.percona.com/browse/FB8-78 Reference Patch: 11ef068 Add the filesort_max_file_size variable setting which specifies the maximum number of bytes a filesort file can take. If it is exceeded, then the query fails. This is very similar to the tmp_table_max_file_size variable. Pull Request resolved: #993 GitHub Author: Manuel Ung <[email protected]> Test Plan: main.max_filesort_size Reviewers: Subscribers: butterflybot, vinaybhat, [email protected] Differential Revision: https://phabricator.intern.facebook.com/D14652353 Tasks: Tags: Blame Revision:
- Loading branch information
1 parent
cc474d7
commit 7f595e0
Showing
12 changed files
with
503 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
set @save_filesort_max_file_size = @@global.filesort_max_file_size; | ||
create table t1 (i int, c char(255)); | ||
insert into t1 values (0, lpad('a', 250, 'b')); | ||
insert into t1 select i+1,c from t1; | ||
insert into t1 select i+2,c from t1; | ||
insert into t1 select i+4,c from t1; | ||
insert into t1 select i+8,c from t1; | ||
insert into t1 select i+16,c from t1; | ||
insert into t1 select i+32,c from t1; | ||
insert into t1 select i+64,c from t1; | ||
insert into t1 select i+128,c from t1; | ||
insert into t1 select i+256,c from t1; | ||
insert into t1 select i+512,c from t1; | ||
insert into t1 select i+1024,c from t1; | ||
insert into t1 select i+2048,c from t1; | ||
Query is OK when there is no limit | ||
show variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 0 | ||
show session variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 0 | ||
show global variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 0 | ||
explain select i, c from t1 order by hex(c) limit 1 offset 4000; | ||
id select_type table partitions type possible_keys key key_len ref rows filtered Extra | ||
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4096 100.00 Using filesort | ||
Warnings: | ||
Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by hex(`test`.`t1`.`c`) limit 4000,1 | ||
select i, c from t1 order by hex(c) limit 1 offset 4000; | ||
i c | ||
2102 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba | ||
select /*+ SET_VAR(filesort_max_file_size = 1000000) */ i, c from t1 order by hex(c) limit 1 offset 4000; | ||
ERROR HY000: Filesort file is too big | ||
Query fails with a limit | ||
set session filesort_max_file_size=1000000; | ||
show variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 1000000 | ||
show session variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 1000000 | ||
show global variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 0 | ||
select i, c from t1 order by hex(c) limit 1 offset 4000; | ||
ERROR HY000: Filesort file is too big | ||
Query is OK when another session has a limit | ||
show variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 0 | ||
show session variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 0 | ||
show global variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 0 | ||
select i, c from t1 order by hex(c) limit 1 offset 4000; | ||
i c | ||
2102 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba | ||
Query is OK when session limit is reset | ||
set session filesort_max_file_size=0; | ||
show variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 0 | ||
show session variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 0 | ||
show global variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 0 | ||
select i, c from t1 order by hex(c) limit 1 offset 4000; | ||
i c | ||
2102 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba | ||
Query fails when global limit is set | ||
set global filesort_max_file_size=1000000; | ||
show variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 1000000 | ||
show session variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 1000000 | ||
show global variables like "filesort_max_file_size"; | ||
Variable_name Value | ||
filesort_max_file_size 1000000 | ||
select i, c from t1 order by hex(c) limit 1 offset 4000; | ||
ERROR HY000: Filesort file is too big | ||
drop table t1; | ||
set @@global.filesort_max_file_size = @save_filesort_max_file_size; |
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
118 changes: 118 additions & 0 deletions
118
mysql-test/suite/sys_vars/r/filesort_max_file_size_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,118 @@ | ||
SET @start_global_value = @@global.filesort_max_file_size; | ||
'#--------------------FN_DYNVARS_005_01-------------------------#' | ||
SET @@global.filesort_max_file_size = 100; | ||
SET @@global.filesort_max_file_size = DEFAULT; | ||
SET @@session.filesort_max_file_size = 200; | ||
SET @@session.filesort_max_file_size = DEFAULT; | ||
'#--------------------FN_DYNVARS_005_02-------------------------#' | ||
SELECT @@global.filesort_max_file_size = 0; | ||
@@global.filesort_max_file_size = 0 | ||
1 | ||
SELECT @@session.filesort_max_file_size = 0; | ||
@@session.filesort_max_file_size = 0 | ||
1 | ||
'#--------------------FN_DYNVARS_005_03-------------------------#' | ||
SET @@global.filesort_max_file_size = 1024; | ||
SELECT @@global.filesort_max_file_size; | ||
@@global.filesort_max_file_size | ||
1024 | ||
SET @@global.filesort_max_file_size = 60020; | ||
SELECT @@global.filesort_max_file_size; | ||
@@global.filesort_max_file_size | ||
60020 | ||
SET @@global.filesort_max_file_size = 4294967295; | ||
SELECT @@global.filesort_max_file_size; | ||
@@global.filesort_max_file_size | ||
4294967295 | ||
'#--------------------FN_DYNVARS_005_04-------------------------#' | ||
SET @@session.filesort_max_file_size = 1024; | ||
SELECT @@session.filesort_max_file_size; | ||
@@session.filesort_max_file_size | ||
1024 | ||
SET @@session.filesort_max_file_size = 4294967295; | ||
SELECT @@session.filesort_max_file_size; | ||
@@session.filesort_max_file_size | ||
4294967295 | ||
SET @@session.filesort_max_file_size = 65535; | ||
SELECT @@session.filesort_max_file_size; | ||
@@session.filesort_max_file_size | ||
65535 | ||
'#------------------FN_DYNVARS_005_05-----------------------#' | ||
SET @@global.filesort_max_file_size = -1024; | ||
Warnings: | ||
Warning 1292 Truncated incorrect filesort_max_file_size value: '-1024' | ||
SELECT @@global.filesort_max_file_size; | ||
@@global.filesort_max_file_size | ||
0 | ||
SET @@global.filesort_max_file_size = ON; | ||
ERROR 42000: Incorrect argument type to variable 'filesort_max_file_size' | ||
SET @@global.filesort_max_file_size = OFF; | ||
ERROR 42000: Incorrect argument type to variable 'filesort_max_file_size' | ||
SET @@global.filesort_max_file_size = True; | ||
SELECT @@global.filesort_max_file_size; | ||
@@global.filesort_max_file_size | ||
1 | ||
SET @@global.filesort_max_file_size = False; | ||
SELECT @@global.filesort_max_file_size; | ||
@@global.filesort_max_file_size | ||
0 | ||
SET @@global.filesort_max_file_size = 65530.34; | ||
ERROR 42000: Incorrect argument type to variable 'filesort_max_file_size' | ||
SET @@global.filesort_max_file_size ="Test"; | ||
ERROR 42000: Incorrect argument type to variable 'filesort_max_file_size' | ||
SET @@session.filesort_max_file_size = ON; | ||
ERROR 42000: Incorrect argument type to variable 'filesort_max_file_size' | ||
SET @@session.filesort_max_file_size = OFF; | ||
ERROR 42000: Incorrect argument type to variable 'filesort_max_file_size' | ||
SET @@session.filesort_max_file_size = True; | ||
SELECT @@session.filesort_max_file_size; | ||
@@session.filesort_max_file_size | ||
1 | ||
SET @@session.filesort_max_file_size = False; | ||
SELECT @@session.filesort_max_file_size; | ||
@@session.filesort_max_file_size | ||
0 | ||
SET @@session.filesort_max_file_size = "Test"; | ||
ERROR 42000: Incorrect argument type to variable 'filesort_max_file_size' | ||
SET @@session.filesort_max_file_size = 12345678901; | ||
SELECT @@session.filesort_max_file_size IN (12345678901,4294967295); | ||
@@session.filesort_max_file_size IN (12345678901,4294967295) | ||
1 | ||
'#------------------FN_DYNVARS_005_06-----------------------#' | ||
SELECT @@global.filesort_max_file_size = VARIABLE_VALUE | ||
FROM performance_schema.global_variables | ||
WHERE VARIABLE_NAME='filesort_max_file_size'; | ||
@@global.filesort_max_file_size = VARIABLE_VALUE | ||
1 | ||
'#------------------FN_DYNVARS_005_07-----------------------#' | ||
SELECT @@session.filesort_max_file_size = VARIABLE_VALUE | ||
FROM performance_schema.session_variables | ||
WHERE VARIABLE_NAME='filesort_max_file_size'; | ||
@@session.filesort_max_file_size = VARIABLE_VALUE | ||
1 | ||
'#---------------------FN_DYNVARS_001_09----------------------#' | ||
SET @@global.filesort_max_file_size = 1024; | ||
SET @@filesort_max_file_size = 4294967295; | ||
SELECT @@filesort_max_file_size = @@global.filesort_max_file_size; | ||
@@filesort_max_file_size = @@global.filesort_max_file_size | ||
0 | ||
'#---------------------FN_DYNVARS_001_10----------------------#' | ||
SET @@filesort_max_file_size = 100; | ||
SELECT @@filesort_max_file_size = @@local.filesort_max_file_size; | ||
@@filesort_max_file_size = @@local.filesort_max_file_size | ||
1 | ||
SELECT @@local.filesort_max_file_size = @@session.filesort_max_file_size; | ||
@@local.filesort_max_file_size = @@session.filesort_max_file_size | ||
1 | ||
'#---------------------FN_DYNVARS_001_11----------------------#' | ||
SET filesort_max_file_size = 1027; | ||
SELECT @@filesort_max_file_size; | ||
@@filesort_max_file_size | ||
1027 | ||
SELECT local.filesort_max_file_size; | ||
ERROR 42S02: Unknown table 'local' in field list | ||
SELECT global.filesort_max_file_size; | ||
ERROR 42S02: Unknown table 'global' in field list | ||
SELECT filesort_max_file_size = @@session.filesort_max_file_size; | ||
ERROR 42S22: Unknown column 'filesort_max_file_size' in 'field list' | ||
SET @@global.filesort_max_file_size = @start_global_value; |
Oops, something went wrong.