Commit e49ebc93 authored by Kevin Atkinson's avatar Kevin Atkinson

Limit the number of rows dumperrorlog works with at at time to avoid

locking the "log" table (and hence preventing swap activity) for too
long.
parent ce1f4359
......@@ -19,6 +19,10 @@ my $debug = 0;
my $force = 0;
my $tempfile = "/var/tmp/testbed_dumperrorlog_tempfile";
my $keep_important = 7 * 24 * 60 * 60;
my $keep_any = 4 * 24 * 60 * 60;
my $max_rows = 300000;
#
# Configure variables
#
......@@ -100,6 +104,11 @@ if (!defined($lastseq)) {
$lastseq = 0;
}
#
# Limit number of rows to keep from locking the log table too long
#
my $maxseq = $lastseq + $max_rows;
#
# And the last experiment index we sent over.
#
......@@ -145,6 +154,7 @@ if ($ISMAINSITE) {
#
DBQueryFatal("select * from log ".
"where seq > $lastseq " .
"and seq <= $maxseq " .
"into outfile '${tempfile}.log' ");
#
......@@ -155,6 +165,7 @@ if ($ISMAINSITE) {
$query_result =
DBQueryFatal("select seq from log ".
"where seq > $lastseq " .
" and seq <= $maxseq ".
"order by seq desc limit 1");
# Save for later.
($lastseq) = $query_result->fetchrow_array();
......@@ -206,13 +217,13 @@ if ($ISMAINSITE) {
"report_assign_violation") {
if (($tablename eq "errors" ||
$tablename eq "session_info") && !$force) {
DBQueryFatal("select * from $tablename where session>=$firstseq ".
DBQueryFatal("select * from $tablename where session>=$firstseq and session<=$lastseq ".
"into outfile '${tempfile}.${tablename}' ");
}
elsif ($tablename eq "report_error" ||
$tablename eq "report_context" ||
$tablename eq "report_assign_violation") {
DBQueryFatal("select * from $tablename where seq>=$firstseq ".
DBQueryFatal("select * from $tablename where seq>=$firstseq and seq<=$lastseq ".
"into outfile '${tempfile}.${tablename}' ");
}
elsif ($tablename eq "users") {
......@@ -260,14 +271,16 @@ DBQueryFatal("update emulab_indicies set idx='$exptidx_max' ".
# And then age out entries.
#
DBQueryFatal("delete from log ".
"where stamp < (UNIX_TIMESTAMP(now()) - (7 * 24 * 60 * 60))");
"where stamp < (UNIX_TIMESTAMP(now()) - $keep_important)".
" and seq <= $maxseq");
#
# And age out non critical data.
#
DBQueryFatal("delete from log ".
"where priority > $NOTICE and ".
" stamp < (UNIX_TIMESTAMP(now()) - (4 * 24 * 60 * 60))");
" stamp < (UNIX_TIMESTAMP(now()) - $keep_any)".
" and seq <= $maxseq");
unlink("$logname")
if (-e $logname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment