Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Distinguish between backpressure and output overflow #234

Merged
merged 1 commit into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions arroyo/processing/strategies/run_task_with_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ def __check_for_results(self, timeout: Optional[float] = None) -> None:

result = async_result.get(timeout=timeout)

next_step_has_applied_backpressure = False

for idx, message in result.valid_messages_transformed:
if isinstance(message, InvalidMessage):
result.valid_messages_transformed.reset_iterator(idx + 1)
Expand All @@ -438,16 +440,25 @@ def __check_for_results(self, timeout: Optional[float] = None) -> None:

except MessageRejected:
result.next_index_to_process = idx
next_step_has_applied_backpressure = True
break

if result.next_index_to_process != len(input_batch):
self.__metrics.increment(
"arroyo.strategies.run_task_with_multiprocessing.batch.output.overflow"
)
if next_step_has_applied_backpressure:
self.__metrics.increment(
"arroyo.strategies.run_task_with_multiprocessing.batch.backpressure"
)
else:
self.__metrics.increment(
"arroyo.strategies.run_task_with_multiprocessing.batch.output.overflow"
)

logger.warning(
"Received incomplete batch (%0.2f%% complete), resubmitting...",
"Received incomplete batch (%0.2f%% complete), resubmitting (reason: %s)",
result.next_index_to_process / len(input_batch) * 100,
"backpressure" if next_step_has_applied_backpressure else "overflow",
)

# TODO: This reserializes all the ``SerializedMessage`` data prior
# to the processed index even though the values at those indices
# will never be unpacked. It probably makes sense to remove that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,37 @@ def test_message_rejected_multiple() -> None:
call(Message(Value(12, {}))),
call(Message(Value(-88, {}))),
]

assert TestingMetricsBackend.calls == [
GaugeCall(name="batches_in_progress", value=0.0, tags=None),
GaugeCall(name="transform.processes", value=1, tags=None),
GaugeCall(name="batches_in_progress", value=1.0, tags=None),
TimingCall(name="batch.size.msg", value=2, tags=None),
TimingCall(name="batch.size.bytes", value=0, tags=None),
IncrementCall(
name="arroyo.strategies.run_task_with_multiprocessing.batch.backpressure",
value=1,
tags=None,
),
IncrementCall(
name="arroyo.strategies.run_task_with_multiprocessing.batch.backpressure",
value=1,
tags=None,
),
IncrementCall(
name="arroyo.strategies.run_task_with_multiprocessing.batch.backpressure",
value=1,
tags=None,
),
IncrementCall(
name="arroyo.strategies.run_task_with_multiprocessing.batch.backpressure",
value=1,
tags=None,
),
IncrementCall(
name="arroyo.strategies.run_task_with_multiprocessing.batch.backpressure",
value=1,
tags=None,
),
GaugeCall(name="batches_in_progress", value=0.0, tags=None),
]