FINERACT-1659: Add optimistic lock to savings interest posting batch …#5550
FINERACT-1659: Add optimistic lock to savings interest posting batch …#5550nickus wants to merge 1 commit intoapache:developfrom
Conversation
bb51c92 to
a5db3fe
Compare
|
@nickus Please fix the failing checks! |
…UPDATE Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@adamsaghy done |
adamsaghy
left a comment
There was a problem hiding this comment.
@nickus I dont think this is correct approach... based on this PR you are not ensuring optimistic locking at all for batch updates: if a version is mismatched it must be rolled back and throw an error, i dont see any rollback mechanism at place... all updates that are sent are final....
|
Hi @adamsaghy, ConcurrentModificationException thrown on version mismatch instead of silent skip Thank you for the clear feedback! |
|
@nickus Are you still working on this ticket? as @awaneetdecoder also working on same ticket. |
|
Hi @Aman-Mittal sorry, I do not have much free time currently to continue this PR so please feel free to continue. I will close it |
…UPDATE
The root cause of duplicate interest postings was fixed in FINERACT-2394 (commit 5281be4), which removed a race condition where both the main thread and a fetchData callable concurrently populated a non-thread-safe ArrayDeque in PostInterestForSavingTasklet.
This commit adds defense-in-depth by wiring the existing @Version column into the raw JDBC batch UPDATE in SavingsSchedularInterestPoster, which bypasses JPA's optimistic lock. The batch UPDATE now includes AND version=? in its WHERE clause and version = version + 1 in SET. If a concurrent modification is detected (updateCounts[i] == 0), the account is skipped and logged rather than double-posted.
Changes:
Description
Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.