Commit c56cf1f
committed
fix: preserve row in dispatch_one when consume() early-exits on shutdown
If stop() flips running=False between a worker pulling a row from
_inflight and dispatch_one entering consume(), FastStream's base
SubscriberUsecase.consume() returns None via its early-exit guard
without invoking the handler. dispatch_one previously fell into
assert_state_set → reject() → _safe_flush, silently DELETEing the
row and emitting an 'acked' metric for work that never ran.
Restructure the consume() block so a None return + running=False
short-circuits before the flush path; the lease lives until
lease_ttl_seconds expires and another replica reclaims the row on
next start. Behavior is preserved for the consume()-raises path
because the outer except already returned without flushing, making
the previous finally-driven state_set mutation a no-op.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# Conflicts:
# CLAUDE.md1 parent 7c1f5f0 commit c56cf1f
3 files changed
Lines changed: 47 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
| 442 | + | |
446 | 443 | | |
447 | 444 | | |
448 | 445 | | |
449 | 446 | | |
450 | 447 | | |
451 | 448 | | |
452 | 449 | | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
453 | 458 | | |
454 | 459 | | |
455 | 460 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1578 | 1578 | | |
1579 | 1579 | | |
1580 | 1580 | | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
1581 | 1617 | | |
1582 | 1618 | | |
1583 | 1619 | | |
| |||
0 commit comments