`compute_aggregate_snapshot` returns ORM rows that were created inside a `with Session(engine)` block — by the time the Celery task tries to serialise their attributes into the result dict the session has closed, triggering SQLAlchemy's DetachedInstanceError. Combined with acks_late this caused the task to be redelivered repeatedly (4× in the first manual trigger). Fix: drop the per-row dict-serialisation in the task return — keep just `aggregates_written: int`. The per-band stats are already logged by the aggregator's own info-level lines, so no observability is lost. Caught when manually firing the task on prod to seed today's snapshot before the 04:00 UTC daily fire. Aggregator itself ran fine (the rows were written before the session closed); only the post-return access was broken. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| listing_tasks.py | ||
| market_tasks.py | ||
| poi_tasks.py | ||
| task_state.py | ||