galovics commented on PR #6640:
URL: https://github.com/apache/fineract/pull/6640#issuecomment-6191810784

   You are right, and my description was wrong. Thanks for catching it.
   
   Verified against the code:
   - `AbstractJob.execute` (Spring Batch 6.0.4, checked in the bytecode) does 
`setEndTime` -> `jobRepository.update(execution)` -> `afterJob`. The final 
status is persisted before the listener runs.
   - The catch-up days run one after another through `jobStarter.run` -> 
`jobOperator.start` (synchronous), so between two days no row is STARTED and 
`isCatchUpRunning()` is false.
   - Net effect: an N-day catch-up unlocked the hard-locked loans and queued 
another catch-up at the end of every day. A loan that keeps failing would make 
that a loop, as you describe; I reproduced the per-day repeat below but did not 
run the unbounded loop.
   
   Reproduced before the fix: a test that runs the listener for 3 catch-up days 
with `isCatchUpRunning()` false failed with `executeLoanCOBCatchUp()` invoked 3 
times (once per day).
   
   Fix (as you suggested): `afterJob` returns early when the run's execution 
context has `IS_CATCH_UP=true`. I added 
`CatchUpFlagResolver.resolve(JobExecution)` and the existing `StepExecution` 
variant delegates to it, so the listener and the partitioner read the same 
value. A regular run has no such value (false) and still starts the catch-up.
   
   Tests: `startsNothingAtTheEndOfACatchUpRun` (3 days, `isCatchUpRunning()` 
false, nothing started and nothing unlocked) and 
`startsCatchUpAfterARegularRunWhoseCatchUpFlagIsFalse`, both for Loan COB and 
Working Capital COB. `*cob*`, `*jobs*`, spotless and checkstyle pass.
   
   Docs: batch-jobs.adoc, the listener javadoc and the commit message no longer 
claim the row is still STARTED.
   
   Also rebased onto current develop; the Liquibase changelog part is now 
`0259_...` because `0258` was taken.
   


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