Commit 1f5cc798 authored by Leigh B Stoller's avatar Leigh B Stoller

Another fix to the resource records code. Sigh.

parent a5bd23ab
......@@ -2076,6 +2076,8 @@ sub PreSwap($$$$)
$swapper->BumpActivity();
$self->GetProject()->BumpActivity();
$self->GetGroup()->BumpActivity();
$self->Refresh() == 0
or goto failed;
return 0;
failed:
......@@ -2157,16 +2159,7 @@ sub SwapFail($$$$;$)
"where idx='$rsrcidx'")
or return -1;
if ($which eq $EXPT_SWAPMOD &&
$self->state() eq libdb::EXPTSTATE_ACTIVE()) {
DBQueryWarn("update experiment_resources set ".
($flags & libdb::TBDB_STATS_FLAGS_MODHOSED() ?
"swapout_time=swapmod_time, " : " ") .
"swapmod_time=0 ".
"where idx='$lastrsrc'")
or return -1;
}
# Delete it.
DBQueryWarn("delete from experiment_resources ".
"where idx=$rsrcidx")
or return -1;
......@@ -2225,6 +2218,21 @@ sub PostSwap($$$$)
my $prev_swapper = $swapper;
my $query_result;
#
# Need to update the previous record with the swapmod_time.
#
if ($which eq $EXPT_SWAPMOD) {
my $when = "UNIX_TIMESTAMP(now())";
# unless its active, in which case pick up swapin time.
$when = $self->swapin_time()
if ($self->state() eq libdb::EXPTSTATE_ACTIVE());
DBQueryWarn("update experiment_resources set ".
" swapmod_time=$when ".
"where idx='$lastrsrc'")
or return -1;
}
if ($which eq $EXPT_SWAPOUT ||
($which eq $EXPT_SWAPMOD &&
$self->state() eq libdb::EXPTSTATE_ACTIVE())) {
......@@ -2246,7 +2254,7 @@ sub PostSwap($$$$)
DBQueryWarn("select r.pnodes,r.vnodes,r.uid_idx, ".
" r.swapmod_time - r.swapin_time ".
" from experiment_resources as r ".
"where r.idx='$rsrcidx'");
"where r.idx='$lastrsrc'");
}
return -1
if (!$query_result);
......@@ -2264,18 +2272,6 @@ sub PostSwap($$$$)
}
}
if ($which eq $EXPT_SWAPMOD) {
my $when = "UNIX_TIMESTAMP(now())";
# unless its active, in which case pick up swapin time.
$when = $self->swapin_time()
if ($self->state() eq libdb::EXPTSTATE_ACTIVE());
DBQueryWarn("update experiment_resources set ".
" swapmod_time=$when ".
"where idx='$lastrsrc'")
or return -1;
}
# Special case for initial record. Needs to be fixed.
if ($which eq $EXPT_SWAPIN && !$self->lastidx()) {
DBQueryWarn("update experiment_resources set byswapin=1 ".
......
......@@ -1402,14 +1402,19 @@ sub cleanup()
}
elsif ($inout eq "modify") {
#
# If the modify fails, and the experiment is swapped out, then
# insert a record for that since that is different then a modify
# that fails, but results in the experiment being restored the
# way it was.
# If the modify fails, must clean up the record (remove it).
#
$experiment->SwapFail($this_user, TBDB_STATS_SWAPMODIFY, $errorstat);
#
# If it got swapped out, then force this into the record. The
# time stamps will be funky, but no big deal. Just looks like a
# really fast swapout.
#
$experiment->SwapFail($this_user, TBDB_STATS_SWAPMODIFY, $errorstat,
($modifyHosed ? TBDB_STATS_FLAGS_MODHOSED() :0));
if ($modifySwapped) {
$experiment->PreSwap($this_user,
TBDB_STATS_SWAPOUT, EXPTSTATE_ACTIVE);
sleep(1);
$experiment->PostSwap($this_user, TBDB_STATS_SWAPOUT);
}
}
......
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