[ 
https://issues.apache.org/jira/browse/IGNITE-23688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17898713#comment-17898713
 ] 

Vadim Pakhnushev commented on IGNITE-23688:
-------------------------------------------

The test is incorrect. It doesn't wait for the {{cancelAsync}} future to 
complete.
So what happens is Awaitility calls {{cancelAsync}}, which doesn't complete 
immediately since it's going to another node via the network messaging service.
Awaitility sees that the future is not completed, waits for 100 ms and calls it 
again.
In the mean time the first cancel request completes, job is properly cancelled 
and next cancel requests complete with the message in the logs that the job 
cannot be cancelled since it is already in this state.

> Compute execution assertion in embedded mode
> --------------------------------------------
>
>                 Key: IGNITE-23688
>                 URL: https://issues.apache.org/jira/browse/IGNITE-23688
>             Project: Ignite
>          Issue Type: Bug
>          Components: compute
>    Affects Versions: 3.0.0-beta1
>            Reporter: Evgeny Stanilovsky
>            Assignee: Vadim Pakhnushev
>            Priority: Major
>              Labels: ignite-3
>
> I failed to run near test in embedded mode:
> append into ItComputeBaseTest
> {code:java}
>     @ParameterizedTest(name = "local: {0}")
>     @ValueSource(booleans = {true, false})
>     void cancelComputeSubmitWithCancelHandle(boolean local) {
>         Ignite entryNode = node(0);
>         Ignite executeNode = local ? node(0) : node(1);
>         JobDescriptor<Long, Void> job = 
> JobDescriptor.builder(SilentSleepJob.class)
>                 .options(executionOptions).units(units()).build();
>         JobExecution<Void> execution = 
> entryNode.compute().submit(JobTarget.node(clusterNode(executeNode)), job, 
> 100L);
>         await().atMost(10, TimeUnit.SECONDS).until(() -> 
> execution.cancelAsync().isDone());
>         await().atMost(10, TimeUnit.SECONDS).until(() -> 
> execution.resultAsync().isDone());
>     }
> {code}
> and 
> into : package org.apache.ignite.internal.compute
> {code:java}
> public class SilentSleepJob implements ComputeJob<Long, Void> {
>     @Override
>     public CompletableFuture<Void> executeAsync(JobExecutionContext 
> jobExecutionContext, Long timeout) {
>         try {
>             TimeUnit.SECONDS.sleep(timeout);
>         } catch (InterruptedException e) {
>             // no op.
>         }
>         return null;
>     }
> }
> {code}
> got:
> {noformat}
> org.apache.ignite.internal.compute.state.IllegalJobStatusTransition: Failed 
> to transition job b692660b-e3ec-4749-80b8-ef1f39d9b7d7 from status CANCELED 
> to status CANCELING
>       at 
> org.apache.ignite.internal.compute.state.InMemoryComputeStateMachine.lambda$cancelingJob$0(InMemoryComputeStateMachine.java:124)
>  ~[main/:?]
>       at 
> org.apache.ignite.internal.compute.state.InMemoryComputeStateMachine.lambda$changeJobStatus$2(InMemoryComputeStateMachine.java:141)
>  ~[main/:?]
>       at 
> org.apache.ignite.internal.compute.state.InMemoryComputeStateMachine.lambda$changeStatus$3(InMemoryComputeStateMachine.java:158)
>  ~[main/:?]
>       at 
> java.base/java.util.concurrent.ConcurrentHashMap.computeIfPresent(ConcurrentHashMap.java:1822)
>  ~[?:?]
>       at 
> org.apache.ignite.internal.compute.state.InMemoryComputeStateMachine.changeStatus(InMemoryComputeStateMachine.java:158)
>  ~[main/:?]
>       at 
> org.apache.ignite.internal.compute.state.InMemoryComputeStateMachine.changeJobStatus(InMemoryComputeStateMachine.java:139)
>  ~[main/:?]
>       at 
> org.apache.ignite.internal.compute.state.InMemoryComputeStateMachine.cancelingJob(InMemoryComputeStateMachine.java:116)
>  ~[main/:?]
>       at 
> org.apache.ignite.internal.compute.queue.QueueExecutionImpl.cancel(QueueExecutionImpl.java:94)
>  ~[main/:?]
>       at 
> org.apache.ignite.internal.compute.executor.JobExecutionInternal.cancel(JobExecutionInternal.java:68)
>  ~[main/:?]
>       at 
> java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:680)
>  ~[?:?]
>       at 
> java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658)
>  ~[?:?]
>       at 
> java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2100)
>  ~[?:?]
>       at 
> org.apache.ignite.internal.compute.DelegatingJobExecution.cancelAsync(DelegatingJobExecution.java:52)
>  ~[main/:?]
>       at 
> org.apache.ignite.internal.compute.ExecutionManager.cancelAsync(ExecutionManager.java:148)
>  ~[main/:?]
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to