feat(phase-5): on-prem sync poll hardening + stale job reclaim
Harden the Hub-side polling protocol for on-prem TapTrack agents: - sync/poll: accept job_failed_ids (retry/fail on-prem delivery failures) - sync/poll: deduct credits + write ledger when on-prem reports sent jobs - sync/poll: return feature_flags (tier-based) + suspended flag in config - sync/poll: skip job dispatch for suspended/expired schools - sms_jobs: add delivered_via (pull|push) + processing_started_at columns - tasks/sms: new sms.reclaim_stale_jobs task resets processing→pending if on-prem goes offline (jobs stuck >5 min), enabling Celery push fallback - tasks/sms: tag Celery-sent jobs as delivered_via='push' - worker: schedule reclaim_stale_jobs every 5 minutes - migration: 001_phase5 adds delivered_via + processing_started_at to sms_jobs
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""phase5: add delivered_via and processing_started_at to sms_jobs
|
||||
|
||||
Revision ID: 001_phase5
|
||||
Revises:
|
||||
Create Date: 2026-03-16
|
||||
|
||||
Adds two columns to sms_jobs to support the on-prem polling protocol:
|
||||
- delivered_via: tracks whether the job was sent via the on-prem pull agent ("pull")
|
||||
or directly via the Hub's Celery push path ("push")
|
||||
- processing_started_at: timestamp when the job was marked `processing` (dispatched to on-prem).
|
||||
Used by sms.reclaim_stale_jobs to detect and reclaim stuck jobs.
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "001_phase5"
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
"sms_jobs",
|
||||
sa.Column("delivered_via", sa.String(10), nullable=True),
|
||||
)
|
||||
op.add_column(
|
||||
"sms_jobs",
|
||||
sa.Column("processing_started_at", sa.DateTime(timezone=True), nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("sms_jobs", "processing_started_at")
|
||||
op.drop_column("sms_jobs", "delivered_via")
|
||||
Reference in New Issue
Block a user