Skip to content

FINERACT-1659: Add optimistic lock to savings interest posting batch …#5550

Open
nickus wants to merge 1 commit intoapache:developfrom
nickus:FINERACT-1659
Open

FINERACT-1659: Add optimistic lock to savings interest posting batch …#5550
nickus wants to merge 1 commit intoapache:developfrom
nickus:FINERACT-1659

Conversation

@nickus
Copy link
Contributor

@nickus nickus commented Feb 26, 2026

…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:

  • SavingsAccountData: add transient version field
  • SavingsAccountReadPlatformServiceImpl: select sa.version and extract it in the ResultSetExtractor
  • SavingsSchedularInterestPoster: add version check to batch UPDATE, skip accounts with version mismatch, filter downstream operations
  • New integration test: testPostInterestJobRunTwiceSameDayNoDuplicate

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!

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our coding conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.

Your assigned reviewer(s) will follow our guidelines for code reviews.

@nickus nickus force-pushed the FINERACT-1659 branch 3 times, most recently from 59ed016 to bb51c92 Compare February 26, 2026 22:18
…UPDATE

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant