@TransactionalStep#400
Merged
Merged
Conversation
kraftp
reviewed
May 26, 2026
kraftp
reviewed
May 26, 2026
kraftp
reviewed
May 26, 2026
kraftp
reviewed
May 27, 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.
Adds
transact-spring-txstep-starter, a new Spring Boot auto-configuration module that brings@TransactionalStepto Spring applications.What it does:
@TransactionalStep, a method annotation that marks a Spring-managed method as an idempotent DBOS step. The method body runs inside aREQUIRES_NEWSpring transaction; the return value is written totx_step_outputsatomically with the user's database work. On workflow retry, the recorded output is replayed without re-executing the method body.TransactionalStepAspectintercepts annotated methods and delegates toTransactionalStepFactory, which callsDBOS.runStep()and usesDataSourceUtils.getConnection()to write step output on the same transaction-bound connection.TransactionalStepAutoConfigurationwires up the factory and aspect as Spring beans, auto-configured viaAutoConfiguration.imports.TransactionalStepRegistrarscans the Spring context post-startup and callsfactory.initialize()(createstx_step_outputs) only when annotated methods are found — no DB contact for apps that don't use the annotation.TransactionalStepFactoryauto-detectsJpaTransactionManagerand sets itsdataSourceproperty to bridge JPA transactions toDataSourceUtils.Supported stacks (all covered by integration tests):
JdbcTemplatejdbi3-springtransaction binding)spring-boot-starter-jooq)spring-boot-starter-data-jpa)This PR also fixes previously implemented step factory's handling of concurrent updates. If two executors race to run the same step, both may pass the initial
checkExecutionread before either has committed. Previously, both executors transactions would commit, with the 2ndrecordOutputINSERT being ignored. This has been fixed so the race loser'srecordOutputINSERT intotx_step_outputshits the(workflow_id, step_id)unique constraint. The factory catches the resulting23505violation and converts it to aStepConflictException. The calling code catchesStepConflictException, rolls back the REQUIRES_NEW transaction (discarding the loser's database work), then re-reads tx_step_outputs to return the winner's committed result:The outcome is idempotent from the caller's perspective: both executors return the same winner result, and only the winner's database write is committed.
Also includes minor refactors to
JdbcStepFactory,JdbiStepFactory, andJooqStepFactoryto extract shared SQL intoTxStepSchemahelpers, and expands their test suites.fixes #385