Merge lp:~stewart/percona-server/max-binlog-files into lp:percona-server/5.5

Proposed by Stewart Smith
Status: Superseded
Proposed branch: lp:~stewart/percona-server/max-binlog-files
Merge into: lp:percona-server/5.5
Diff against target: 641 lines (+477/-1)
14 files modified
Percona-Server/mysql-test/r/mysqld--help-notwin.result (+6/-0)
Percona-Server/mysql-test/r/mysqld--help-win.result (+6/-0)
Percona-Server/mysql-test/r/percona_server_variables_debug.result (+1/-0)
Percona-Server/mysql-test/r/percona_server_variables_release.result (+1/-0)
Percona-Server/mysql-test/suite/binlog/r/percona_binlog_max_nr.result (+30/-0)
Percona-Server/mysql-test/suite/binlog/t/percona_binlog_max_nr-master.opt (+2/-0)
Percona-Server/mysql-test/suite/binlog/t/percona_binlog_max_nr.test (+60/-0)
Percona-Server/mysql-test/suite/sys_vars/r/max_binlog_files_basic.result (+134/-0)
Percona-Server/mysql-test/suite/sys_vars/t/max_binlog_files_basic.test (+147/-0)
Percona-Server/sql/log.cc (+76/-1)
Percona-Server/sql/log.h (+1/-0)
Percona-Server/sql/mysqld.cc (+4/-0)
Percona-Server/sql/mysqld.h (+1/-0)
Percona-Server/sql/sys_vars.cc (+8/-0)
To merge this branch: bzr merge lp:~stewart/percona-server/max-binlog-files
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Needs Fixing
Alexey Kopytov Pending
Review via email: mp+116189@code.launchpad.net

This proposal supersedes a proposal from 2012-05-30.

This proposal has been superseded by a proposal from 2012-08-13.

Description of the change

introduces new server parameter to limit the number of binlog files. Used with setting max file size for binlog you can rather effectively set maximum disk space used by binlogs.

Original Jenkins run:
http://jenkins.percona.com/view/PS%205.5/job/percona-server-5.5-param/385/

This run:
http://jenkins.percona.com/job/percona-server-5.5-param/451/

In this resubmitted req it's just addressing review comments.

To post a comment you must log in.
Revision history for this message
Stewart Smith (stewart) wrote : Posted in a previous version of this proposal

This is for (internal) issue 23617

--
Stewart Smith

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

The testcase has commit but does not have matching begin transaction or disable autocommit.
Perhaps rename err label to exit, as it is used for non-error returns too.

review: Needs Fixing
Revision history for this message
Stewart Smith (stewart) wrote : Posted in a previous version of this proposal

On Fri, 01 Jun 2012 03:46:26 -0000, Laurynas Biveinis <email address hidden> wrote:
> The testcase has commit but does not have matching begin transaction
> or disable autocommit.

It does have a BEGIN;. It doesn't explicitly set engine to InnoDB,
although in this case it doesn't really matter what engine it executes
with, so I'm just running with default engine.

> Perhaps rename err label to exit, as it is used for non-error returns too.

I generally avoid exit as a label name due to exit(3) existing.
Using err as label is consistent with the rest of log.cc though.

--
Stewart Smith

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

OK, thanks for explaining.

review: Approve
Revision history for this message
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal

Stewart,

- There is a problem in MYSQL_BIN_LOG::purge_logs_maximum_number() when
  some files cannot be purged when in use, e.g. when there's a slave
  reading that log file. It looks like in this case we will be spinning
  in a tight loop *and* holding the LOCK_index mutex *and* incrementing
  current_number_of_logs, so it will also be an infinite loop.

- I wonder if we really need that "do while()" loop?

- Please fix formatting in purge_logs_maximum_number(). I know it's
  mostly copy-pasted code, but fixing it is just "C-M-h C-M-\"

- Please don't follow a bad example established previously with adding
  variables to all_vars.result. Let's have max_binlog_files_basic.test
  instead. The test case says there should no variable names in
  all_vars.result, and the upstream server has none.

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal

Forgot to mention that the comment header in the .test file should be fixed too (copy-paste from another test).

Revision history for this message
Stewart Smith (stewart) wrote :

http://jenkins.percona.com/job/percona-server-5.5-param/452/

