FINERACT-1659: Prevent duplicate savings interest posting in same period#5357
Open
sidshas03 wants to merge 3 commits intoapache:developfrom
Open
FINERACT-1659: Prevent duplicate savings interest posting in same period#5357sidshas03 wants to merge 3 commits intoapache:developfrom
sidshas03 wants to merge 3 commits intoapache:developfrom
Conversation
…with query filter
adamsaghy
reviewed
Jan 23, 2026
| private boolean backdatedTxnsAllowedTill; | ||
|
|
||
| @Transactional(isolation = Isolation.READ_UNCOMMITTED, rollbackFor = Exception.class) | ||
| @Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class) |
Contributor
There was a problem hiding this comment.
While the SERIALIZABLE here might be better than the READ_UNCOMMITTED, i dont think we are addressing the underlying issue properly.
I would rather recommend a different approach:
- Is it possible to ensure no two
SavingsSchedularInterestPostergot the very same savings account? If we can ensure no two parallel executedpostInterestwork on the very same savings account, i see no reason why would any double posting and we dont need to enforce SERIALIZABLE isolation which usually means strict and heavy locking of the resource which does not help the performance.
Alternative solution:
- Is it possible to introduce constraints which ensure no two interest to be posted on the very same date of the very same savings account? We can even build retry strategy too based on this constraints:
- Read savings account -> post interest -> if fails, refetch the savings account and check again whether interest needed to be posted.
It might go beyond the scope of the original story, but to be frank, this would be the proper way to do it.
TLDR: 1 savings account should be processed by 1 thread entirely and avoid situations where 1 savings account might be processed by many threads.
Contributor
|
Contributor
|
Please review the failing test cases |
f3cfdef to
2600c75
Compare
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.
Description
This PR fixes the duplicate interest posting issue reported in FINERACT-1659, where the Post Interest job could post interest multiple times for the same savings account within the same posting period.
What changed
SavingsSchedularInterestPosterto skip accounts where interest has already been posted for the current period, by comparinginterestPostedTillDatewith the current business date.SERIALIZABLEto prevent duplicate postings caused by race conditions during parallel scheduler runs.Tests
Added two integration tests to validate the behavior:
testPostInterestPreventsDuplicateOnSameDayEnsures running the job twice on the same day results in only one interest posting.
testPostInterestSkipsCurrentPeriodButAllowsNewPeriodEnsures the job skips reposting within the current period, while still allowing postings in a new period.
Expected outcome