temporalio / temporalio/samples-java

[Bug] HelloCancellationScope example has different behaviour when running the test vs when running the workflow through the main method

Open
#326 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
258
Forks
189
Avg merge
6d 4h
Merged PRs (30d)
4

Description

What are you really trying to do?

I am trying to understand how cancellation scopes work, and for that I am looking at HelloCancellationScope and HelloDetachedCancellationScope

Describe the bug

I was looking at the code in the HelloCancellationScope class.

If I run the example through the main method, this is the output:

Activity for Oi going to take 23 seconds
Activity for Привет going to take 8 seconds
Activity for Hallo going to take 16 seconds
Activity for Bye going to take 28 seconds
Activity for Hola going to take 11 seconds
Activity for Hello going to take 19 seconds
Activity for Привет completed
Activity for Oi was cancelled. Cleanup is expected to take 2 seconds.
Activity for Hallo was cancelled. Cleanup is expected to take 4 seconds.
Activity for Bye was cancelled. Cleanup is expected to take 1 seconds.
Activity for Hola was cancelled. Cleanup is expected to take 2 seconds.
Activity for Hello was cancelled. Cleanup is expected to take 1 seconds.
Activity for Bye finished cancellation
13:26:44.374 {HelloCancellationScopeWorkflow dd9e08dd-9b26-3f67-a226-396d0fa9c2df} [Activity Executor taskQueue="HelloCancellationScopeTaskQueue", namespace="default": 4] INFO  i.t.i.a.ActivityTaskExecutors$ActivityTaskExecutor - Activity canceled. ActivityId=dd9e08dd-9b26-3f67-a226-396d0fa9c2df, activityType=ComposeGreeting, attempt=1 
Activity for Hello finished cancellation
13:26:44.387 {HelloCancellationScopeWorkflow be5eaced-ee7f-34ee-9e18-1bc0de1bc344} [Activity Executor taskQueue="HelloCancellationScopeTaskQueue", namespace="default": 6] INFO  i.t.i.a.ActivityTaskExecutors$ActivityTaskExecutor - Activity canceled. ActivityId=be5eaced-ee7f-34ee-9e18-1bc0de1bc344, activityType=ComposeGreeting, attempt=1 
Activity for Oi finished cancellation
13:26:45.355 {HelloCancellationScopeWorkflow 42c07d6b-7f8d-3638-b408-6045e5eee15d} [Activity Executor taskQueue="HelloCancellationScopeTaskQueue", namespace="default": 1] INFO  i.t.i.a.ActivityTaskExecutors$ActivityTaskExecutor - Activity canceled. ActivityId=42c07d6b-7f8d-3638-b408-6045e5eee15d, activityType=ComposeGreeting, attempt=1 
Activity for Hola finished cancellation
13:26:45.383 {HelloCancellationScopeWorkflow 7c33e886-500d-3711-8d81-8c0d84d6291e} [Activity Executor taskQueue="HelloCancellationScopeTaskQueue", namespace="default": 5] INFO  i.t.i.a.ActivityTaskExecutors$ActivityTaskExecutor - Activity canceled. ActivityId=7c33e886-500d-3711-8d81-8c0d84d6291e, activityType=ComposeGreeting, attempt=1 
Activity for Hallo finished cancellation
13:26:47.366 {HelloCancellationScopeWorkflow b1ec9997-52bc-3c81-8a4c-2be9f2506e41} [Activity Executor taskQueue="HelloCancellationScopeTaskQueue", namespace="default": 3] INFO  i.t.i.a.ActivityTaskExecutors$ActivityTaskExecutor - Activity canceled. ActivityId=b1ec9997-52bc-3c81-8a4c-2be9f2506e41, activityType=ComposeGreeting, attempt=1 
Привет World!

After the first activity is completed all the remaining activities are cancelled as expected.

If I run the test (HelloCancellationScopeTest), this is the output:

Activity for Hello going to take 9 seconds
Activity for Hola going to take 16 seconds
Activity for Bye going to take 9 seconds
Activity for Hallo going to take 11 seconds
Activity for Привет going to take 8 seconds
Activity for Oi going to take 16 seconds
Activity for Привет completed
Activity for Bye completed
Activity for Hello completed
Activity for Hallo completed
Activity for Hola completed
Activity for Oi completed

After the first activity is completed all the remaining activities are not cancelled.

Minimal Reproduction
Environment/Versions
  • OS and processor: [e.g. M1 Mac, x86 Windows, Linux]
  • Temporal Version: [e.g. 1.14.0?] and/or SDK version
  • Are you using Docker or Kubernetes or building Temporal from source?
Additional context

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare the HelloCancellationScope main method with HelloCancellationScopeTest and reproduce both runs using the example outputs in the issue. Trace how the first completed activity affects the remaining activities, and consider the issue resolved when the test and main execution show the intended cancellation behavior consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.