Skip to content

[Fix #1354] ForExecutor was not properly implemented for multithread#1369

Closed
fjtirado wants to merge 1 commit intoserverlessworkflow:mainfrom
fjtirado:Fix_1363
Closed

[Fix #1354] ForExecutor was not properly implemented for multithread#1369
fjtirado wants to merge 1 commit intoserverlessworkflow:mainfrom
fjtirado:Fix_1363

Conversation

@fjtirado
Copy link
Copy Markdown
Collaborator

@fjtirado fjtirado commented May 5, 2026

Fix #1354

Copilot AI review requested due to automatic review settings May 5, 2026 10:23
@fjtirado fjtirado force-pushed the Fix_1363 branch 2 times, most recently from e30fae0 to 5f1e7df Compare May 5, 2026 10:28
@fjtirado fjtirado changed the title [Fix #1363] ForExecutor was not properly implemented for multithread [Fix #1354] ForExecutor was not properly implemented for multithread May 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a concurrency/correctness issue in the ForExecutor loop execution, ensuring loop variables are set per-iteration at execution time (rather than being overwritten while building the future chain), and updates an existing regression test to better reproduce timing-sensitive behavior.

Changes:

  • Refactor ForExecutor to execute the loop via a per-iteration future chain (instead of pre-building the whole chain in a tight while loop).
  • Add a lagged in-memory event broker for tests to introduce a small delay after publishing.
  • Update ForEachFuncTest to use the lagged broker to reproduce the bug scenario more reliably.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
impl/core/src/main/java/io/serverlessworkflow/impl/executors/ForExecutor.java Refactors for-loop execution to avoid loop-variable overwrites across async stages.
experimental/test/src/test/java/io/serverlessworkflow/fluent/test/LaggedInMemoryEvent.java Adds a test-only event broker that delays after publish to amplify timing issues.
experimental/test/src/test/java/io/serverlessworkflow/fluent/test/ForEachFuncTest.java Switches the regression test to use the lagged broker.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/executors/ForExecutor.java Outdated
Copilot AI review requested due to automatic review settings May 5, 2026 10:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…d for multithread

Signed-off-by: fjtirado <ftirados@redhat.com>
Copilot AI review requested due to automatic review settings May 5, 2026 10:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ricardozanini
Copy link
Copy Markdown
Member

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.

ForExecutor race condition: shared TaskContext causes wrong items to be processed in async loops

3 participants