Keeping External Work Out of a Long Transaction
A short transaction can record a decision and allow slow external work to occur afterward, provided the intended workflow accounts for failures.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a generated thumbnail
Commit the article record and pending thumbnail work. A worker can generate the image after committing rather than hold a database transaction while processing it. Work queues describe how to retain the task.
Handle the cases deliberately
If the thumbnail must exist before public display, express that dependency in publication state. Recording an outbox intent illustrates reliable handoff.[1]
Commit a claim before performing slow external work
A worker reserves one job in a short transaction and records ownership. It then performs the activity outside that transaction and records completion later. The claim needs an expiry or recovery policy if workers can disappear. See claiming shared database work.
Short transaction: claim job 8 and commit
External processing occurs separately
New transaction records outcome for the same claim
Test a worker that stops after claiming
A second worker should follow the documented reclaim rule. A late first worker should not overwrite the current owner's result if leases can expire. Test errors, retries and ownership changes.