Enforce one active task lock per user; lock bundles via bundledTasks - #1261
Draft
CollinBeczak wants to merge 6 commits into
Draft
Enforce one active task lock per user; lock bundles via bundledTasks#1261CollinBeczak wants to merge 6 commits into
CollinBeczak wants to merge 6 commits into
Conversation
Users could previously hold locks on multiple tasks at once (no constraint on locked.user_id), and bundling either didn't lock tasks at all or locked every member individually. Add a migration that enforces a single active edit lock per user (a partial unique index scoped away from reviewer review-claim locks, which stay independent) and gives locked a bundled_tasks column. Bundling now locks only the primary task and records the other member ids in bundled_tasks instead of locking each task, and all lock/unlock/refresh logic and lock-aware joins (TaskDAL, ChallengeDAL, VirtualChallengeDAL, TaskClusterRepository, TaskRepository, getLockedTasks) resolve a bundle member's lock through its primary. Locking a task or bundle while already holding a different lock now returns 409 with the held lock's details instead of silently succeeding or 500ing.
CollinBeczak
marked this pull request as draft
August 5, 2026 16:05
Task lock/release/refresh now resolve through bundled_tasks so any
member of a bundle correctly maps back to the primary's lock, and
broadcast tasksClaimed/tasksReleased for the whole bundle membership
instead of just the single task - keeping other tabs/sessions in sync.
TaskBundleController broadcasts the same events on bundle create,
update, unbundle, and delete.
Adds PUT /task/:taskId/lockBundle so a client can update the lock's
member coverage while interactively building a bundle (e.g.
lasso-select) without creating a task_bundles row until the bundle is
actually submitted.
Also fixes an anorm placeholder-parsing bug where the empty bundled
lock literal ('{}') was mistaken for a {paramName} token, and relaxes
the lock-conflict check so re-locking a task already covered by the
caller's own bundle doesn't throw.
…on random/nearby task lookup Random/nearby task candidate lookups went through withListLocking/withSingleLocking, which unlocked all of a user's other task locks as a side effect with no conflict check, silently discarding locks held in other tabs/sessions. Route locking through the explicit /start endpoint instead, and broadcast task-released/tasks-released websocket messages when a lock is released via status completion, bundle completion, or lock expiry, so other tabs/sessions learn a task (and its bundle members) were unlocked instead of showing it as locked-by-you indefinitely.
createTaskBundle committed the bundle/task_bundles rows in separate transactions before attempting to lock the primary task, so a LockConflictException there left an orphaned, unlocked bundle with no id the client could reach to retry or clean up. Delete the bundle on that failure instead. Also fixes deleteTaskBundle's lock release to fall back to the first task when no explicit primary was set, matching lockBundleTasks' own fallback.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Users could previously hold locks on multiple tasks at once (no constraint on locked.user_id), and bundling either didn't lock tasks at all or locked every member individually. Add a migration that enforces a single active edit lock per user (a partial unique index scoped away from reviewer review-claim locks, which stay independent) and gives locked a bundled_tasks column. Bundling now locks only the primary task and records the other member ids in bundled_tasks instead of locking each task, and all lock/unlock/refresh logic and lock-aware joins (TaskDAL, ChallengeDAL, VirtualChallengeDAL, TaskClusterRepository, TaskRepository, getLockedTasks) resolve a bundle member's lock through its primary. Locking a task or bundle while already holding a different lock now returns 409 with the held lock's details instead of silently succeeding or 500ing.
This is a work in progress pr and will need to make some decisions on wether we want to branch out into new endpoints for mr4 compatibility or if we want to make mr3 compatible with these new restrictions and data layout.