Skip to content

[stable34] fix(taskprocessing): claim tasks atomically so parallel workers don't duplicate#61367

Open
backportbot[bot] wants to merge 6 commits into
stable34from
backport/61053/stable34
Open

[stable34] fix(taskprocessing): claim tasks atomically so parallel workers don't duplicate#61367
backportbot[bot] wants to merge 6 commits into
stable34from
backport/61053/stable34

Conversation

@backportbot

@backportbot backportbot Bot commented Jun 17, 2026

Copy link
Copy Markdown

Backport of PR #61053

@backportbot backportbot Bot requested a review from a team as a code owner June 17, 2026 08:42
@backportbot backportbot Bot requested review from ArtificialOwl, benjaminfrueh, icewind1991, leftybournes, marcelklehr, oleksandr-nc and salmart-dev and removed request for a team June 17, 2026 08:42
@backportbot backportbot Bot added bug 3. to review Waiting for reviews AI assisted community pull requests from community labels Jun 17, 2026
@backportbot backportbot Bot added this to the Nextcloud 34.0.1 milestone Jun 17, 2026
@AndyScherzinger AndyScherzinger force-pushed the backport/61053/stable34 branch from 4d4e119 to 0e8ad02 Compare June 17, 2026 13:03
bygadd and others added 6 commits June 17, 2026 19:00
…ite index

Replace the worker retry/ignore-list claim-loop with a single atomic
SELECT ... FOR UPDATE SKIP LOCKED claim (SQLite bounded-retry fallback),
preserving the no-duplicate guarantee while removing the thundering-herd
contention that throttled backlog draining. Add a (status,type,last_updated)
index via the table-creating migration + db:add-missing-indices listener.

Signed-off-by: Yoan Bozhilov <bygadd@gmail.com>
Assisted-by: Claude Code:claude-opus-4-8
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
…Oracle fallback

Address review feedback (@marcelklehr, Copilot):
- lockTask claims only SCHEDULED tasks (was status != RUNNING) and stamps
  started_at in the same atomic UPDATE, so a finished task cannot be re-claimed
  and the external-provider claim path records started_at as well.
- claimWithBoundedRetry re-reads after lockTask instead of a follow-up UPDATE.
- Oracle joins SQLite on the bounded-retry fallback: Oracle cannot combine a
  row-limiting clause with FOR UPDATE (ORA-02014), which failed the claim tests
  on Oracle CI.
- Reword the worker docblock/comments to "prefer oldest available" (parallel
  SKIP LOCKED does not guarantee a strict global order).
- Add a regression test that lockTask does not resurrect a finished task.

Signed-off-by: Yoan Bozhilov <bygadd@gmail.com>
Assisted-by: Claude Code:claude-opus-4-8
Per review feedback: note in the lockTask docblock that the guard changed from
`status != RUNNING` to `status = SCHEDULED`, and that callers must now treat a
0 return as "the task is no longer claimable" rather than assuming success.

Signed-off-by: Yoan Bozhilov <bygadd@gmail.com>
Assisted-by: Claude Code:claude-opus-4-8
The new public IManager::claimNextScheduledTask lands in master (35.0.0),
not 34.0.0. Addresses review feedback.

Signed-off-by: Yoan Bozhilov <bygadd@gmail.com>
Assisted-by: Claude Code:claude-opus-4-8
@AndyScherzinger AndyScherzinger force-pushed the backport/61053/stable34 branch from 0e8ad02 to 86b4dc6 Compare June 17, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted bug community pull requests from community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants