fix(ingest): zero queue-depth gauge on all-queues-drained (review round 4)
- metrics: update_ingest_queue_depth guarded on `not by_queue`, which conflated
None (memory backend no-op) with {} (postgres, ALL queues drained). When every
queue drains at once, get_ingest_job_counts_by_queue returns {} and the
pre-zero loop was skipped, leaving a stale ghost backlog in the gauge. Guard on
`by_queue is None` only; add an all-drained regression test.
- procrastinate: note that INGEST_TRANSIENT_MAX_ATTEMPTS is snapshotted at
blueprint-build time (restart to pick up changes).
Deck #323.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
44f72839ed
commit
ce53e21ead
@@ -39,3 +39,17 @@ def test_none_is_noop(metric_sample):
|
||||
assert metric_sample(
|
||||
_METRIC, {"queue": "ingest-fast", "status": "doing"}
|
||||
) == approx(2)
|
||||
|
||||
|
||||
def test_all_queues_drained_empty_dict_zeroes(metric_sample):
|
||||
# postgres backend with every queue drained → get_ingest_job_counts_by_queue
|
||||
# returns {} (list_queues_async drops empty queues). An empty dict is NOT the
|
||||
# memory-backend no-op: it must still zero every managed queue's gauge.
|
||||
update_ingest_queue_depth({"ingest-fast": {"todo": 9}})
|
||||
assert metric_sample(_METRIC, {"queue": "ingest-fast", "status": "todo"}) == approx(
|
||||
9
|
||||
)
|
||||
update_ingest_queue_depth({})
|
||||
assert metric_sample(_METRIC, {"queue": "ingest-fast", "status": "todo"}) == approx(
|
||||
0
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user