Skip to content

HARMONY-2016: Fix race condition in work reaper.#708

Merged
ygliuvt merged 1 commit intomainfrom
harmony-2016
Mar 4, 2025
Merged

HARMONY-2016: Fix race condition in work reaper.#708
ygliuvt merged 1 commit intomainfrom
harmony-2016

Conversation

@ygliuvt
Copy link
Copy Markdown
Member

@ygliuvt ygliuvt commented Mar 4, 2025

Jira Issue ID

HARMONY-2016

Description

I think the issue is caused by the race condition between old work items cleanup and old workflow steps cleanup. Currently, work reaper uses the current time minus the reapableWorkAgeMinutes configuration value to find and cleanup old work items and old workflow steps, but because it takes time to run old work items cleanup, by the time it gets to workflow steps cleanup, there might be more work items that are eligible for cleanup based on the current time, thus causes the error documented in this ticket.

The fix is to pre-calculate the cutoff time before executing the work items cleanup and the workflow steps cleanup to avoid the race condition.

Local Test Steps

npm run test

PR Acceptance Checklist

  • Acceptance criteria met
  • Tests added/updated (if needed) and passing
  • Documentation updated (if needed)
  • Harmony in a Box tested (if changes made to microservices or new dependencies added)

Copy link
Copy Markdown
Contributor

@indiejames indiejames left a comment

Choose a reason for hiding this comment

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

Tested locally, verified that work-items and steps are deleted

Copy link
Copy Markdown
Contributor

@chris-durbin chris-durbin left a comment

Choose a reason for hiding this comment

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

Good catch.

@ygliuvt ygliuvt merged commit 11df0f5 into main Mar 4, 2025
5 checks passed
@ygliuvt ygliuvt deleted the harmony-2016 branch March 4, 2025 22:48
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