You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: make task identifiers unique in the database #248
The only unique index of the tasks collection (db.dbs.taskStore.collections.tasks.indexes in pro_tes/config.yaml) is on task_id and worker_id, sparse. Task documents store their identifier as task.id, not task_id, and worker_id is a new UUID for each task, so the index never rejects a task identifier that is already used: the DuplicateKeyError retry in TaskRuns._write_doc_to_db() is dead code.
Since #215, tasks are owned per user, and a repeated identifier would give access to the task of someone else. The PR for #215 makes the controller skip identifiers of stored tasks and identifiers with owner roles, and grants the owner before the task is stored, so only two concurrent requests drawing the same identifier at the same moment could still collide (about 1 in 2.2e9 per pair). A unique index closes that gap and makes the check atomic.
How?
Replace the index with a unique index on task.id (not sparse), and, if useful, one on worker_id.
Upgrading notes: index creation fails if stored tasks share an identifier; how to find and resolve duplicates (db.tasks.aggregate([{ $group: { _id: "$task.id", n: { $sum: 1 } } }, { $match: { n: { $gt: 1 } } }])).
Test with the real MongoDB job that a duplicate task.id is rejected and retried.
Activity