Skip to content

Commit 3018b8f

Browse files
committed
Add (none)->ignore transition, simplify reserve description
- ignore() can be called on keys not yet in jobs table - Reserve is done via update1() per key, client provides pid/host/connection_id - Removed specific SQL query from spec
1 parent 7c22b6d commit 3018b8f

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

docs/src/design/autopopulate-2.0-spec.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ FilteredImage.jobs.refresh() # Refresh job queue
141141
```mermaid
142142
stateDiagram-v2
143143
[*] --> pending : refresh()
144+
[*] --> ignore : ignore()
144145
pending --> reserved : reserve()
145146
reserved --> [*] : complete()\n[if not keeping completed]
146147
reserved --> success : complete()\n[if keeping completed]
@@ -152,6 +153,7 @@ stateDiagram-v2
152153

153154
**Transition methods:**
154155
- `refresh()` — Adds new jobs as `pending` (from `key_source - target - jobs`)
156+
- `ignore()` — Marks a key as `ignore` (can be called on keys not yet in jobs table)
155157
- `reserve()` — Marks a pending job as `reserved` before calling `make()`
156158
- `complete()` — Marks reserved job as `success`, or deletes it (based on `jobs.keep_completed` setting)
157159
- `error()` — Marks reserved job as `error` with message and stack trace
@@ -452,21 +454,7 @@ The jobs table is created with the appropriate primary key structure matching th
452454

453455
### Conflict Resolution
454456

455-
Job reservation does **not** use transaction-level locking for simplicity and performance. Instead, conflicts are resolved at the `make()` transaction level:
456-
457-
```python
458-
# Simple reservation (no locking)
459-
UPDATE `_my_table__jobs`
460-
SET status = 'reserved',
461-
reserved_time = NOW(),
462-
user = CURRENT_USER(),
463-
host = @@hostname,
464-
pid = CONNECTION_ID()
465-
WHERE status = 'pending'
466-
AND scheduled_time <= NOW()
467-
ORDER BY priority DESC, scheduled_time ASC
468-
LIMIT 1;
469-
```
457+
Job reservation is performed via `update1()` for each key individually before calling `make()`. The client provides its own `pid`, `host`, and `connection_id` information. No transaction-level locking is used.
470458

471459
**Conflict scenario** (rare):
472460
1. Two workers reserve the same job nearly simultaneously

0 commit comments

Comments
 (0)