Skip to content

Commit 204cbaf

Browse files
committed
Better handle the situation where a cluster job was re-submitted before the prior submission fully ended
1 parent 4eec467 commit 204cbaf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cluster/src/org/labkey/cluster/pipeline/AbstractClusterExecutionEngine.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ protected void updateJobStatus(@Nullable String status, ClusterJob j, @Nullable
487487
j.setLastStatusCheck(new Date());
488488
j.setStatus(status);
489489

490+
491+
ClusterJob mostRecent = getMostRecentClusterSubmission(j.getJobId(), true);
492+
boolean hasNewerSubmission = mostRecent != null && j.getClusterId() != null && !j.getClusterId().equals(mostRecent.getClusterId());
493+
490494
PipelineStatusFile sf = PipelineService.get().getStatusFile(j.getStatusFileId());
491495
if (sf != null)
492496
{
@@ -502,13 +506,20 @@ protected void updateJobStatus(@Nullable String status, ClusterJob j, @Nullable
502506
statusChanged = true;
503507
}
504508

505-
if (status != null && !statusChanged && !sf.getStatus().equalsIgnoreCase(j.getStatus()))
509+
if (!hasNewerSubmission && status != null && !statusChanged && !sf.getStatus().equalsIgnoreCase(j.getStatus()))
506510
{
507511
_log.info("ClusterExecutionEngine reports status not changed for job: " + sf.getRowId() + ", but was: " + status + " / statusfile: " + sf.getStatus() + " / cluster job: " + j.getStatus());
508512
statusChanged = true;
509513
}
510514
}
511515

516+
// Because it is possible for a prior submission to report a status, only update the PipelineJob itself if this is the latest submission.
517+
if (hasNewerSubmission)
518+
{
519+
_log.error("There is a newer submission for job: " + sf.getRowId() + ". Skipping update for cluster ID: " + j.getClusterId() + " in favor of " + mostRecent.getClusterId());
520+
statusChanged = false;
521+
}
522+
512523
//no need to redundantly update PipelineJob
513524
if (!statusChanged)
514525
{

0 commit comments

Comments
 (0)