Skip to content

Commit 59ee3cf

Browse files
committed
Bug 36417002 - [36416582->24.09] Executor service incorrectly re-creates task after each thrown yield after the task has been recovered after fail-over (merge main -> ce/main @ 107660)
[git-p4: depot-paths = "//dev/coherence-ce/main/": change = 107661]
1 parent 58efc4f commit 59ee3cf

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

prj/coherence-concurrent/src/main/java/com/oracle/coherence/concurrent/executor/ClusteredRegistration.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2023, Oracle and/or its affiliates.
2+
* Copyright (c) 2016, 2024, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -488,7 +488,7 @@ public TaskExecutor(String sTaskId, boolean fRecovered)
488488
m_task = null;
489489
m_cYield = 0;
490490
m_properties = null;
491-
f_fRecovered = fRecovered;
491+
m_fRecovered = fRecovered;
492492
}
493493

494494
// ----- public methods --------------------------------------------
@@ -569,7 +569,7 @@ public void run()
569569
boolean fIsCompleted;
570570

571571
// when resuming locally, just determine if we've completed the task
572-
if (isResuming() && (!f_fRecovered || m_task instanceof CronTask))
572+
if (isResuming() && (!m_fRecovered || m_task instanceof CronTask))
573573
{
574574
// when resuming, only extract the necessary information (like isCompleted)
575575
List listExtracted = (List) tasksCache.invoke(f_sTaskId,
@@ -579,7 +579,7 @@ public void run()
579579
// ensure the TaskExecutor still exists
580580
// (if it doesn't, the executor has been removed, thus we can skip execution)
581581
Object oIsCompleted =
582-
listExtracted == null || listExtracted.size() < 1 ? null : listExtracted.get(0);
582+
listExtracted == null || listExtracted.isEmpty() ? null : listExtracted.get(0);
583583

584584
if (oIsCompleted == null)
585585
{
@@ -709,6 +709,9 @@ else if (existing.equals(ClusteredAssignment.State.ASSIGNED)
709709
// increase the yield count (to indicate that we've yielded)
710710
m_cYield++;
711711

712+
// if we're here, reset the recovered flag, recovery has already been done
713+
m_fRecovered = false;
714+
712715
ExecutorTrace.log(() -> String.format("Executor [%s] scheduling Task [%s] to resume in %s",
713716
f_sExecutorId, f_sTaskId, yield.getDuration()));
714717

@@ -720,7 +723,7 @@ else if (existing.equals(ClusteredAssignment.State.ASSIGNED)
720723
yield.getDuration().toNanos(), TimeUnit.NANOSECONDS);
721724

722725
// we've yielded, so we're not finished
723-
fUpdateExecutionStatus = false;
726+
fUpdateExecutionStatus = false;
724727
fCleanupLocalExecutionResources = false;
725728
}
726729
catch (Throwable throwable)
@@ -839,7 +842,7 @@ public boolean isCancelled()
839842
@Override
840843
public boolean isResuming()
841844
{
842-
return m_cYield > 0 || f_fRecovered;
845+
return m_cYield > 0 || m_fRecovered;
843846
}
844847

845848
@Override
@@ -887,7 +890,7 @@ public String toString()
887890
"taskId='" + f_sTaskId + '\'' +
888891
", task=" + m_task +
889892
", yieldCount=" + m_cYield +
890-
", recovered=" + f_fRecovered +
893+
", recovered=" + m_fRecovered +
891894
", current-thread=" + m_executionThread +
892895
'}';
893896
}
@@ -912,7 +915,7 @@ public String toString()
912915
/**
913916
* Indicates if the {@link Task} was previously assigned to a different {@link Executor}.
914917
*/
915-
protected final boolean f_fRecovered;
918+
protected boolean m_fRecovered;
916919

917920
/**
918921
* The task {@link Task.Properties}.

0 commit comments

Comments
 (0)