siva-sai-udaygiri opened a new pull request, #5135:
URL: https://github.com/apache/fineract/pull/5135
## JIRA
FINERACT-1086
## What
Acquire a DB write lock on `Loan` to serialize concurrent writers and avoid
`JpaOptimisticLockingFailureException`.
## How
- In `LoanAccountDomainServiceJpa#makeRefund(...)`, immediately after
assembling the loan, call:
`entityManager.lock(loan, LockModeType.PESSIMISTIC_WRITE);`
- Leave existing `loanRepositoryWrapper.saveAndFlush(loan)` unchanged.
## Why
Optimistic locking was tripping when two requests updated the same Loan at
once. A `PESSIMISTIC_WRITE` lock ensures only one writer proceeds at a time.
## Notes
- Local Windows build hit Spotless/line-ending issues. I will run `./gradlew
spotlessApply` in Linux (WSL/Codespaces) and push formatting updates shortly.
- Follow-up plan: add an integration test that performs two concurrent
updates on the same Loan and asserts no optimistic-locking failure.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]