fix(db): use TransactionTemplate for batched spot cleanup#295
Merged
arunderwood merged 2 commits intomainfrom Jan 6, 2026
Merged
fix(db): use TransactionTemplate for batched spot cleanup#295arunderwood merged 2 commits intomainfrom
arunderwood merged 2 commits intomainfrom
Conversation
The previous @transactional approach didn't work because deleteBatch() is called internally from executeCleanup() in the same class, bypassing Spring's proxy-based AOP (self-invocation problem). Switch to programmatic TransactionTemplate to ensure each batch commits in its own transaction, preventing long-running transactions when deleting millions of expired spots.
2efa7c1 to
cd49860
Compare
Cover the null branch in SpotCleanupService.deleteBatch() to satisfy delta coverage requirements (80% branch coverage). The null case occurs when TransactionTemplate.execute() returns null during a rollback.
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
@TransactionalondeleteBatch()was ignored when called fromexecuteCleanup()in the same classTransactionTemplateto ensure each 100k-row batch commits independentlyBackground
The previous PR (#294) added batched deletion but used
@Transactionalannotation which doesn't work for internal method calls (Spring's proxy-based AOP limitation). After deployment, the cleanup task continued failing (44 consecutive failures).Test plan
spot-cleanuptask succeeds (checkconsecutive_failures = 0inscheduled_taskstable)