awaneetdecoder commented on code in PR #5671:
URL: https://github.com/apache/fineract/pull/5671#discussion_r3055362546


##########
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:
   @adamsaghy The CI has completed — 42 checks passing, 1 failing. The failing 
test is 
verifyEarlyLateRepaymentOnProgressiveLoanNextInstallmentAllocationRepayLessThenEmi
 in LoanInterestRecalculationCOBTest, failing with HTTP 403 due to a duplicate 
loan product short name 01BB in the test environment. This is a pre-existing 
Loan domain test unrelated to this PR's savings changes.



-- 
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]

Reply via email to