Commit 8739f22
fix: Propagate expected exceptions from rate limit functions (#7736)
Stop reporting errors on expected transient exceptions during allocation
policy evaluation.
`rate_limit_start_request` and `rate_limit_finish_request` have broad
`except Exception` handlers that call `logger.exception()`, which
reports errors even for expected conditions like Redis timeouts and
unexpected pipeline result counts (`StopIteration`). However, the base
`AllocationPolicy` class can handle these at a higher level —
incrementing a `fail_open` metric and continuing without error logging.
This change re-raises `RedisTimeoutError` and `StopIteration` from the
low-level rate limit functions so they propagate to the allocation
policy base class, which handles them by failing open with a metric
(`reason` tagged by exception type) and avoiding noisy error reports.
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent b53a7ac commit 8739f22
File tree
2 files changed
+18
-8
lines changed- snuba
- query/allocation_policies
- state
2 files changed
+18
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
486 | | - | |
487 | | - | |
488 | | - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
492 | | - | |
| 492 | + | |
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | | - | |
557 | | - | |
558 | | - | |
| 556 | + | |
559 | 557 | | |
560 | | - | |
| 558 | + | |
561 | 559 | | |
562 | 560 | | |
563 | 561 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
282 | 292 | | |
283 | 293 | | |
284 | 294 | | |
| |||
315 | 325 | | |
316 | 326 | | |
317 | 327 | | |
| 328 | + | |
| 329 | + | |
318 | 330 | | |
319 | 331 | | |
320 | 332 | | |
| |||
0 commit comments