m-trieu commented on code in PR #34367: URL: https://github.com/apache/beam/pull/34367#discussion_r2024330828
########## runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/harness/WindmillStreamSender.java: ########## @@ -165,4 +201,39 @@ long getAndResetThrottleTime() { long getCurrentActiveCommitBytes() { return workCommitter.currentActiveCommitBytes(); } + + /** + * Creates, starts, and gracefully terminates {@link GetWorkStream} before the clientside deadline + * to prevent {@link org.apache.beam.vendor.grpc.v1p69p0.io.grpc.Status#DEADLINE_EXCEEDED} errors. + * If at any point the server closes the stream, reconnects immediately. + */ + private void getWorkStreamLoop(CountDownLatch waitForInitialStream) { + @Nullable GetWorkStream newStream = null; + while (isRunning.get()) { + synchronized (activeGetWorkStream) { + newStream = getWorkStreamFactory.get(); + newStream.start(); + waitForInitialStream.countDown(); + activeGetWorkStream.set(newStream); + } + try { + // Try to gracefully terminate the stream. + if (!newStream.awaitTermination(GET_WORK_STREAM_TTL_MINUTES, TimeUnit.MINUTES)) { + newStream.halfClose(); Review Comment: done offloaded closure to a different thread -- 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: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org