Implement durable image processing pipeline with outbox and recovery
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from app.job_db import connect_db
|
||||
|
||||
|
||||
logger = logging.getLogger("messenger.faults")
|
||||
|
||||
|
||||
def trip_fault(job_id, stage: str) -> None:
|
||||
with connect_db() as db:
|
||||
row = db.execute(
|
||||
"""
|
||||
UPDATE pipeline_fault_injections
|
||||
SET consumed_at = clock_timestamp()
|
||||
WHERE job_id = %s
|
||||
AND stage = %s
|
||||
AND consumed_at IS NULL
|
||||
RETURNING job_id
|
||||
""",
|
||||
(job_id, stage),
|
||||
).fetchone()
|
||||
|
||||
if row is None:
|
||||
return
|
||||
|
||||
logger.warning(
|
||||
"fault_injection job_id=%s stage=%s exit_code=75",
|
||||
job_id,
|
||||
stage,
|
||||
)
|
||||
os._exit(75)
|
||||
Reference in New Issue
Block a user