m-trieu commented on code in PR #34283:
URL: https://github.com/apache/beam/pull/34283#discussion_r2012822232


##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/client/AbstractWindmillStream.java:
##########
@@ -236,13 +239,34 @@ protected final void executeSafely(Runnable runnable) {
     }
   }
 
-  public final synchronized void maybeSendHealthCheck(Instant 
lastSendThreshold) {
-    if (!clientClosed && debugMetrics.getLastSendTimeMs() < 
lastSendThreshold.getMillis()) {
-      try {
-        sendHealthCheck();
-      } catch (Exception e) {
-        logger.debug("Received exception sending health check.", e);
-      }
+  /**
+   * Schedule an application level keep-alive health check to be sent on the 
stream.
+   *
+   * @implNote This is sent asynchronously via an executor to minimize 
blocking. Messages are sent
+   *     serially. If we recently sent a message before we attempt to schedule 
the health check, the
+   *     stream has been restarted/closed, there is an active health check 
that hasn't completed due
+   *     to flow control/pushback or there was a more recent send by the time 
we enter the
+   *     synchronized block, we skip the attempt to send scheduled the health 
check.
+   */
+  public final void maybeSendHealthCheck(Instant lastSendThreshold) {
+    if (debugMetrics.getLastSendTimeMs() < lastSendThreshold.getMillis() && 
!isHealthCheckActive) {

Review Comment:
   done, opted to use an AtomicBoolean



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to