Skip to content

Commit 5f9a15d

Browse files
authored
fix(consumer): Ensure backpressure is properly handled in stale message routing (#83271)
Previously we were not handling the case where a `MessageRejected` error which signals backpressure from downstream steps might be received in the dlq stale messages strategy. If this happens we can just ignore the error, we will retry on the next loop.
1 parent f8f3a8a commit 5f9a15d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/sentry/consumers/dlq.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
from arroyo.backends.kafka import KafkaPayload, KafkaProducer
99
from arroyo.dlq import InvalidMessage, KafkaDlqProducer
10-
from arroyo.processing.strategies.abstract import ProcessingStrategy, ProcessingStrategyFactory
10+
from arroyo.processing.strategies.abstract import (
11+
MessageRejected,
12+
ProcessingStrategy,
13+
ProcessingStrategyFactory,
14+
)
1115
from arroyo.types import FILTERED_PAYLOAD, BrokerValue, Commit, FilteredPayload, Message, Partition
1216
from arroyo.types import Topic as ArroyoTopic
1317
from arroyo.types import Value
@@ -127,9 +131,12 @@ def poll(self) -> None:
127131
if self.offsets_to_forward:
128132
if time.time() > self.last_forwarded_offsets + 1:
129133
filtered_message = Message(Value(FILTERED_PAYLOAD, self.offsets_to_forward))
130-
self.next_step.submit(filtered_message)
131-
self.offsets_to_forward = {}
132-
self.last_forwarded_offsets = time.time()
134+
try:
135+
self.next_step.submit(filtered_message)
136+
self.offsets_to_forward = {}
137+
self.last_forwarded_offsets = time.time()
138+
except MessageRejected:
139+
pass
133140

134141
def join(self, timeout: float | None = None) -> None:
135142
self.next_step.join(timeout)

0 commit comments

Comments
 (0)