(just set a sensible limit on max number of binlog files)

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

    --force-restart in percona_binlog_max_nr-master.opt is an MTR
    option, not mysqld one, so it should be removed.

    Please add a newline to that file.

    What does "FN_DYNVARS_072_01" mean in max_binlog_files_basic.test?

    while(find_next_log(&log_info, 0) == false) missing space after
    while and am not sure "== false" is the way to write it: there is
    an "if (find_next_log(&log_info, 0))" below.

    Use MYSQL_BIN_LOG::lock_index and unlock_index instead of directly
    touching the LOCK_index.

    Rev 253 and diff lines 579--580, is that a separate bug fixed?
    Maybe it needs an LP bug for it?

review: Needs Fixing
Revision history for this message
Stewart Smith (stewart) wrote :

> --force-restart in percona_binlog_max_nr-master.opt is an MTR
> option, not mysqld one, so it should be removed.

fixed

> Please add a newline to that file.

fixed

> What does "FN_DYNVARS_072_01" mean in max_binlog_files_basic.test?

This is just copied from max_binlog_size test

> while(find_next_log(&log_info, 0) == false) missing space after
> while and am not sure "== false" is the way to write it: there is
> an "if (find_next_log(&log_info, 0))" below.

fixed

> Use MYSQL_BIN_LOG::lock_index and unlock_index instead of directly
> touching the LOCK_index.

none of the existing code uses this

> Rev 253 and diff lines 579--580, is that a separate bug fixed?
> Maybe it needs an LP bug for it?

