temporalio / temporalio/samples-java
[Bug] moneybatcher sample race condition?
Nobody has claimed this yet.
- 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 learn how to do batching using temporal. I found the moneybatch sample and I wanted to make sure that it can handle requests in parallel.
To simulate the behavior, I changed the workflow to withdraw more times than a single batch size as well as added a delay during the deposit call.
What this lead to is that the workflow would continue to run and not complete, it won't even process a single batch.
Describe the bug
This is related to the condition in the workflow:
Workflow.await(() -> count == batchSize);
If count suddenly goes from 0 to a value greater than batchSize, the workflow will continue to run and not complete.
I am new to temporal, so I am not quite sure how to fix this. Is this a bug in the sample or am I doing something wrong?
Minimal Reproduction
Download this branch:
https://github.com/derwasp/samples-java/tree/derwasp/moneybatcher
Either run ./run-moneybatch-demo.sh and observe the logs.
Or run the test TransferWorkflowTest and see the failure.
Environment/Versions
- OS and processor: M4 Mac
- Temporal Version: (CLI version 1.4.1)
- Are you using Docker or Kubernetes or building Temporal from source? Docker
Additional context
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the moneybatch sample under core/src/main/java/io/temporal/samples/moneybatch and run TransferWorkflowTest from the linked reproduction branch. Inspect the Workflow.await condition and the test setup for requests exceeding one batch size. Done means the reproduced workflow completes and processes the expected batches instead of remaining blocked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100