From a7089186be5f6eb0134c7a48b40b21ace68aecd6 Mon Sep 17 00:00:00 2001 From: "David M. Johnson" Date: Mon, 24 Sep 2018 14:56:38 -0600 Subject: [PATCH] Fix an IsFeasible bug where start and end of different reservations overlap. When IsFeasible processes the list of events (i.e. reservation start/end, expt start/end), it processes them in sorted order of event time, but if times are equal, there is no secondary sort, and thus the additive (incoming) reservation might be processed before the reductive (outgoing) reservation), which would create a false negative hole in the forecast. This commit adds the secondary sort. --- db/Reservation.pm.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/db/Reservation.pm.in b/db/Reservation.pm.in index 71c682d6a..dc9169c07 100755 --- a/db/Reservation.pm.in +++ b/db/Reservation.pm.in @@ -828,8 +828,15 @@ sub IsFeasible($$;$$$$$) push( @$forecast, \%origin ); } - my @events = sort { $a->{'t'} <=> $b->{'t'} } @timeline; - + my @events = sort { + if ($a->{'t'} == $b->{'t'}) { + return $a->{'reserved'} <=> $b->{'reserved'}; + } + else { + return $a->{'t'} <=> $b->{'t'}; + } + } @timeline; + foreach my $event ( @events ) { my $pid = $event->{'pid'}; -- GitLab