possibly should...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Percona-Server/mysql-test/r/mysqld--help-notwin.result'
--- Percona-Server/mysql-test/r/mysqld--help-notwin.result 2012-08-07 06:10:00 +0000
+++ Percona-Server/mysql-test/r/mysqld--help-notwin.result 2012-08-13 05:32:20 +0000
@@ -321,6 +321,11 @@
321 --max-binlog-dump-events=# 321 --max-binlog-dump-events=#
322 Option used by mysql-test for debugging and testing of322 Option used by mysql-test for debugging and testing of
323 replication.323 replication.
324 --max-binlog-files=#
325 Maximum number of binlog files. Used with
326 --max-binlog-size this can be used to limit the total
327 amount of disk space used for the binlog. Default is 0,
328 don't limit.
324 --max-binlog-size=# Binary log will be rotated automatically when the size329 --max-binlog-size=# Binary log will be rotated automatically when the size
325 exceeds this value. Will also apply to relay logs if330 exceeds this value. Will also apply to relay logs if
326 max_relay_log_size is 0331 max_relay_log_size is 0
@@ -913,6 +918,7 @@
913max-allowed-packet 1048576918max-allowed-packet 1048576
914max-binlog-cache-size 18446744073709547520919max-binlog-cache-size 18446744073709547520
915max-binlog-dump-events 0920max-binlog-dump-events 0
921max-binlog-files 0
916max-binlog-size 1073741824922max-binlog-size 1073741824
917max-binlog-stmt-cache-size 18446744073709547520923max-binlog-stmt-cache-size 18446744073709547520
918max-connect-errors 10924max-connect-errors 10
919925
=== modified file 'Percona-Server/mysql-test/r/mysqld--help-win.result'
--- Percona-Server/mysql-test/r/mysqld--help-win.result 2012-08-07 06:10:00 +0000
+++ Percona-Server/mysql-test/r/mysqld--help-win.result 2012-08-13 05:32:20 +0000
@@ -294,6 +294,11 @@
294 --max-binlog-dump-events=# 294 --max-binlog-dump-events=#
295 Option used by mysql-test for debugging and testing of295 Option used by mysql-test for debugging and testing of
296 replication.296 replication.
297 --max-binlog-files=#
298 Maximum number of binlog files. Used with
299 --max-binlog-size this can be used to limit the total
300 amount of disk space used for the binlog. Default is 0,
301 don't limit.
297 --max-binlog-size=# Binary log will be rotated automatically when the size302 --max-binlog-size=# Binary log will be rotated automatically when the size
298 exceeds this value. Will also apply to relay logs if303 exceeds this value. Will also apply to relay logs if
299 max_relay_log_size is 0304 max_relay_log_size is 0
@@ -857,6 +862,7 @@
857max-allowed-packet 1048576862max-allowed-packet 1048576
858max-binlog-cache-size 18446744073709547520863max-binlog-cache-size 18446744073709547520
859max-binlog-dump-events 0864max-binlog-dump-events 0
865max-binlog-files 0
860max-binlog-size 1073741824866max-binlog-size 1073741824
861max-binlog-stmt-cache-size 18446744073709547520867max-binlog-stmt-cache-size 18446744073709547520
862max-connect-errors 10868max-connect-errors 10
863869
=== modified file 'Percona-Server/mysql-test/r/percona_server_variables_debug.result'
--- Percona-Server/mysql-test/r/percona_server_variables_debug.result 2012-08-09 06:49:56 +0000
+++ Percona-Server/mysql-test/r/percona_server_variables_debug.result 2012-08-13 05:32:20 +0000
@@ -214,6 +214,7 @@
214LOW_PRIORITY_UPDATES214LOW_PRIORITY_UPDATES
215MAX_ALLOWED_PACKET215MAX_ALLOWED_PACKET
216MAX_BINLOG_CACHE_SIZE216MAX_BINLOG_CACHE_SIZE
217MAX_BINLOG_FILES
217MAX_BINLOG_SIZE218MAX_BINLOG_SIZE
218MAX_BINLOG_STMT_CACHE_SIZE219MAX_BINLOG_STMT_CACHE_SIZE
219MAX_CONNECTIONS220MAX_CONNECTIONS
220221
=== modified file 'Percona-Server/mysql-test/r/percona_server_variables_release.result'
--- Percona-Server/mysql-test/r/percona_server_variables_release.result 2012-08-07 06:10:00 +0000
+++ Percona-Server/mysql-test/r/percona_server_variables_release.result 2012-08-13 05:32:20 +0000
@@ -209,6 +209,7 @@
209LOW_PRIORITY_UPDATES209LOW_PRIORITY_UPDATES
210MAX_ALLOWED_PACKET210MAX_ALLOWED_PACKET
211MAX_BINLOG_CACHE_SIZE211MAX_BINLOG_CACHE_SIZE
212MAX_BINLOG_FILES
212MAX_BINLOG_SIZE213MAX_BINLOG_SIZE
213MAX_BINLOG_STMT_CACHE_SIZE214MAX_BINLOG_STMT_CACHE_SIZE
214MAX_CONNECTIONS215MAX_CONNECTIONS
215216
=== added file 'Percona-Server/mysql-test/suite/binlog/r/percona_binlog_max_nr.result'
--- Percona-Server/mysql-test/suite/binlog/r/percona_binlog_max_nr.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/binlog/r/percona_binlog_max_nr.result 2012-08-13 05:32:20 +0000
@@ -0,0 +1,30 @@
1RESET MASTER;
2##############################################################
3testing purge binary logs to max number on explicit FLUSH LOGS
4##############################################################
5show binary logs;
6Log_name File_size
7master-bin.000001 #
8CREATE TABLE t1 (a int primary key auto_increment, b blob);
9flush logs;
10show binary logs;
11Log_name File_size
12master-bin.000006 #
13master-bin.000007 #
14DROP TABLE t1;
15reset master;
16##############################################################
17testing purge binary logs to max number on implicit flush
18i.e. when starting new file
19##############################################################
20show binary logs;
21Log_name File_size
22master-bin.000001 #
23CREATE TABLE t1 (a int primary key auto_increment, b blob);
24show binary logs;
25Log_name File_size
26master-bin.000005 #
27master-bin.000006 #
28DROP TABLE t1;
29reset master;
30End of tests
031
=== added file 'Percona-Server/mysql-test/suite/binlog/t/percona_binlog_max_nr-master.opt'
--- Percona-Server/mysql-test/suite/binlog/t/percona_binlog_max_nr-master.opt 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/binlog/t/percona_binlog_max_nr-master.opt 2012-08-13 05:32:20 +0000
@@ -0,0 +1,2 @@
1--max-binlog-size=4096 --max-binlog-files=2
2
03
=== added file 'Percona-Server/mysql-test/suite/binlog/t/percona_binlog_max_nr.test'
--- Percona-Server/mysql-test/suite/binlog/t/percona_binlog_max_nr.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/binlog/t/percona_binlog_max_nr.test 2012-08-13 05:32:20 +0000
@@ -0,0 +1,60 @@
1source include/have_log_bin.inc;
2source include/not_embedded.inc;
3
4RESET MASTER;
5
6let $MYSQLD_DATADIR= `select @@datadir`;
7let $INDEX=$MYSQLD_DATADIR/master-bin.index;
8
9--echo ##############################################################
10--echo testing purge binary logs to max number on explicit FLUSH LOGS
11--echo ##############################################################
12
13source include/show_binary_logs.inc;
14file_exists $MYSQLD_DATADIR/master-bin.000001;
15
16CREATE TABLE t1 (a int primary key auto_increment, b blob);
17--disable_query_log
18let $c=20;
19begin;
20while ($c)
21{
22 eval INSERT INTO t1 (b) values ('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789');
23 dec $c;
24}
25commit;
26--enable_query_log
27
28flush logs;
29source include/show_binary_logs.inc;
30
31DROP TABLE t1;
32
33reset master;
34
35--echo ##############################################################
36--echo testing purge binary logs to max number on implicit flush
37--echo i.e. when starting new file
38--echo ##############################################################
39
40source include/show_binary_logs.inc;
41file_exists $MYSQLD_DATADIR/master-bin.000001;
42
43CREATE TABLE t1 (a int primary key auto_increment, b blob);
44--disable_query_log
45let $c=20;
46begin;
47while ($c)
48{
49 eval INSERT INTO t1 (b) values ('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789');
50 dec $c;
51}
52commit;
53--enable_query_log
54
55source include/show_binary_logs.inc;
56DROP TABLE t1;
57
58reset master;
59
60--echo End of tests
061
=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/max_binlog_files_basic.result'
--- Percona-Server/mysql-test/suite/sys_vars/r/max_binlog_files_basic.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/r/max_binlog_files_basic.result 2012-08-13 05:32:20 +0000
@@ -0,0 +1,134 @@
1SET @start_value = @@global.max_binlog_files;
2SELECT @start_value;
3@start_value
40
5'#--------------------FN_DYNVARS_072_01------------------------#'
6SET @@global.max_binlog_files = 5000;
7SET @@global.max_binlog_files = DEFAULT;
8SELECT @@global.max_binlog_files;
9@@global.max_binlog_files
100
11'#---------------------FN_DYNVARS_072_02-------------------------#'
12SET @@global.max_binlog_files = @start_value;
13SELECT @@global.max_binlog_files = 0;
14@@global.max_binlog_files = 0
151
16'#--------------------FN_DYNVARS_072_03------------------------#'
17SET @@global.max_binlog_files = 4;
18SELECT @@global.max_binlog_files;
19@@global.max_binlog_files
204
21SET @@global.max_binlog_files = 10;
22SELECT @@global.max_binlog_files;
23@@global.max_binlog_files
2410
25SET @@global.max_binlog_files = 10;
26SELECT @@global.max_binlog_files;
27@@global.max_binlog_files
2810
29SET @@global.max_binlog_files = 40;
30SELECT @@global.max_binlog_files;
31@@global.max_binlog_files
3240
33SET @@global.max_binlog_files = 65;
34SELECT @@global.max_binlog_files;
35@@global.max_binlog_files
3665
37'#--------------------FN_DYNVARS_072_04-------------------------#'
38SET @@global.max_binlog_files = -1;
39Warnings:
40Warning 1292 Truncated incorrect max_binlog_files value: '-1'
41SELECT @@global.max_binlog_files;
42@@global.max_binlog_files
430
44SET @@global.max_binlog_files = 100000000000;
45Warnings:
46Warning 1292 Truncated incorrect max_binlog_files value: '100000000000'
47SELECT @@global.max_binlog_files;
48@@global.max_binlog_files
49102400
50SET @@global.max_binlog_files = 10000.01;
51ERROR 42000: Incorrect argument type to variable 'max_binlog_files'
52SELECT @@global.max_binlog_files;
53@@global.max_binlog_files
54102400
55SET @@global.max_binlog_files = -1024;
56Warnings:
57Warning 1292 Truncated incorrect max_binlog_files value: '-1024'
58SELECT @@global.max_binlog_files;
59@@global.max_binlog_files
600
61SET @@global.max_binlog_files = 1024;
62SELECT @@global.max_binlog_files;
63@@global.max_binlog_files
641024
65SET @@global.max_binlog_files = 4294967296;
66Warnings:
67Warning 1292 Truncated incorrect max_binlog_files value: '4294967296'
68SELECT @@global.max_binlog_files;
69@@global.max_binlog_files
70102400
71SET @@global.max_binlog_files = 4095;
72SELECT @@global.max_binlog_files;
73@@global.max_binlog_files
744095
75SET @@global.max_binlog_files = ON;
76ERROR 42000: Incorrect argument type to variable 'max_binlog_files'
77SELECT @@global.max_binlog_files;
78@@global.max_binlog_files
794095
80SET @@global.max_binlog_files = 'test';
81ERROR 42000: Incorrect argument type to variable 'max_binlog_files'
82SELECT @@global.max_binlog_files;
83@@global.max_binlog_files
844095
85'#-------------------FN_DYNVARS_072_05----------------------------#'
86SET @@session.max_binlog_files = 4096;
87ERROR HY000: Variable 'max_binlog_files' is a GLOBAL variable and should be set with SET GLOBAL
88SELECT @@session.max_binlog_files;
89ERROR HY000: Variable 'max_binlog_files' is a GLOBAL variable
90'#----------------------FN_DYNVARS_072_06------------------------#'
91SELECT @@global.max_binlog_files = VARIABLE_VALUE
92FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
93WHERE VARIABLE_NAME='max_binlog_files';
94@@global.max_binlog_files = VARIABLE_VALUE
951
96SELECT @@max_binlog_files = VARIABLE_VALUE
97FROM INFORMATION_SCHEMA.SESSION_VARIABLES
98WHERE VARIABLE_NAME='max_binlog_files';
99@@max_binlog_files = VARIABLE_VALUE
1001
101'#---------------------FN_DYNVARS_072_07----------------------#'
102SET @@global.max_binlog_files = TRUE;
103SELECT @@global.max_binlog_files;
104@@global.max_binlog_files
1051
106SET @@global.max_binlog_files = FALSE;
107SELECT @@global.max_binlog_files;
108@@global.max_binlog_files
1090
110'#---------------------FN_DYNVARS_072_08----------------------#'
111SET @@global.max_binlog_files = 5000;
112SELECT @@max_binlog_files = @@global.max_binlog_files;
113@@max_binlog_files = @@global.max_binlog_files
1141
115'#---------------------FN_DYNVARS_072_09----------------------#'
116SET max_binlog_files = 6000;
117ERROR HY000: Variable 'max_binlog_files' is a GLOBAL variable and should be set with SET GLOBAL
118SELECT @@max_binlog_files;
119@@max_binlog_files
1205000
121SET local.max_binlog_files = 7000;
122ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'max_binlog_files = 7000' at line 1
123SELECT local.max_binlog_files;
124ERROR 42S02: Unknown table 'local' in field list
125SET global.max_binlog_files = 8000;
126ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'max_binlog_files = 8000' at line 1
127SELECT global.max_binlog_files;
128ERROR 42S02: Unknown table 'global' in field list
129SELECT max_binlog_files = @@session.max_binlog_files;
130ERROR 42S22: Unknown column 'max_binlog_files' in 'field list'
131SET @@global.max_binlog_files = @start_value;
132SELECT @@global.max_binlog_files;
133@@global.max_binlog_files
1340
0135
=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/max_binlog_files_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/max_binlog_files_basic.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/max_binlog_files_basic.test 2012-08-13 05:32:20 +0000
@@ -0,0 +1,147 @@
1--source include/load_sysvars.inc
2#test max-binlog-files, mostly copied from max_binlog_files test
3
4SET @start_value = @@global.max_binlog_files;
5SELECT @start_value;
6
7
8--echo '#--------------------FN_DYNVARS_072_01------------------------#'
9##################################################################
10# Display the DEFAULT value of max_binlog_files #
11##################################################################
12
13SET @@global.max_binlog_files = 5000;
14SET @@global.max_binlog_files = DEFAULT;
15SELECT @@global.max_binlog_files;
16
17--echo '#---------------------FN_DYNVARS_072_02-------------------------#'
18###############################################
19# Verify default value of variable #
20###############################################
21
22SET @@global.max_binlog_files = @start_value;
23SELECT @@global.max_binlog_files = 0;
24
25--echo '#--------------------FN_DYNVARS_072_03------------------------#'
26##################################################################
27# Change the value of max_binlog_files to a valid value #
28##################################################################
29
30SET @@global.max_binlog_files = 4;
31SELECT @@global.max_binlog_files;
32SET @@global.max_binlog_files = 10;
33SELECT @@global.max_binlog_files;
34SET @@global.max_binlog_files = 10;
35SELECT @@global.max_binlog_files;
36SET @@global.max_binlog_files = 40;
37SELECT @@global.max_binlog_files;
38SET @@global.max_binlog_files = 65;
39SELECT @@global.max_binlog_files;
40
41
42--echo '#--------------------FN_DYNVARS_072_04-------------------------#'
43#####################################################################
44# Change the value of max_binlog_files to invalid value #
45#####################################################################
46
47SET @@global.max_binlog_files = -1;
48SELECT @@global.max_binlog_files;
49SET @@global.max_binlog_files = 100000000000;
50SELECT @@global.max_binlog_files;
51--Error ER_WRONG_TYPE_FOR_VAR
52SET @@global.max_binlog_files = 10000.01;
53SELECT @@global.max_binlog_files;
54SET @@global.max_binlog_files = -1024;
55SELECT @@global.max_binlog_files;
56SET @@global.max_binlog_files = 1024;
57SELECT @@global.max_binlog_files;
58SET @@global.max_binlog_files = 4294967296;
59SELECT @@global.max_binlog_files;
60SET @@global.max_binlog_files = 4095;
61SELECT @@global.max_binlog_files;
62
63--Error ER_WRONG_TYPE_FOR_VAR
64SET @@global.max_binlog_files = ON;
65SELECT @@global.max_binlog_files;
66--Error ER_WRONG_TYPE_FOR_VAR
67SET @@global.max_binlog_files = 'test';
68SELECT @@global.max_binlog_files;
69
70
71--echo '#-------------------FN_DYNVARS_072_05----------------------------#'
72#####################################################################
73# Test if accessing session max_binlog_files gives error #
74#####################################################################
75
76--Error ER_GLOBAL_VARIABLE
77SET @@session.max_binlog_files = 4096;
78--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
79SELECT @@session.max_binlog_files;
80
81
82--echo '#----------------------FN_DYNVARS_072_06------------------------#'
83##############################################################################
84# Check if the value in GLOBAL & SESSION Tables matches values in variable #
85##############################################################################
86
87SELECT @@global.max_binlog_files = VARIABLE_VALUE
88FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
89WHERE VARIABLE_NAME='max_binlog_files';
90
91SELECT @@max_binlog_files = VARIABLE_VALUE
92FROM INFORMATION_SCHEMA.SESSION_VARIABLES
93WHERE VARIABLE_NAME='max_binlog_files';
94
95
96--echo '#---------------------FN_DYNVARS_072_07----------------------#'
97###################################################################
98# Check if TRUE and FALSE values can be used on variable #
99###################################################################
100
101SET @@global.max_binlog_files = TRUE;
102SELECT @@global.max_binlog_files;
103SET @@global.max_binlog_files = FALSE;
104SELECT @@global.max_binlog_files;
105
106
107--echo '#---------------------FN_DYNVARS_072_08----------------------#'
108########################################################################################################
109# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable #
110########################################################################################################
111
112SET @@global.max_binlog_files = 5000;
113SELECT @@max_binlog_files = @@global.max_binlog_files;
114
115
116--echo '#---------------------FN_DYNVARS_072_09----------------------#'
117##########################################################################
118# Check if max_binlog_files can be accessed with and without @@ sign #
119##########################################################################
120
121--Error ER_GLOBAL_VARIABLE
122SET max_binlog_files = 6000;
123SELECT @@max_binlog_files;
124--Error ER_PARSE_ERROR
125SET local.max_binlog_files = 7000;
126--Error ER_UNKNOWN_TABLE
127SELECT local.max_binlog_files;
128--Error ER_PARSE_ERROR
129SET global.max_binlog_files = 8000;
130--Error ER_UNKNOWN_TABLE
131SELECT global.max_binlog_files;
132--Error ER_BAD_FIELD_ERROR
133SELECT max_binlog_files = @@session.max_binlog_files;
134
135
136##############################
137# Restore initial value #
138##############################
139
140SET @@global.max_binlog_files = @start_value;
141SELECT @@global.max_binlog_files;
142
143
144##################################################################
145# END OF max_binlog_files TESTS #
146##################################################################
147
0148
=== modified file 'Percona-Server/sql/log.cc'
--- Percona-Server/sql/log.cc 2012-08-07 06:10:00 +0000
+++ Percona-Server/sql/log.cc 2012-08-13 05:32:20 +0000
@@ -1,4 +1,5 @@
1/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.1/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2 Copyright (C) 2012 Percona Inc.
23
3 This program is free software; you can redistribute it and/or modify4 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by5 it under the terms of the GNU General Public License as published by
@@ -59,6 +60,8 @@
5960
60LOGGER logger;61LOGGER logger;
6162
63ulong max_binlog_files;
64
62MYSQL_BIN_LOG mysql_bin_log(&sync_binlog_period);65MYSQL_BIN_LOG mysql_bin_log(&sync_binlog_period);
6366
64static bool test_if_number(const char *str,67static bool test_if_number(const char *str,
@@ -4139,6 +4142,74 @@
4139}4142}
41404143
4141/**4144/**
4145 Purge old logs so that we have a maximum of max_nr_files logs.
4146
4147 @param max_nr_files Maximum number of logfiles to have
4148
4149 @note
4150 If any of the logs before the deleted one is in use,
4151 only purge logs up to this one.
4152
4153 @retval
4154 0 ok
4155 @retval
4156 LOG_INFO_PURGE_NO_ROTATE Binary file that can't be rotated
4157 LOG_INFO_FATAL if any other than ENOENT error from
4158 mysql_file_stat() or mysql_file_delete()
4159*/
4160
4161int MYSQL_BIN_LOG::purge_logs_maximum_number(ulong max_nr_files)
4162{
4163 int error;
4164 char to_log[FN_REFLEN];
4165 LOG_INFO log_info;
4166 ulong current_number_of_logs= 1;
4167
4168 DBUG_ENTER("purge_logs_maximum_number");
4169
4170 mysql_mutex_lock(&LOCK_index);
4171 to_log[0]= 0;
4172
4173 if ((error=find_log_pos(&log_info, NullS, 0 /*no mutex*/)))
4174 goto err;
4175
4176 while (!find_next_log(&log_info, 0))
4177 current_number_of_logs++;
4178
4179 if (current_number_of_logs <= max_nr_files)
4180 {
4181 error= 0;
4182 goto err; /* No logs to expire */
4183 }
4184
4185 if ((error=find_log_pos(&log_info, NullS, 0 /*no mutex*/)))
4186 goto err;
4187
4188 while (strcmp(log_file_name, log_info.log_file_name) &&
4189 !is_active(log_info.log_file_name) &&
4190 !log_in_use(log_info.log_file_name) &&
4191 current_number_of_logs > max_nr_files)
4192 {
4193 current_number_of_logs--;
4194 strmake(to_log,
4195 log_info.log_file_name,
4196 sizeof(log_info.log_file_name) - 1);
4197
4198 if (find_next_log(&log_info, 0))
4199 {
4200 break;
4201 }
4202 }
4203
4204 error= (to_log[0] ? purge_logs(to_log, 1, 0, 1, (ulonglong *) 0) : 0);
4205
4206err:
4207 mysql_mutex_unlock(&LOCK_index);
4208 DBUG_RETURN(error);
4209}
4210
4211
4212/**
4142 Remove all logs before the given file date from disk and from the4213 Remove all logs before the given file date from disk and from the
4143 index file.4214 index file.
41444215
@@ -5315,6 +5386,10 @@
5315 purge_logs_before_date(purge_time);5386 purge_logs_before_date(purge_time);
5316 }5387 }
5317 }5388 }
5389 if (max_binlog_files)
5390 {
5391 purge_logs_maximum_number(max_binlog_files);
5392 }
5318#endif5393#endif
5319}5394}
53205395
@@ -5833,7 +5908,7 @@
58335908
5834 mysql_mutex_unlock(&LOCK_log);5909 mysql_mutex_unlock(&LOCK_log);
58355910
5836 if (xid_count > 0 && check_purge)5911 if (xid_count == 0 && check_purge)
5837 {5912 {
5838 purge();5913 purge();
5839 }5914 }
58405915
=== modified file 'Percona-Server/sql/log.h'
--- Percona-Server/sql/log.h 2012-08-07 06:10:00 +0000
+++ Percona-Server/sql/log.h 2012-08-13 05:32:20 +0000
@@ -569,6 +569,7 @@
569 int purge_logs(const char *to_log, bool included,569 int purge_logs(const char *to_log, bool included,
570 bool need_mutex, bool need_update_threads,570 bool need_mutex, bool need_update_threads,
571 ulonglong *decrease_log_space);571 ulonglong *decrease_log_space);
572 int purge_logs_maximum_number(ulong max_nr_files);
572 int purge_logs_before_date(time_t purge_time);573 int purge_logs_before_date(time_t purge_time);
573 int purge_first_log(Relay_log_info* rli, bool included);574 int purge_first_log(Relay_log_info* rli, bool included);
574 int set_purge_index_file_name(const char *base_file_name);575 int set_purge_index_file_name(const char *base_file_name);
575576
=== modified file 'Percona-Server/sql/mysqld.cc'
--- Percona-Server/sql/mysqld.cc 2012-08-07 06:10:00 +0000
+++ Percona-Server/sql/mysqld.cc 2012-08-13 05:32:20 +0000
@@ -4151,6 +4151,10 @@
4151 if (purge_time >= 0)4151 if (purge_time >= 0)
4152 mysql_bin_log.purge_logs_before_date(purge_time);4152 mysql_bin_log.purge_logs_before_date(purge_time);
4153 }4153 }
4154 if (opt_bin_log && max_binlog_files)
4155 {
4156 mysql_bin_log.purge_logs_maximum_number(max_binlog_files);
4157 }
4154#endif4158#endif
41554159
4156 if (opt_myisam_log)4160 if (opt_myisam_log)
41574161
=== modified file 'Percona-Server/sql/mysqld.h'
--- Percona-Server/sql/mysqld.h 2012-08-07 06:10:00 +0000
+++ Percona-Server/sql/mysqld.h 2012-08-13 05:32:20 +0000
@@ -142,6 +142,7 @@
142extern ulong max_long_data_size;142extern ulong max_long_data_size;
143extern ulong current_pid;143extern ulong current_pid;
144extern ulong expire_logs_days;144extern ulong expire_logs_days;
145extern ulong max_binlog_files;
145extern my_bool relay_log_recovery;146extern my_bool relay_log_recovery;
146extern uint sync_binlog_period, sync_relaylog_period, 147extern uint sync_binlog_period, sync_relaylog_period,
147 sync_relayloginfo_period, sync_masterinfo_period;148 sync_relayloginfo_period, sync_masterinfo_period;
148149
=== modified file 'Percona-Server/sql/sys_vars.cc'
--- Percona-Server/sql/sys_vars.cc 2012-08-07 06:10:00 +0000
+++ Percona-Server/sql/sys_vars.cc 2012-08-13 05:32:20 +0000
@@ -799,6 +799,14 @@
799 GLOBAL_VAR(expire_logs_days),799 GLOBAL_VAR(expire_logs_days),
800 CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 99), DEFAULT(0), BLOCK_SIZE(1));800 CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 99), DEFAULT(0), BLOCK_SIZE(1));
801801
802static Sys_var_ulong Sys_max_binlog_files(
803 "max_binlog_files",
804 "Maximum number of binlog files. Used with --max-binlog-size this can "
805 "be used to limit the total amount of disk space used for the binlog. "
806 "Default is 0, don't limit.",
807 GLOBAL_VAR(max_binlog_files),
808 CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 102400), DEFAULT(0), BLOCK_SIZE(1));
809
802static Sys_var_mybool Sys_flush(810static Sys_var_mybool Sys_flush(
803 "flush", "Flush MyISAM tables to disk between SQL commands",811 "flush", "Flush MyISAM tables to disk between SQL commands",
804 GLOBAL_VAR(myisam_flush),812 GLOBAL_VAR(myisam_flush),

Subscribers

People subscribed via source and target branches