adamsaghy commented on code in PR #5671:
URL: https://github.com/apache/fineract/pull/5671#discussion_r3028430376
##########
fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularInterestPoster.java:
##########
@@ -213,8 +213,24 @@ private void batchUpdate(final List<SavingsAccountData>
savingsAccountDataList)
savingsAccountData.setUpdatedTransactions(savingsAccountTransactionDataList);
}
- if (transRefNo.size() > 0) {
- this.jdbcTemplate.batchUpdate(queryForSavingsUpdate,
paramsForSavingsSummary);
+ if (!transRefNo.isEmpty()) {
+ int[] updateCounts =
this.jdbcTemplate.batchUpdate(queryForSavingsUpdate, paramsForSavingsSummary);
+
+ Set<Long> skippedAccountIds = new HashSet<>();
+ for (int i = 0; i < updateCounts.length; i++) {
+ if (updateCounts[i] == 0) {
+ Long accountId = savingsAccountDataList.get(i).getId();
+ skippedAccountIds.add(accountId);
+ log.warn("Optimistic lock failure for savings account
id={} — concurrent modification detected."
+ + " Rolling back. Will retry on next run.",
accountId);
+ }
+ }
+
+ if (!skippedAccountIds.isEmpty()) {
Review Comment:
I am wondering why to throw optimistic lock exception if we havent updated
anything... i mean we calculated something, but it was not updated... so there
is no duplicate posting anyway, no?
--
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]