[Fix #1247] Adding sync/async implementations#1248
Merged
fjtirado merged 1 commit intoserverlessworkflow:mainfrom Mar 20, 2026
Merged
[Fix #1247] Adding sync/async implementations#1248fjtirado merged 1 commit intoserverlessworkflow:mainfrom
fjtirado merged 1 commit intoserverlessworkflow:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a PersistenceExecutor abstraction to support synchronous and asynchronous persistence execution paths, and wires these into persistence instance writing to address #1247.
Changes:
- Added
PersistenceExecutorinterface plusSyncPersistenceExecutorand async implementations. - Introduced
TransactedPersistenceInstanceWriterto route persistence operations through aPersistenceExecutor. - Updated default persistence handlers/writer to use the new executor model (sync by default, async when configured).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| impl/persistence/api/src/main/java/io/serverlessworkflow/impl/persistence/TransactedPersistenceInstanceWriter.java | Adds a writer base that executes persistence actions via a PersistenceExecutor. |
| impl/persistence/api/src/main/java/io/serverlessworkflow/impl/persistence/SyncPersistenceExecutor.java | Adds a synchronous executor implementation. |
| impl/persistence/api/src/main/java/io/serverlessworkflow/impl/persistence/PersistenceExecutor.java | Defines executor contract with lifecycle hooks for start/delete. |
| impl/persistence/api/src/main/java/io/serverlessworkflow/impl/persistence/DefaultPersistenceInstanceWriter.java | Switches default writer to the new transacted/executor model. |
| impl/persistence/api/src/main/java/io/serverlessworkflow/impl/persistence/DefaultPersistenceInstanceHandlers.java | Wires builder configuration to create sync/async executors. |
| impl/persistence/api/src/main/java/io/serverlessworkflow/impl/persistence/AsyncPersistenceInstanceWriter.java | Refactors prior async writer logic into an async executor implementation. |
| impl/persistence/api/src/main/java/io/serverlessworkflow/impl/persistence/AsyncPersistenceExecutor.java | Adds a concrete async executor that supplies an ExecutorService. |
| impl/persistence/api/src/main/java/io/serverlessworkflow/impl/persistence/AbstractPersistenceInstanceWriter.java | Splits “start” and “complete” hooks from generic transaction execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...stence/api/src/main/java/io/serverlessworkflow/impl/persistence/SyncPersistenceExecutor.java
Outdated
Show resolved
Hide resolved
Signed-off-by: fjtirado <ftirados@redhat.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
impl/persistence/api/src/main/java/io/serverlessworkflow/impl/persistence/AbstractAsyncPersistenceExecutor.java:61
deleteInstancecan skip the provided delete runnable entirely when there is no pending future for the instance (it returns a completed future without runningrunnable). This meanscompleted/failed/abortedmay not remove the process instance for workflows that don't enqueue any async writes afterstartInstance(which is currently synchronous), leaving stale state. Also, canceling the in-flight future can interrupt/cancel queued persistence writes and causes the returned future to complete exceptionally (CancellationException), which defeats the goal of ensuring persistence completes before instance deletion. Consider always executing the runnable, and when a prior future exists, chain the runnable to run after that future settles (without canceling it), returning a future that represents the delete runnable's completion.
impl/persistence/api/src/main/java/io/serverlessworkflow/impl/persistence/AbstractAsyncPersistenceExecutor.java:75close()waits on each future viafuture.get(), but it doesn't handleCancellationException. With the currentdeleteInstanceimplementation canceling futures,close()can throw at runtime and skip draining/clearing remaining entries. Either avoid canceling the futures indeleteInstance, or handleCancellationExceptionhere similarly toExecutionExceptionto keep shutdown robust.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ricardozanini
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #1247