Skip to content

FINERACT-1659: Fix optimistic locking in savings interest posting batch job#5671

Open
awaneetdecoder wants to merge 1 commit intoapache:developfrom
awaneetdecoder:FINERACT-1659-fix-optimistic-lock-savings-batch
Open

FINERACT-1659: Fix optimistic locking in savings interest posting batch job#5671
awaneetdecoder wants to merge 1 commit intoapache:developfrom
awaneetdecoder:FINERACT-1659-fix-optimistic-lock-savings-batch

Conversation

@awaneetdecoder
Copy link
Contributor

Problem

The savings interest posting batch job could post duplicate interest
when two instances ran concurrently. PR #5550 attempted a fix but
adamsaghy correctly identified there was no rollback mechanism —
version mismatch was silently skipped.

Fix

  • SQL uses WHERE id=? AND version=? to detect concurrent modification
  • version = version + 1 increments on each successful update
  • updateCounts[i] == 0 detected as concurrent modification
  • ConcurrentModificationException thrown on version mismatch
  • @transactional on postInterest() rolls back entire batch

Files Changed

  • SavingsAccountData.java — added version field
  • SavingsAccountReadPlatformServiceImpl.java — reads version from DB
  • SavingsSchedularInterestPoster.java — core fix
  • SavingsSchedularInterestPosterTest.java — unit tests
  • SavingsInterestPostingJobIntegrationTest.java — integration tests

Fixes FINERACT-1659
Supersedes PR #5550

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