feat(core): require TransactionRunner in OutboxScheduler/OutboxPurger (breaking)#54
Open
endrju19 wants to merge 1 commit into
Open
feat(core): require TransactionRunner in OutboxScheduler/OutboxPurger (breaking)#54endrju19 wants to merge 1 commit into
endrju19 wants to merge 1 commit into
Conversation
… (breaking) Drop the nullable default and the silent non-transactional fallback in tick(). Under JDBC auto-commit, FOR UPDATE SKIP LOCKED releases its row lock at the end of the claim SELECT and concurrent processor instances deliver the same entry multiple times. Make the invariant explicit at the type level in okapi-core, complementing #49's adapter-layer fix. Closes #51
4 tasks
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.
Summary
Moves the "claim+deliver runs in a transaction" invariant down into
okapi-core, where it belongs.OutboxSchedulerandOutboxPurgernow require a non-nullTransactionRunnerconstructor parameter; the nullable default and the silent non-transactional fallback intick()are gone.Under JDBC auto-commit,
FOR UPDATE SKIP LOCKEDreleases its row lock at the end of the claimSELECT. Concurrent processor instances then see overlapping result sets and silently deliver the same entry multiple times — no log, no exception, no metric. This PR removes that footgun from the core API. Companion to #49, which closed the same hole at the Spring Boot autoconfig layer; this PR completes the story for non-Spring consumers (Ktor, manual Spring wiring, plain Java/Kotlin).Breaking change — pre-1.0, permitted by the project's stated versioning policy.
Changes
OutboxSchedulerandOutboxPurger:transactionRunner: TransactionRunner? = null→transactionRunner: TransactionRunner(required); drop the?:fallback intick().@JvmOverloadskept (still useful for remaining default paramsconfig/clock).OutboxSchedulerdocuments theFOR UPDATE SKIP LOCKEDrationale — the why is non-obvious from the signature alone and would otherwise tempt a future reader to "simplify" back to nullable.noOpTransactionRunner()helper; deleted"tick runs without transactionRunner"(exercised the removed null-fallback); added new test"transactionRunner wraps each batch delete"on the purger — asserts the runner is invoked per batch, not just present (closes a behavioral gap the type system cannot enforce; analogous to the existing scheduler test)."transactionRunner wraps tick when provided"→"transactionRunner wraps tick"(always provided now).CHANGELOG.md: new### Changed (BREAKING)entry under[Unreleased]. Migration example uses anonymous-object syntax, not lambda —TransactionRunneris intentionally a plaininterface, notfun interface, because Kotlin forbids SAM conversion on generic abstract methods.What this does NOT change
TransactionRunnerafter feat: require TransactionRunner in okapi-spring-boot autoconfig (KOJAK-67) #49; no further changes needed.TransactionRunnerinterface itself — unchanged.SpringTransactionRunner,ExposedTransactionRunner).OutboxPurger.tick()was identified during review and deferred to a separate follow-up.Test plan
./gradlew :okapi-core:test— green./gradlew :okapi-spring-boot:test— green (adapter still happy)./gradlew ktlintCheck— clean./gradlew build— full build greenOutboxScheduler(/OutboxPurger(construction site in the repo now passes an explicittransactionRunner.Closes #51.