You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by tv...@apache.org on 2023/11/15 02:13:18 UTC

(beam) branch master updated: Add logging in data plane code when processing is stuck waiting on data for an instruction. (#29399)

This is an automated email from the ASF dual-hosted git repository.

tvalentyn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 427faae497d Add logging in data plane code when processing is stuck waiting on data for an instruction. (#29399)
427faae497d is described below

commit 427faae497db525e8cddd6a307ecddf4c9539919
Author: tvalentyn <tv...@users.noreply.github.com>
AuthorDate: Tue Nov 14 18:13:11 2023 -0800

    Add logging in data plane code when processing is stuck waiting on data for an instruction. (#29399)
---
 sdks/python/apache_beam/runners/worker/data_plane.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/sdks/python/apache_beam/runners/worker/data_plane.py b/sdks/python/apache_beam/runners/worker/data_plane.py
index a8638345da6..5c763743f41 100644
--- a/sdks/python/apache_beam/runners/worker/data_plane.py
+++ b/sdks/python/apache_beam/runners/worker/data_plane.py
@@ -499,7 +499,10 @@ class _GrpcDataChannel(DataChannel):
       raise RuntimeError('Instruction cleaned up already %s' % instruction_id)
     done_inputs = set()  # type: Set[Union[str, Tuple[str, str]]]
     abort_callback = abort_callback or (lambda: False)
+    log_interval_sec = 5 * 60
     try:
+      start_time = time.time()
+      next_waiting_log_time = start_time + log_interval_sec
       while len(done_inputs) < len(expected_inputs):
         try:
           element = received.get(timeout=1)
@@ -510,7 +513,21 @@ class _GrpcDataChannel(DataChannel):
             return
           if self._exception:
             raise self._exception from None
+          current_time = time.time()
+          if next_waiting_log_time <= current_time:
+            # If at the same time another instruction is waiting on input queue
+            # to become available, it is a sign of inefficiency in data plane.
+            _LOGGER.info(
+                'Detected input queue delay longer than %s seconds. '
+                'Waiting to receive elements in input queue '
+                'for instruction: %s for %.2f seconds.',
+                log_interval_sec,
+                instruction_id,
+                current_time - start_time)
+            next_waiting_log_time = current_time + log_interval_sec
         else:
+          start_time = time.time()
+          next_waiting_log_time = start_time + log_interval_sec
           if isinstance(element, beam_fn_api_pb2.Elements.Timers):
             if element.is_last:
               done_inputs.add((element.transform_id, element.timer_family_id))