US07-04: Prove Concurrency and Crash Recovery (#86)
This commit was merged in pull request #86.
This commit is contained in:
@@ -16,6 +16,7 @@ from collections.abc import Mapping, Sequence
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from photo_pipeline.faults import JOB_ITEM_DONE, maybe_fault
|
||||
from photo_pipeline.jobs.handlers import REGISTRY, Cancelled, Handler, JobContext
|
||||
from photo_pipeline.models import JobItem
|
||||
from photo_pipeline.services.jobs import ItemState, JobConflict, JobService, JobState
|
||||
@@ -86,6 +87,9 @@ class Worker:
|
||||
)
|
||||
else:
|
||||
self.service.set_item(job_id, item_key, ItemState.SUCCEEDED, fencing_token=token)
|
||||
# One item is durably done, the job outcome is not: the control point
|
||||
# for a crash mid-batch (US07-04). Recovery must not re-run this item.
|
||||
maybe_fault(JOB_ITEM_DONE)
|
||||
self.service.heartbeat(job_id, self.worker_id, lease_seconds=self.lease_seconds)
|
||||
|
||||
self._finalize(job_id, token, cancelled=cancelled, any_failed=any_failed)
|
||||
|
||||
Reference in New Issue
Block a user