Commit 52f02d01 authored by Leigh B Stoller's avatar Leigh B Stoller

Look for and delete unused reserved_vlantags

parent 5c358e1b
......@@ -561,6 +561,52 @@ if (!$MAINSITE) {
}
}
#
# Look for (and delete) reserved vlan tags that are no longer in use.
# We seem to be leaking these.
#
$query_result =
DBQueryFatal("select v.pid,v.eid,v.vname,v.tag,v.lanid,e.state, ".
" h.history_id,h.released ".
" from reserved_vlantags as v ".
"left join lans as l on l.lanid=v.lanid ".
"left join experiments as e on e.idx=v.exptidx ".
"left join vlantag_history as h on ".
" h.exptidx=v.exptidx and h.lanid=v.lanid and h.tag=v.tag ".
"where l.lanid is null and ".
" (UNIX_TIMESTAMP(now()) - ".
" UNIX_TIMESTAMP(reserve_time)) > (2 * 3600)");
if ($query_result->numrows) {
print "\n";
print "----------------------------------------------------------------\n";
print "\n";
print "Stale reserved vlan tags\n";
print "----------------------------------------------------------------\n";
}
while (my ($pid,$eid,$lan,$tag,$lanid,$estate,$hid,$released) =
$query_result->fetchrow_array()) {
next
if ($estate eq EXPTSTATE_ACTIVATING());
if ($estate eq EXPTSTATE_ACTIVE()) {
print "Active Experiment with reserved tag points to deleted lanid\n";
print " $pid,$eid,$lan,$tag,$lanid\n";
next;
}
print "Deleting stale vlan tag reservation: $tag ($pid,$eid,$lan)\n";
if ($hid && !defined($released)) {
print "--> but leaving stale vlantag_history record $hid\n";
}
next
if ($impotent);
DBQueryWarn("delete from reserved_vlantags where tag='$tag'")
or Fatal("Could not delete stale reserved vlan tag $tag");
}
#
# Send email if anything was reported.
#
......
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