Skip to content

Fix money-batch settlement when requests exceed batch size - #807

Open
yeomin4242 wants to merge 1 commit into
temporalio:mainfrom
yeomin4242:repro/moneybatch-749
Open

yeomin4242 wants to merge 1 commit into
temporalio:mainfrom
yeomin4242:repro/moneybatch-749

Conversation

@yeomin4242

Copy link
Copy Markdown

What was changed

Queue withdrawal requests and select exactly batchSize requests for each money-batch execution, preserving count == batchSize.

After a successful deposit, complete the workflow if no requests remain. Otherwise, continue as new with pending requests and reference IDs to preserve deduplication across executions. Pending requests wait for a full batch before their withdrawals are executed.

Propagate withdrawal failures instead of waiting indefinitely. Update the sample caller and README for the carried batch state.

This change targets new executions and does not preserve replay compatibility with the original implementation.

Why?

When withdrawal signals exceed the batch size, the completed withdrawal count can pass batchSize, leaving the workflow waiting indefinitely. Selecting a fixed batch prevents this while preserving excess requests for the next execution.

Checklist

  1. Closes [Bug] moneybatcher sample race condition? #749

  2. How was this tested:
    Four tests pass, covering normal settlement, excess requests and deduplication across executions, requests received during a deposit, and withdrawal failure propagation. Tested with Java 21 using ./gradlew :core:cleanTest :core:test --tests 'io.temporal.samples.moneybatch.*' :core:spotlessJavaCheck. Spotless and git diff --check also pass.

  3. Any docs updates needed?
    Updated the money-batch README to explain batching, Continue-As-New, and compatibility.

@yeomin4242
yeomin4242 marked this pull request as ready for review October 11, 2026 16:39
@yeomin4242
yeomin4242 requested review from a team, antmendoza and tsurdilo as code owners October 11, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] moneybatcher sample race condition?

1 participant