Skip to content

FINERACT-2602: Remove orphaned COB locks after job completion#5858

Open
oleksii-novikov-onix wants to merge 1 commit into
apache:developfrom
openMF:FINERACT-2602/removed-stuck-loans-from-lock-table
Open

FINERACT-2602: Remove orphaned COB locks after job completion#5858
oleksii-novikov-onix wants to merge 1 commit into
apache:developfrom
openMF:FINERACT-2602/removed-stuck-loans-from-lock-table

Conversation

@oleksii-novikov-onix
Copy link
Copy Markdown
Contributor

Description

Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our coding conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.

Your assigned reviewer(s) will follow our guidelines for code reviews.

@oleksii-novikov-onix oleksii-novikov-onix force-pushed the FINERACT-2602/removed-stuck-loans-from-lock-table branch from 49aae2d to 502ab61 Compare May 19, 2026 10:06

private String error;
private LocalDate cobBusinessDate;
private Boolean nullCobBusinessDate;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this field for?

public RepeatStatus execute(@NonNull final StepContribution contribution, @NonNull final ChunkContext chunkContext) throws Exception {
final int removedCount = accountLockService.removeOrphanedLocksForProcessedAccounts();
if (removedCount > 0) {
log.info("Unlocked {} account(s) that completed COB processing but remained locked", removedCount);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use debug level logging please...

}

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
Copy link
Copy Markdown
Contributor

@adamsaghy adamsaghy May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to start a new transaction for this?

@oleksii-novikov-onix oleksii-novikov-onix force-pushed the FINERACT-2602/removed-stuck-loans-from-lock-table branch from 502ab61 to 57ed03e Compare May 19, 2026 13:40
@AshharAhmadKhan
Copy link
Copy Markdown
Contributor

@oleksii-novikov-onix @adamsaghy

The approach here is solid. A few thoughts on the open review comments:

@Transactional(propagation = REQUIRES_NEW) on removeOrphanedLocksForProcessedAccounts() isn't needed. Spring Batch already wraps each tasklet in its own transaction and all prior steps have committed by the time this runs, so default REQUIRED is fine.

nullCobBusinessDate in LockRequest is there so tests can place a lock with a null cob date through the API, which is needed to cover the lock_placed_on_cob_business_date IS NOT NULL filter in the delete query. Without it there's no way to test that edge case.

Also agree on log.info, log.debug makes more sense since this runs on every COB execution.

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.

3 participants