python student-tests/incident_worker.py
1. baseline (worker running):
   t=   15s  ready=   0 oldest_age=     0s worker_deliveries/s= 0.06 worker_busy=   0  QueueLagHigh=inactive http={'201': 137, 'upload 202': 2} 
2. t=18s docker compose stop worker; uploads continue
   t=   19s  ready=   0 oldest_age=     0s worker_deliveries/s= 0.07 worker_busy=   0  QueueLagHigh=inactive http={'201': 168, 'upload 202': 3} 
   t=   34s  ready=   0 oldest_age=     0s worker_deliveries/s= 0.06 worker_busy=   0  QueueLagHigh=inactive http={'201': 305, 'upload 202': 6} 
   t=   49s  ready=   4 oldest_age= 19.49s worker_deliveries/s= 0.06 worker_busy=   0  QueueLagHigh=inactive http={'201': 440, 'upload 202': 9} 
   t=   64s  ready=   6 oldest_age= 29.49s worker_deliveries/s= 0.02 worker_busy=   0  QueueLagHigh=inactive http={'201': 574, 'upload 202': 12} 
   t=   79s  ready=  10 oldest_age= 49.49s worker_deliveries/s=    — worker_busy=   0  QueueLagHigh=inactive http={'201': 711, 'upload 202': 15} 
   t=   94s  ready=  12 oldest_age=  59.5s worker_deliveries/s=    — worker_busy=   0  QueueLagHigh=inactive http={'201': 846, 'upload 202': 18} 
   t=  109s  ready=  16 oldest_age=  79.5s worker_deliveries/s=    — worker_busy=   0  QueueLagHigh=inactive http={'201': 984, 'upload 202': 21} 
   t=  124s  ready=  20 oldest_age= 99.51s worker_deliveries/s=    — worker_busy=   0  QueueLagHigh=pending  http={'201': 1121, 'upload 202': 23} 
   t=  124s  ready=  20 oldest_age= 99.51s worker_deliveries/s=    — worker_busy=   0  QueueLagHigh=pending  http={'201': 1121, 'upload 202': 23} 
   t=  139s  ready=  22 oldest_age=109.52s worker_deliveries/s=    — worker_busy=   0  QueueLagHigh=pending  http={'201': 1258, 'upload 202': 26} 
   t=  154s  ready=  25 oldest_age=129.52s worker_deliveries/s=    — worker_busy=   0  QueueLagHigh=pending  http={'201': 1393, 'upload 202': 29} 
   t=  169s  ready=  27 oldest_age=139.86s worker_deliveries/s=    — worker_busy=   0  QueueLagHigh=pending  http={'201': 1519, 'upload 202': 32} 
   t=  184s  ready=  31 oldest_age=159.55s worker_deliveries/s=    — worker_busy=   0  QueueLagHigh=firing   http={'201': 1654, 'upload 202': 35} 
3. QueueLagHigh pending at t=124s, FIRING at t=184s (165 s after the worker stopped)
4. t=189s docker compose start worker
   t=  197s  ready=  33 oldest_age=169.93s worker_deliveries/s=    — worker_busy=   0  QueueLagHigh=firing   http={'201': 1767, 'upload 202': 38} 
   t=  212s  ready=  31 oldest_age=159.33s worker_deliveries/s=    — worker_busy=   1  QueueLagHigh=firing   http={'201': 1902, 'upload 202': 41} 
   t=  227s  ready=  19 oldest_age= 96.24s worker_deliveries/s= 0.38 worker_busy=   1  QueueLagHigh=firing   http={'201': 2036, 'upload 202': 44} 
   t=  242s  ready=  11 oldest_age= 54.98s worker_deliveries/s= 0.63 worker_busy=   1  QueueLagHigh=firing   http={'201': 2174, 'upload 202': 46} 
   t=  257s  ready=   1 oldest_age=  3.16s worker_deliveries/s= 0.82 worker_busy= 0.5  QueueLagHigh=firing   http={'201': 2308, 'upload 202': 49} 
   t=  272s  ready=   0 oldest_age=     0s worker_deliveries/s= 0.62 worker_busy=   0  QueueLagHigh=inactive http={'201': 2442, 'upload 202': 52} 
   QueueLagHigh RESOLVED at t=272s (83 s after the worker started)
   all 52 uploads of the run are ready (none lost); final http codes: {'201': 2442, 'upload 202': 52}
5. diagnosis from stored telemetry:
   metrics: max oldest_age over 10 min = 170 s; worker deliveries/s fell to 0 while API kept answering 2xx — the queue is not drained, the API is healthy
   logs: worker.started (cf67239815a8); worker.stopped (cf67239815a8); worker.started (cf67239815a8)
   trace 42f0e6b4e45735295a6ddcff6dca33f of upload 97bd8671-fd20-4454-8d91-54bfd61c9db2 made during the outage: send -> process gap 123 s (message waited in the queue), processing itself 2.19 s
     messenger-api    SERVER   POST /api/v1/chats/{chat_id}/attachments             30.0 ms  route=/api/v1/chats/{chat_id}/attachments status_code=202
       messenger-api    CLIENT   S3.PutObject                                         10.1 ms  method=PutObject
       messenger-api    INTERNAL BackgroundTask nudge                                  0.8 ms
       messenger-api    PRODUCER send attachments                                      4.7 ms  attempt=1
         messenger-worker CONSUMER process attachments.process                        2190.9 ms  attempt=1 outcome=ready
           messenger-worker INTERNAL jobs.claim                                            6.8 ms
           messenger-worker CLIENT   S3.GetObject                                          8.1 ms  method=GetObject
           messenger-worker INTERNAL image.process                                      2066.8 ms
           messenger-worker CLIENT   S3.PutObject                                         10.5 ms  method=PutObject
           messenger-worker CLIENT   S3.PutObject                                          8.1 ms  method=PutObject
           messenger-worker CLIENT   S3.PutObject                                          8.3 ms  method=PutObject
           messenger-worker CLIENT   S3.PutObject                                          8.0 ms  method=PutObject
           messenger-worker INTERNAL jobs.complete                                        56.7 ms
           messenger-worker CLIENT   S3.DeleteObject                                       4.3 ms  method=DeleteObject
PASS: worker stopped -> oldest job age grew -> QueueLagHigh firing in 165 s; worker started -> backlog drained, alert resolved in 83 s; no uploads lost
