Skip to content

Enforce one active task lock per user; lock bundles via bundledTasks - #1261

Draft
CollinBeczak wants to merge 6 commits into
mainfrom
collin/one-lock-per-user-bundling
Draft

Enforce one active task lock per user; lock bundles via bundledTasks#1261
CollinBeczak wants to merge 6 commits into
mainfrom
collin/one-lock-per-user-bundling

Conversation

@CollinBeczak

Copy link
Copy Markdown
Contributor

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.

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
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.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate FailedQuality Gate failed

Failed conditions
10.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for freeto 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.

1 participant

@CollinBeczak