Skip to content

fix(taskprocessing): claim tasks atomically so parallel workers don't duplicate#61053

Open
bygadd wants to merge 2 commits into
nextcloud:masterfrom
bygadd:fix/taskprocessing-worker-atomic-claim
Open

fix(taskprocessing): claim tasks atomically so parallel workers don't duplicate#61053
bygadd wants to merge 2 commits into
nextcloud:masterfrom
bygadd:fix/taskprocessing-worker-atomic-claim

Conversation

@bygadd
Copy link
Copy Markdown

@bygadd bygadd commented Jun 6, 2026

Fixes #61052

occ taskprocessing:worker claimed tasks non-atomically, so multiple parallel workers processed the same task (both concurrently and sequentially), wasting worker capacity and multiplying provider/LLM calls.

This PR:

  1. WorkerCommand::processNextTask() now calls lockTask() after getNextScheduledTask() and skips + re-fetches (via an ignore list) when the lock fails — mirroring TaskProcessingApiController.
  2. TaskMapper::lockTask() now guards with status = STATUS_SCHEDULED instead of status != STATUS_RUNNING, so an already-completed task cannot be re-claimed.

Verified on 33.0.5 with 8 concurrent workers: every task processed exactly once (0 duplicates), vs 4× before.

Signed-off-by: bygadd bygadd@gmail.com

@bygadd bygadd requested a review from a team as a code owner June 6, 2026 16:12
@bygadd bygadd requested review from ArtificialOwl, artonge, leftybournes and salmart-dev and removed request for a team June 6, 2026 16:12
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.

taskprocessing:worker does not atomically claim tasks → duplicate processing with multiple workers

1 participant