Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
e7f4bf5b
Commit
e7f4bf5b
authored
Mar 11, 2003
by
gluh@gluh.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 'PURGE LOGS BEFORE' command
Added expire-logs-days option
parent
2022b7b6
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
35 deletions
+42
-35
mysql-test/r/rpl_rotate_logs.result
mysql-test/r/rpl_rotate_logs.result
+6
-1
mysql-test/t/rpl_rotate_logs.test
mysql-test/t/rpl_rotate_logs.test
+3
-1
sql/log.cc
sql/log.cc
+19
-23
sql/mysqld.cc
sql/mysqld.cc
+3
-3
sql/set_var.cc
sql/set_var.cc
+4
-0
sql/sql_class.h
sql/sql_class.h
+1
-0
sql/sql_parse.cc
sql/sql_parse.cc
+1
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+5
-6
No files found.
mysql-test/r/rpl_rotate_logs.result
View file @
e7f4bf5b
...
@@ -40,7 +40,12 @@ set insert_id=1234;
...
@@ -40,7 +40,12 @@ set insert_id=1234;
insert into t2 values(NULL);
insert into t2 values(NULL);
set global sql_slave_skip_counter=1;
set global sql_slave_skip_counter=1;
start slave;
start slave;
purge master logs to 'master-bin.000003';
purge master logs to 'master-bin.000002';
show binary logs;
Log_name
master-bin.000002
master-bin.000003
purge logs before now();
show binary logs;
show binary logs;
Log_name
Log_name
master-bin.000003
master-bin.000003
...
...
mysql-test/t/rpl_rotate_logs.test
View file @
e7f4bf5b
...
@@ -89,7 +89,9 @@ connection master;
...
@@ -89,7 +89,9 @@ connection master;
#let slave catch up
#let slave catch up
sync_slave_with_master
;
sync_slave_with_master
;
connection
master
;
connection
master
;
purge
master
logs
to
'master-bin.000003'
;
purge
master
logs
to
'master-bin.000002'
;
show
binary
logs
;
purge
logs
before
now
();
show
binary
logs
;
show
binary
logs
;
insert
into
t2
values
(
65
);
insert
into
t2
values
(
65
);
sync_slave_with_master
;
sync_slave_with_master
;
...
...
sql/log.cc
View file @
e7f4bf5b
...
@@ -679,6 +679,19 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli)
...
@@ -679,6 +679,19 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli)
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
/*
Update log index_file
*/
int
MYSQL_LOG
::
update_log_index
(
LOG_INFO
*
log_info
)
{
if
(
copy_up_file_and_fill
(
&
index_file
,
log_info
->
index_file_start_offset
))
return
LOG_INFO_IO
;
// now update offsets in index file for running threads
adjust_linfo_offsets
(
log_info
->
index_file_start_offset
);
return
0
;
}
/*
/*
Remove all logs before the given log from disk and from the index file.
Remove all logs before the given log from disk and from the index file.
...
@@ -731,15 +744,7 @@ int MYSQL_LOG::purge_logs(THD* thd, const char* to_log)
...
@@ -731,15 +744,7 @@ int MYSQL_LOG::purge_logs(THD* thd, const char* to_log)
If we get killed -9 here, the sysadmin would have to edit
If we get killed -9 here, the sysadmin would have to edit
the log index file after restart - otherwise, this should be safe
the log index file after restart - otherwise, this should be safe
*/
*/
error
=
update_log_index
(
&
log_info
);
if
(
copy_up_file_and_fill
(
&
index_file
,
log_info
.
index_file_start_offset
))
{
error
=
LOG_INFO_IO
;
goto
err
;
}
// now update offsets in index file for running threads
adjust_linfo_offsets
(
log_info
.
index_file_start_offset
);
err:
err:
pthread_mutex_unlock
(
&
LOCK_index
);
pthread_mutex_unlock
(
&
LOCK_index
);
...
@@ -789,11 +794,10 @@ int MYSQL_LOG::purge_logs_before_date(THD* thd, time_t purge_time)
...
@@ -789,11 +794,10 @@ int MYSQL_LOG::purge_logs_before_date(THD* thd, time_t purge_time)
!
log_in_use
(
log_info
.
log_file_name
))
!
log_in_use
(
log_info
.
log_file_name
))
{
{
/* It's not fatal even if we can't delete a log file */
/* It's not fatal even if we can't delete a log file */
if
(
my_stat
(
log_info
.
log_file_name
,
&
stat_area
,
MYF
(
0
))
&&
if
(
!
my_stat
(
log_info
.
log_file_name
,
&
stat_area
,
MYF
(
0
))
||
stat_area
.
st_mtime
<
purge_time
)
stat_area
.
st_mtime
>=
purge_time
)
my_delete
(
log_info
.
log_file_name
,
MYF
(
0
));
else
break
;
break
;
my_delete
(
log_info
.
log_file_name
,
MYF
(
0
));
if
(
find_next_log
(
&
log_info
,
0
))
if
(
find_next_log
(
&
log_info
,
0
))
break
;
break
;
}
}
...
@@ -802,15 +806,7 @@ int MYSQL_LOG::purge_logs_before_date(THD* thd, time_t purge_time)
...
@@ -802,15 +806,7 @@ int MYSQL_LOG::purge_logs_before_date(THD* thd, time_t purge_time)
If we get killed -9 here, the sysadmin would have to edit
If we get killed -9 here, the sysadmin would have to edit
the log index file after restart - otherwise, this should be safe
the log index file after restart - otherwise, this should be safe
*/
*/
error
=
update_log_index
(
&
log_info
);
if
(
copy_up_file_and_fill
(
&
index_file
,
log_info
.
index_file_start_offset
))
{
error
=
LOG_INFO_IO
;
goto
err
;
}
// now update offsets in index file for running threads
adjust_linfo_offsets
(
log_info
.
index_file_start_offset
);
err:
err:
pthread_mutex_unlock
(
&
LOCK_index
);
pthread_mutex_unlock
(
&
LOCK_index
);
...
@@ -1235,7 +1231,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
...
@@ -1235,7 +1231,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
}
}
pthread_mutex_unlock
(
&
LOCK_log
);
pthread_mutex_unlock
(
&
LOCK_log
);
if
(
should_rotate
&&
~
expire_logs_days
)
if
(
should_rotate
&&
expire_logs_days
)
{
{
long
purge_time
=
time
(
0
)
-
expire_logs_days
*
24
*
60
*
60
;
long
purge_time
=
time
(
0
)
-
expire_logs_days
*
24
*
60
*
60
;
if
(
purge_time
>=
0
)
if
(
purge_time
>=
0
)
...
...
sql/mysqld.cc
View file @
e7f4bf5b
...
@@ -392,7 +392,7 @@ ulong max_connections,max_insert_delayed_threads,max_used_connections,
...
@@ -392,7 +392,7 @@ ulong max_connections,max_insert_delayed_threads,max_used_connections,
max_connect_errors
,
max_user_connections
=
0
;
max_connect_errors
,
max_user_connections
=
0
;
ulong
thread_id
=
1L
,
current_pid
;
ulong
thread_id
=
1L
,
current_pid
;
ulong
slow_launch_threads
=
0
;
ulong
slow_launch_threads
=
0
;
ulong
expire_logs_days
=
~
0L
;
ulong
expire_logs_days
=
0
;
char
mysql_real_data_home
[
FN_REFLEN
],
char
mysql_real_data_home
[
FN_REFLEN
],
language
[
LIBLEN
],
reg_ext
[
FN_EXTLEN
],
language
[
LIBLEN
],
reg_ext
[
FN_EXTLEN
],
...
@@ -2159,7 +2159,7 @@ The server will not act as a slave.");
...
@@ -2159,7 +2159,7 @@ The server will not act as a slave.");
open_log
(
&
mysql_bin_log
,
glob_hostname
,
opt_bin_logname
,
"-bin"
,
open_log
(
&
mysql_bin_log
,
glob_hostname
,
opt_bin_logname
,
"-bin"
,
opt_binlog_index_name
,
LOG_BIN
);
opt_binlog_index_name
,
LOG_BIN
);
using_update_log
=
1
;
using_update_log
=
1
;
if
(
~
expire_logs_days
)
if
(
expire_logs_days
)
{
{
long
purge_time
=
time
(
0
)
-
expire_logs_days
*
24
*
60
*
60
;
long
purge_time
=
time
(
0
)
-
expire_logs_days
*
24
*
60
*
60
;
if
(
purge_time
>=
0
)
if
(
purge_time
>=
0
)
...
@@ -4031,7 +4031,7 @@ struct my_option my_long_options[] =
...
@@ -4031,7 +4031,7 @@ struct my_option my_long_options[] =
"Logs will be rotated after expire-log-days days. "
,
"Logs will be rotated after expire-log-days days. "
,
(
gptr
*
)
&
expire_logs_days
,
(
gptr
*
)
&
expire_logs_days
,
(
gptr
*
)
&
expire_logs_days
,
0
,
GET_ULONG
,
(
gptr
*
)
&
expire_logs_days
,
0
,
GET_ULONG
,
REQUIRED_ARG
,
~
0L
,
0
,
99
,
0
,
1
,
0
},
REQUIRED_ARG
,
0
,
0
,
99
,
0
,
1
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
}
{
0
,
0
,
0
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
}
};
};
...
...
sql/set_var.cc
View file @
e7f4bf5b
...
@@ -118,6 +118,8 @@ sys_var_long_ptr sys_delayed_insert_timeout("delayed_insert_timeout",
...
@@ -118,6 +118,8 @@ sys_var_long_ptr sys_delayed_insert_timeout("delayed_insert_timeout",
&
delayed_insert_timeout
);
&
delayed_insert_timeout
);
sys_var_long_ptr
sys_delayed_queue_size
(
"delayed_queue_size"
,
sys_var_long_ptr
sys_delayed_queue_size
(
"delayed_queue_size"
,
&
delayed_queue_size
);
&
delayed_queue_size
);
sys_var_long_ptr
sys_expire_logs_days
(
"expire_logs_days"
,
&
expire_logs_days
);
sys_var_bool_ptr
sys_flush
(
"flush"
,
&
myisam_flush
);
sys_var_bool_ptr
sys_flush
(
"flush"
,
&
myisam_flush
);
sys_var_long_ptr
sys_flush_time
(
"flush_time"
,
&
flush_time
);
sys_var_long_ptr
sys_flush_time
(
"flush_time"
,
&
flush_time
);
sys_var_thd_ulong
sys_interactive_timeout
(
"interactive_timeout"
,
sys_var_thd_ulong
sys_interactive_timeout
(
"interactive_timeout"
,
...
@@ -332,6 +334,7 @@ sys_var *sys_variables[]=
...
@@ -332,6 +334,7 @@ sys_var *sys_variables[]=
&
sys_delayed_insert_timeout
,
&
sys_delayed_insert_timeout
,
&
sys_delayed_queue_size
,
&
sys_delayed_queue_size
,
&
sys_error_count
,
&
sys_error_count
,
&
sys_expire_logs_days
,
&
sys_flush
,
&
sys_flush
,
&
sys_flush_time
,
&
sys_flush_time
,
&
sys_foreign_key_checks
,
&
sys_foreign_key_checks
,
...
@@ -435,6 +438,7 @@ struct show_var_st init_vars[]= {
...
@@ -435,6 +438,7 @@ struct show_var_st init_vars[]= {
{
sys_delayed_insert_limit
.
name
,
(
char
*
)
&
sys_delayed_insert_limit
,
SHOW_SYS
},
{
sys_delayed_insert_limit
.
name
,
(
char
*
)
&
sys_delayed_insert_limit
,
SHOW_SYS
},
{
sys_delayed_insert_timeout
.
name
,
(
char
*
)
&
sys_delayed_insert_timeout
,
SHOW_SYS
},
{
sys_delayed_insert_timeout
.
name
,
(
char
*
)
&
sys_delayed_insert_timeout
,
SHOW_SYS
},
{
sys_delayed_queue_size
.
name
,(
char
*
)
&
sys_delayed_queue_size
,
SHOW_SYS
},
{
sys_delayed_queue_size
.
name
,(
char
*
)
&
sys_delayed_queue_size
,
SHOW_SYS
},
{
sys_expire_logs_days
.
name
,
(
char
*
)
&
sys_expire_logs_days
,
SHOW_SYS
},
{
sys_flush
.
name
,
(
char
*
)
&
sys_flush
,
SHOW_SYS
},
{
sys_flush
.
name
,
(
char
*
)
&
sys_flush
,
SHOW_SYS
},
{
sys_flush_time
.
name
,
(
char
*
)
&
sys_flush_time
,
SHOW_SYS
},
{
sys_flush_time
.
name
,
(
char
*
)
&
sys_flush_time
,
SHOW_SYS
},
{
"ft_min_word_len"
,
(
char
*
)
&
ft_min_word_len
,
SHOW_LONG
},
{
"ft_min_word_len"
,
(
char
*
)
&
ft_min_word_len
,
SHOW_LONG
},
...
...
sql/sql_class.h
View file @
e7f4bf5b
...
@@ -133,6 +133,7 @@ class MYSQL_LOG {
...
@@ -133,6 +133,7 @@ class MYSQL_LOG {
int
generate_new_name
(
char
*
new_name
,
const
char
*
old_name
);
int
generate_new_name
(
char
*
new_name
,
const
char
*
old_name
);
void
make_log_name
(
char
*
buf
,
const
char
*
log_ident
);
void
make_log_name
(
char
*
buf
,
const
char
*
log_ident
);
bool
is_active
(
const
char
*
log_file_name
);
bool
is_active
(
const
char
*
log_file_name
);
int
update_log_index
(
LOG_INFO
*
linfo
);
int
purge_logs
(
THD
*
thd
,
const
char
*
to_log
);
int
purge_logs
(
THD
*
thd
,
const
char
*
to_log
);
int
purge_logs_before_date
(
THD
*
thd
,
time_t
purge_time
);
int
purge_logs_before_date
(
THD
*
thd
,
time_t
purge_time
);
int
purge_first_log
(
struct
st_relay_log_info
*
rli
);
int
purge_first_log
(
struct
st_relay_log_info
*
rli
);
...
...
sql/sql_parse.cc
View file @
e7f4bf5b
...
@@ -3813,7 +3813,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
...
@@ -3813,7 +3813,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
mysql_log
.
new_file
(
1
);
mysql_log
.
new_file
(
1
);
mysql_update_log
.
new_file
(
1
);
mysql_update_log
.
new_file
(
1
);
mysql_bin_log
.
new_file
(
1
);
mysql_bin_log
.
new_file
(
1
);
if
(
~
expire_logs_days
)
if
(
expire_logs_days
)
{
{
long
purge_time
=
time
(
0
)
-
expire_logs_days
*
24
*
60
*
60
;
long
purge_time
=
time
(
0
)
-
expire_logs_days
*
24
*
60
*
60
;
if
(
purge_time
>=
0
)
if
(
purge_time
>=
0
)
...
...
sql/sql_yacc.yy
View file @
e7f4bf5b
...
@@ -3565,10 +3565,9 @@ purge:
...
@@ -3565,10 +3565,9 @@ purge:
;
;
purge_options:
purge_options:
LOGS_SYM
LOGS_SYM purge_option
purge_option
| MASTER_SYM LOGS_SYM purge_option
| MASTER_SYM LOGS_SYM
;
purge_option;
purge_option:
purge_option:
TO_SYM TEXT_STRING
TO_SYM TEXT_STRING
...
@@ -3586,7 +3585,8 @@ purge_option:
...
@@ -3586,7 +3585,8 @@ purge_option:
Item *tmp= new Item_func_unix_timestamp($2);
Item *tmp= new Item_func_unix_timestamp($2);
Lex->sql_command = SQLCOM_PURGE_BEFORE;
Lex->sql_command = SQLCOM_PURGE_BEFORE;
Lex->purge_time= tmp->val_int();
Lex->purge_time= tmp->val_int();
};
}
;
/* kill threads */
/* kill threads */
...
@@ -3596,7 +3596,6 @@ kill:
...
@@ -3596,7 +3596,6 @@ kill:
LEX *lex=Lex;
LEX *lex=Lex;
if ($2->check_cols(1) || $2->fix_fields(lex->thd, 0, &$2))
if ($2->check_cols(1) || $2->fix_fields(lex->thd, 0, &$2))
{
{
send_error(lex->thd, ER_SET_CONSTANTS_ONLY);
send_error(lex->thd, ER_SET_CONSTANTS_ONLY);
YYABORT;
YYABORT;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment