Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api-headless-cms-tasks): race conditions while emptying the entries #4144

Merged
merged 6 commits into from
May 22, 2024

Conversation

leopuleo
Copy link
Contributor

Changes

With this PR, we aim to:

  • refactor CreateDeleteEntriesTasks class for improved readability and efficiency;
  • remove redundant variables;
  • simplify loop conditions;
  • ensure proper handling of edge cases and pagination;
  • uniform messages returned by the task execution.

TaskCache and TaskTrigger

The main change introduced by this fix is the use of a cache to store all the subtasks created while looping through the entries that need to be deleted.

Previously, when dealing with a large number of entries, the child tasks would start executing while the main task was still executing. This could cause a race condition and lead to failures when deleting some entries that had already been deleted by other subtasks.

With this pull request, we are now storing inputs for subtasks inside an internal cache and executing them after the main task loop finishes.

How Has This Been Tested?

Manually + Jest

@leopuleo leopuleo added this to the 5.40.0 milestone May 22, 2024
@leopuleo leopuleo requested a review from Pavel910 May 22, 2024 08:56
@leopuleo leopuleo self-assigned this May 22, 2024
@leopuleo leopuleo changed the title fix(api-headless-cms-tasks): fix(api-headless-cms-tasks): race conditions while emptying the entries May 22, 2024
@leopuleo leopuleo merged commit d711547 into next May 22, 2024
91 checks passed
@leopuleo leopuleo deleted the leo/fix/empty-trash-bin branch June 5, 2024 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants