Pull pipeline/ from boilerplate a1c6f0d: a dedup key is looked up and inserted in one transaction
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
471ace703c
commit
2e4624cbc4
3 files changed
+222
-51
No files matched your search
@@ -106,6 +106,8 @@ A **cancel** and a **failure** are the same thing here: both travel to the `afte
|
||||
|
||||
**One job of this kind queued or running at a time.** Two tabs pressing Fetch is one pull, and the second caller is handed the job already going rather than an error, because what they asked for is that the work be under way and it is. Enforced by a partial unique index over the unfinished states, so it holds across every tab, every client and every process at once — not by a flag in whichever browser happened to ask.
|
||||
|
||||
**A live job that finishes during an enqueue is not an error.** `Jobs.enqueue` looks the key up and inserts in one `BEGIN IMMEDIATE` transaction, so a worker finishing the live job lands either before it, and a new job is queued, or after it, and the caller is handed the live one. The earlier version inserted first and looked the job up only after the index refused, and a finish between those two statements surfaced as `IntegrityError: UNIQUE constraint failed: jobs.dedup_key`. The write lock is waited for under the connection's 30-second busy timeout, as every other write on the file is.
|
||||
|
||||
**Off unless a job says otherwise.** A sweep that forgets to say `solo=True` runs twice and wastes a minute. A batch kind that forgets to say `solo=False` has seven of its eight batches quietly handed the first one, and the work simply never happens. The default belongs on the side that fails loudly.
|
||||
|
||||
A job that names `depends_on` never dedups, whatever it declared, since the whole point of a batch is that there are several.
|
||||
|
||||
Reference in new issue
Block a user