FAILED/OCR FAIL rows never disappear on their own, so counting all of them
made the alarm fire every 5 minutes forever. Only stuck entries and
failures from the last 24 h trigger it now; older ones stay in the DB for
tools/gundi_requeue.py.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Upload request path uses its own S3 client with short timeouts (5s/30s,
2 attempts) and no longer holds a DB row lock during the S3 call; S3/DB
failures answer 503 + Retry-After instead of 500 after minutes of waiting.
- Transient S3/DB errors in ingest/OCR no longer count against max_attempts
(previously ~15 min of outage turned images into FAILED); the sweep retries.
- The sweep no longer queues the same id twice (no pile-up during long outages).
- Backlog check logs [GUNDI][ALARM] for stuck/failed entries.
- tools/gundi_requeue.py resets FAILED/FAIL entries; unit tests for all of it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>