Skip to content

Commit 37e79b7

Browse files
committed
IGNITE-28189 Fixed incorrect status of a Compute Task when it is canceled
1 parent 40d9b61 commit 37e79b7

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -748,23 +748,21 @@ else if (sysStopping && X.hasCause(e, InterruptedException.class, IgniteInterrup
748748
*/
749749
public void cancel(boolean sys) {
750750
try {
751-
final ComputeJob job0 = job;
751+
if (log.isDebugEnabled())
752+
log.debug("Cancelling job: " + ses);
753+
754+
status = CANCELLED;
752755

753756
if (sys)
754757
sysCancelled = true;
755758

756-
if (job0 != null) {
757-
if (log.isDebugEnabled())
758-
log.debug("Cancelling job: " + ses);
759-
760-
status = CANCELLED;
759+
final ComputeJob job0 = job;
761760

762-
U.wrapThreadLoader(dep.classLoader(), (IgniteRunnable)() -> {
763-
try (Scope ignored = ctx.security().withContext(secCtx)) {
764-
job0.cancel();
765-
}
766-
});
767-
}
761+
U.wrapThreadLoader(dep.classLoader(), (IgniteRunnable)() -> {
762+
try (Scope ignored = ctx.security().withContext(secCtx)) {
763+
job0.cancel();
764+
}
765+
});
768766

769767
// Interrupting only when all 'cancelled' flags are set.
770768
// This allows the 'job' to determine it's a cancellation.
@@ -1091,6 +1089,11 @@ ComputeJobStatusEnum status() {
10911089
return jobId.hashCode();
10921090
}
10931091

1092+
/** {@inheritDoc} */
1093+
@Override public boolean isCancelled() {
1094+
return status == CANCELLED;
1095+
}
1096+
10941097
/** {@inheritDoc} */
10951098
@Override protected void onCancel(boolean firstCancelRequest) {
10961099
if (firstCancelRequest)

0 commit comments

Comments
 (0)