You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "m-trieu (via GitHub)" <gi...@apache.org> on 2024/10/24 08:40:29 UTC
[PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
m-trieu opened a new pull request, #32922:
URL: https://github.com/apache/beam/pull/32922
fix silent failures in dispatch loop from stalling the pipeline
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu closed pull request #32922: fix silent failures in dispatch loop from stalling the pipeline
URL: https://github.com/apache/beam/pull/32922
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle merged PR #32922:
URL: https://github.com/apache/beam/pull/32922
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #32922:
URL: https://github.com/apache/beam/pull/32922#issuecomment-2436856999
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment `assign set of reviewers`
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1821383609
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java:
##########
@@ -346,10 +348,7 @@ public static StreamingDataflowWorker fromOptions(DataflowWorkerHarnessOptions o
.setSizeMb(options.getWorkerCacheMb())
.setSupportMapViaMultimap(options.isEnableStreamingEngine())
.build();
- Function<String, ScheduledExecutorService> executorSupplier =
- threadName ->
- Executors.newSingleThreadScheduledExecutor(
Review Comment:
Resolved https://github.com/apache/beam/pull/32922#discussion_r1820519685
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1817205784
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/TerminatingExecutors.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.util;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import org.apache.beam.runners.dataflow.worker.WorkerUncaughtExceptionHandler;
+import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.slf4j.Logger;
+
+/**
+ * Utility class for {@link java.util.concurrent.ExecutorService}s that will terminate the JVM on
+ * uncaught exceptions.
+ *
+ * @implNote Ensures that all threads produced by the {@link ExecutorService}s have a {@link
+ * WorkerUncaughtExceptionHandler} attached to prevent hidden/silent exceptions and errors.
+ */
+public final class TerminatingExecutors {
+ private TerminatingExecutors() {}
+
+ public static ExecutorService newSingleThreadedExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return Executors.newSingleThreadExecutor(
+ terminatingThreadFactory(threadFactoryBuilder, logger));
+ }
+
+ public static ScheduledExecutorService newSingleThreadedScheduledExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return Executors.newSingleThreadScheduledExecutor(
+ terminatingThreadFactory(threadFactoryBuilder, logger));
+ }
+
+ public static ExecutorService newCachedThreadPool(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return Executors.newCachedThreadPool(terminatingThreadFactory(threadFactoryBuilder, logger));
+ }
+
+ public static ExecutorService newFixedThreadPool(
+ int numThreads, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return Executors.newFixedThreadPool(
+ numThreads, terminatingThreadFactory(threadFactoryBuilder, logger));
+ }
+
+ private static ThreadFactory terminatingThreadFactory(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return threadFactoryBuilder
+ .setUncaughtExceptionHandler(new WorkerUncaughtExceptionHandler(logger))
Review Comment:
added to test to ensure that we are halting the JVM
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1821426187
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java:
##########
@@ -174,7 +174,7 @@ private StreamingDataflowWorker(
StreamingCounters streamingCounters,
MemoryMonitor memoryMonitor,
GrpcWindmillStreamFactory windmillStreamFactory,
- Function<String, ScheduledExecutorService> executorSupplier,
+ Function<String, ScheduledExecutorService> activeWorkRefreshExecutorFn,
Review Comment:
does this need to be a parameter still? can we just create a scheduled executor to pass into ActiveWorkRefresher?
##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/streaming/harness/SingleSourceWorkerHarnessTest.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.streaming.harness;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.util.Optional;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import org.apache.beam.runners.dataflow.worker.WorkerUncaughtExceptionHandler;
+import org.apache.beam.runners.dataflow.worker.streaming.ComputationState;
+import org.apache.beam.runners.dataflow.worker.util.common.worker.JvmRuntime;
+import org.apache.beam.runners.dataflow.worker.windmill.client.commits.WorkCommitter;
+import org.apache.beam.runners.dataflow.worker.windmill.client.getdata.GetDataClient;
+import org.apache.beam.runners.dataflow.worker.windmill.work.processing.StreamingWorkScheduler;
+import org.apache.beam.runners.dataflow.worker.windmill.work.refresh.HeartbeatSender;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(JUnit4.class)
+public class SingleSourceWorkerHarnessTest {
+ private static final Logger LOG = LoggerFactory.getLogger(SingleSourceWorkerHarnessTest.class);
+ private final WorkCommitter workCommitter = mock(WorkCommitter.class);
+ private final GetDataClient getDataClient = mock(GetDataClient.class);
+ private final HeartbeatSender heartbeatSender = mock(HeartbeatSender.class);
+ private final Runnable waitForResources = () -> {};
+ private final Function<String, Optional<ComputationState>> computationStateFetcher =
+ ignored -> Optional.empty();
+ private final StreamingWorkScheduler streamingWorkScheduler = mock(StreamingWorkScheduler.class);
+
+ private SingleSourceWorkerHarness createWorkerHarness(
+ SingleSourceWorkerHarness.GetWorkSender getWorkSender, JvmRuntime runtime) {
+ Thread.setDefaultUncaughtExceptionHandler(new WorkerUncaughtExceptionHandler(runtime, LOG));
Review Comment:
// In non-test scenario this is set in ...
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java:
##########
@@ -346,10 +348,7 @@ public static StreamingDataflowWorker fromOptions(DataflowWorkerHarnessOptions o
.setSizeMb(options.getWorkerCacheMb())
.setSupportMapViaMultimap(options.isEnableStreamingEngine())
.build();
- Function<String, ScheduledExecutorService> executorSupplier =
- threadName ->
- Executors.newSingleThreadScheduledExecutor(
Review Comment:
yeah, since that schedules at a fixed rate internally to ActiveWorkRefresher I don think we want to crash the vm.
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #32922:
URL: https://github.com/apache/beam/pull/32922#issuecomment-2434713500
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1817097406
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/harness/SingleSourceWorkerHarness.java:
##########
@@ -103,11 +106,22 @@ public void start() {
"Multiple calls to {}.start() are not allowed.",
getClass());
workCommitter.start();
- workProviderExecutor.execute(
- () -> {
- getDispatchLoop().run();
- LOG.info("Dispatch done");
- });
+ while (isRunning.get()) {
+ Future<?> dispatchLoopFuture =
+ workProviderExecutor.submit(
+ () -> {
+ getDispatchLoop().run();
+ LOG.info("Dispatch done");
+ });
+
+ try {
+ dispatchLoopFuture.get();
Review Comment:
removed
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1819752790
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/harness/StreamingWorkerStatusReporter.java:
##########
@@ -228,6 +228,22 @@ private static void shutdownExecutor(ScheduledExecutorService executor) {
}
}
+ // Calculates the PerWorkerMetrics reporting frequency, ensuring alignment with the
Review Comment:
done
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "arunpandianp (via GitHub)" <gi...@apache.org>.
arunpandianp commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1817704576
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/harness/StreamingWorkerStatusReporter.java:
##########
@@ -228,6 +228,22 @@ private static void shutdownExecutor(ScheduledExecutorService executor) {
}
}
+ // Calculates the PerWorkerMetrics reporting frequency, ensuring alignment with the
Review Comment:
can we revert the unrelated change, to keep the diff small and on topic?
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/config/StreamingEngineComputationConfigFetcher.java:
##########
@@ -157,6 +157,19 @@ private static Optional<StreamingConfigTask> fetchConfigWithRetry(
}
}
+ private static Optional<ComputationConfig> createComputationConfig(StreamingConfigTask config) {
Review Comment:
can we revert the unrelated change, to keep the diff small and on topic?
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java:
##########
@@ -346,10 +348,7 @@ public static StreamingDataflowWorker fromOptions(DataflowWorkerHarnessOptions o
.setSizeMb(options.getWorkerCacheMb())
.setSupportMapViaMultimap(options.isEnableStreamingEngine())
.build();
- Function<String, ScheduledExecutorService> executorSupplier =
- threadName ->
- Executors.newSingleThreadScheduledExecutor(
Review Comment:
I think changing `Executors.newSingleThreadScheduledExecutor` to `Executors.newSingleThreadExecutor` should fix the problem? We don't need to introduce a new Executor.
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1821448353
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java:
##########
@@ -174,7 +174,7 @@ private StreamingDataflowWorker(
StreamingCounters streamingCounters,
MemoryMonitor memoryMonitor,
GrpcWindmillStreamFactory windmillStreamFactory,
- Function<String, ScheduledExecutorService> executorSupplier,
+ Function<String, ScheduledExecutorService> activeWorkRefreshExecutorFn,
Review Comment:
done
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "arunpandianp (via GitHub)" <gi...@apache.org>.
arunpandianp commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1819778474
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/TerminatingExecutors.java:
##########
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.util;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.apache.beam.runners.dataflow.worker.WorkerUncaughtExceptionHandler;
+import org.apache.beam.runners.dataflow.worker.util.common.worker.JvmRuntime;
+import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
+
+/**
+ * Utility class for {@link java.util.concurrent.ExecutorService}s that will terminate the JVM on
+ * uncaught exceptions.
+ *
+ * @implNote Ensures that all threads produced by the {@link ExecutorService}s have a {@link
+ * WorkerUncaughtExceptionHandler} attached to prevent hidden/silent exceptions and errors.
+ */
+public final class TerminatingExecutors {
+ private TerminatingExecutors() {}
+
+ public static TerminatingExecutorService newSingleThreadExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newSingleThreadExecutor(terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingScheduledExecutorService newSingleThreadScheduledExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingScheduledExecutorService(
+ Executors.newSingleThreadScheduledExecutor(
+ terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newCachedThreadPool(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newCachedThreadPool(terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newFixedThreadPool(
+ int numThreads, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newFixedThreadPool(
+ numThreads, terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newSingleThreadedExecutorForTesting(
+ JvmRuntime jvmRuntime, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newSingleThreadExecutor(
Review Comment:
I think the test is passing since you have `newSingleThreadExecutor` here. Try changing this to `newSingleThreadScheduledExecutor`, the test will fail.
something like WrappingExecutorService suggested by @scwhittle seems better. We can use the new executor only where ScheduledExecutorService are needed (eg: refresh), other places we can use plain `Executors.newSingleThreadExecutor`
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1817206087
##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/streaming/harness/SingleSourceWorkerHarnessTest.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.streaming.harness;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
+import static org.mockito.Mockito.mock;
+
+import java.util.Optional;
+import java.util.function.Function;
+import org.apache.beam.runners.dataflow.worker.streaming.ComputationState;
+import org.apache.beam.runners.dataflow.worker.windmill.client.commits.WorkCommitter;
+import org.apache.beam.runners.dataflow.worker.windmill.client.getdata.GetDataClient;
+import org.apache.beam.runners.dataflow.worker.windmill.work.processing.StreamingWorkScheduler;
+import org.apache.beam.runners.dataflow.worker.windmill.work.refresh.HeartbeatSender;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class SingleSourceWorkerHarnessTest {
+ private final WorkCommitter workCommitter = mock(WorkCommitter.class);
+ private final GetDataClient getDataClient = mock(GetDataClient.class);
+ private final HeartbeatSender heartbeatSender = mock(HeartbeatSender.class);
+ private final Runnable waitForResources = () -> {};
+ private final Function<String, Optional<ComputationState>> computationStateFetcher =
+ ignored -> Optional.empty();
+ private final StreamingWorkScheduler streamingWorkScheduler = mock(StreamingWorkScheduler.class);
+
+ private SingleSourceWorkerHarness createWorkerHarness(
+ SingleSourceWorkerHarness.GetWorkSender getWorkSender) {
+ return SingleSourceWorkerHarness.builder()
+ .setWorkCommitter(workCommitter)
+ .setGetDataClient(getDataClient)
+ .setHeartbeatSender(heartbeatSender)
+ .setWaitForResources(waitForResources)
+ .setStreamingWorkScheduler(streamingWorkScheduler)
+ .setComputationStateFetcher(computationStateFetcher)
+ .setGetWorkSender(getWorkSender)
+ .build();
+ }
+
+ @Test
+ public void testDispatchLoopFailureThrowsException_appliance() {
+ RuntimeException expected = new RuntimeException("something bad happened");
+ SingleSourceWorkerHarness.GetWorkSender getWorkSender =
+ SingleSourceWorkerHarness.GetWorkSender.forAppliance(
+ () -> {
+ throw expected;
Review Comment:
added test to ensure that the runtime is being terminated
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1816168706
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/harness/SingleSourceWorkerHarness.java:
##########
@@ -103,11 +106,22 @@ public void start() {
"Multiple calls to {}.start() are not allowed.",
getClass());
workCommitter.start();
- workProviderExecutor.execute(
- () -> {
- getDispatchLoop().run();
- LOG.info("Dispatch done");
- });
+ while (isRunning.get()) {
+ Future<?> dispatchLoopFuture =
+ workProviderExecutor.submit(
+ () -> {
+ getDispatchLoop().run();
+ LOG.info("Dispatch done");
+ });
+
+ try {
+ dispatchLoopFuture.get();
Review Comment:
this is changing start() to be blocking.
If we want that we shoudl have clearer method name and also just get rid of the workProviderExecutor and use this thread directly.
##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/streaming/harness/SingleSourceWorkerHarnessTest.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.streaming.harness;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
+import static org.mockito.Mockito.mock;
+
+import java.util.Optional;
+import java.util.function.Function;
+import org.apache.beam.runners.dataflow.worker.streaming.ComputationState;
+import org.apache.beam.runners.dataflow.worker.windmill.client.commits.WorkCommitter;
+import org.apache.beam.runners.dataflow.worker.windmill.client.getdata.GetDataClient;
+import org.apache.beam.runners.dataflow.worker.windmill.work.processing.StreamingWorkScheduler;
+import org.apache.beam.runners.dataflow.worker.windmill.work.refresh.HeartbeatSender;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class SingleSourceWorkerHarnessTest {
+ private final WorkCommitter workCommitter = mock(WorkCommitter.class);
+ private final GetDataClient getDataClient = mock(GetDataClient.class);
+ private final HeartbeatSender heartbeatSender = mock(HeartbeatSender.class);
+ private final Runnable waitForResources = () -> {};
+ private final Function<String, Optional<ComputationState>> computationStateFetcher =
+ ignored -> Optional.empty();
+ private final StreamingWorkScheduler streamingWorkScheduler = mock(StreamingWorkScheduler.class);
+
+ private SingleSourceWorkerHarness createWorkerHarness(
+ SingleSourceWorkerHarness.GetWorkSender getWorkSender) {
+ return SingleSourceWorkerHarness.builder()
+ .setWorkCommitter(workCommitter)
+ .setGetDataClient(getDataClient)
+ .setHeartbeatSender(heartbeatSender)
+ .setWaitForResources(waitForResources)
+ .setStreamingWorkScheduler(streamingWorkScheduler)
+ .setComputationStateFetcher(computationStateFetcher)
+ .setGetWorkSender(getWorkSender)
+ .build();
+ }
+
+ @Test
+ public void testDispatchLoopFailureThrowsException_appliance() {
+ RuntimeException expected = new RuntimeException("something bad happened");
+ SingleSourceWorkerHarness.GetWorkSender getWorkSender =
+ SingleSourceWorkerHarness.GetWorkSender.forAppliance(
+ () -> {
+ throw expected;
Review Comment:
I'm confused why the test of this isn't causing the runtime to halt. It makes me think the unhandled exception handler isn't being called and this is just working because of the changes to make start() blocking and call get on the future().
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/TerminatingExecutors.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.util;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import org.apache.beam.runners.dataflow.worker.WorkerUncaughtExceptionHandler;
+import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.slf4j.Logger;
+
+/**
+ * Utility class for {@link java.util.concurrent.ExecutorService}s that will terminate the JVM on
+ * uncaught exceptions.
+ *
+ * @implNote Ensures that all threads produced by the {@link ExecutorService}s have a {@link
+ * WorkerUncaughtExceptionHandler} attached to prevent hidden/silent exceptions and errors.
+ */
+public final class TerminatingExecutors {
+ private TerminatingExecutors() {}
+
+ public static ExecutorService newSingleThreadedExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return Executors.newSingleThreadExecutor(
+ terminatingThreadFactory(threadFactoryBuilder, logger));
+ }
+
+ public static ScheduledExecutorService newSingleThreadedScheduledExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return Executors.newSingleThreadScheduledExecutor(
+ terminatingThreadFactory(threadFactoryBuilder, logger));
+ }
+
+ public static ExecutorService newCachedThreadPool(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return Executors.newCachedThreadPool(terminatingThreadFactory(threadFactoryBuilder, logger));
+ }
+
+ public static ExecutorService newFixedThreadPool(
+ int numThreads, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return Executors.newFixedThreadPool(
+ numThreads, terminatingThreadFactory(threadFactoryBuilder, logger));
+ }
+
+ private static ThreadFactory terminatingThreadFactory(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return threadFactoryBuilder
+ .setUncaughtExceptionHandler(new WorkerUncaughtExceptionHandler(logger))
Review Comment:
I'm not sure this is working if the executor thread is catchign the exception and putting it in the future.
I think we might need instead to wrap the executor so that scheduled tasks are wrapped and then catch exceptions and call termination method like com/google/common/util/concurrent/WrappingExecutorService.java
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1819588611
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java:
##########
@@ -346,10 +348,7 @@ public static StreamingDataflowWorker fromOptions(DataflowWorkerHarnessOptions o
.setSizeMb(options.getWorkerCacheMb())
.setSupportMapViaMultimap(options.isEnableStreamingEngine())
.build();
- Function<String, ScheduledExecutorService> executorSupplier =
- threadName ->
- Executors.newSingleThreadScheduledExecutor(
Review Comment:
We need `ScheduledExecutorService` here and `Executors.newSingleThreadExecutor` does not return a `ScheduledExecutorService`
Question here:
do we want active work refresh failures to crash the JVM? if yes than we need a terminating executor, if not i think we can remove `TerminatingExecutors`, use `Executors.newSingleThreadExecutor` everywhere we want a failure to crash the JVM and `ScheduledExecutorService` everywhere we are ok with failures.
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1820466136
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/TerminatingExecutors.java:
##########
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.util;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.apache.beam.runners.dataflow.worker.WorkerUncaughtExceptionHandler;
+import org.apache.beam.runners.dataflow.worker.util.common.worker.JvmRuntime;
+import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
+
+/**
+ * Utility class for {@link java.util.concurrent.ExecutorService}s that will terminate the JVM on
+ * uncaught exceptions.
+ *
+ * @implNote Ensures that all threads produced by the {@link ExecutorService}s have a {@link
+ * WorkerUncaughtExceptionHandler} attached to prevent hidden/silent exceptions and errors.
+ */
+public final class TerminatingExecutors {
+ private TerminatingExecutors() {}
+
+ public static TerminatingExecutorService newSingleThreadExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newSingleThreadExecutor(terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingScheduledExecutorService newSingleThreadScheduledExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingScheduledExecutorService(
+ Executors.newSingleThreadScheduledExecutor(
+ terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newCachedThreadPool(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newCachedThreadPool(terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newFixedThreadPool(
+ int numThreads, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newFixedThreadPool(
+ numThreads, terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newSingleThreadedExecutorForTesting(
+ JvmRuntime jvmRuntime, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newSingleThreadExecutor(
Review Comment:
do we want to crash the JVM on failures of tasks submitted to ScheduledExecutorService?
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1821367239
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/TerminatingExecutors.java:
##########
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.util;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.apache.beam.runners.dataflow.worker.WorkerUncaughtExceptionHandler;
+import org.apache.beam.runners.dataflow.worker.util.common.worker.JvmRuntime;
+import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
+
+/**
+ * Utility class for {@link java.util.concurrent.ExecutorService}s that will terminate the JVM on
+ * uncaught exceptions.
+ *
+ * @implNote Ensures that all threads produced by the {@link ExecutorService}s have a {@link
+ * WorkerUncaughtExceptionHandler} attached to prevent hidden/silent exceptions and errors.
+ */
+public final class TerminatingExecutors {
+ private TerminatingExecutors() {}
+
+ public static TerminatingExecutorService newSingleThreadExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newSingleThreadExecutor(terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingScheduledExecutorService newSingleThreadScheduledExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingScheduledExecutorService(
+ Executors.newSingleThreadScheduledExecutor(
+ terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newCachedThreadPool(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newCachedThreadPool(terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newFixedThreadPool(
+ int numThreads, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newFixedThreadPool(
+ numThreads, terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newSingleThreadedExecutorForTesting(
+ JvmRuntime jvmRuntime, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newSingleThreadExecutor(
Review Comment:
updated thanks!
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "arunpandianp (via GitHub)" <gi...@apache.org>.
arunpandianp commented on PR #32922:
URL: https://github.com/apache/beam/pull/32922#issuecomment-2445434728
lgtm
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on PR #32922:
URL: https://github.com/apache/beam/pull/32922#issuecomment-2436855851
R: @arunpandianp @scwhittle
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on PR #32922:
URL: https://github.com/apache/beam/pull/32922#issuecomment-2438604938
back to you thank you!
@scwhittle
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1820519685
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/TerminatingExecutors.java:
##########
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.util;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.apache.beam.runners.dataflow.worker.WorkerUncaughtExceptionHandler;
+import org.apache.beam.runners.dataflow.worker.util.common.worker.JvmRuntime;
+import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
+
+/**
+ * Utility class for {@link java.util.concurrent.ExecutorService}s that will terminate the JVM on
+ * uncaught exceptions.
+ *
+ * @implNote Ensures that all threads produced by the {@link ExecutorService}s have a {@link
+ * WorkerUncaughtExceptionHandler} attached to prevent hidden/silent exceptions and errors.
+ */
+public final class TerminatingExecutors {
+ private TerminatingExecutors() {}
+
+ public static TerminatingExecutorService newSingleThreadExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newSingleThreadExecutor(terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingScheduledExecutorService newSingleThreadScheduledExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingScheduledExecutorService(
+ Executors.newSingleThreadScheduledExecutor(
+ terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newCachedThreadPool(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newCachedThreadPool(terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newFixedThreadPool(
+ int numThreads, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newFixedThreadPool(
+ numThreads, terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newSingleThreadedExecutorForTesting(
+ JvmRuntime jvmRuntime, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newSingleThreadExecutor(
Review Comment:
I think it depends on the use case. There can be cases where the futures are being examined and having the exceptions manually handled by retrying etc. If we are using schedule and not ignoring the future result then that seems like a case we wouldn't want a failure. If we are using execute or otherwise ignoring the future it seems like we would want a failure.
I think Arun's advice to use ExecutorService where we can makes sense. We can look at the remaining scheduledexecutorservice cases to see if we want to fail or if the errors are already handled via examining the futures.
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1820441792
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/TerminatingExecutors.java:
##########
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.util;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.apache.beam.runners.dataflow.worker.WorkerUncaughtExceptionHandler;
+import org.apache.beam.runners.dataflow.worker.util.common.worker.JvmRuntime;
+import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
+
+/**
+ * Utility class for {@link java.util.concurrent.ExecutorService}s that will terminate the JVM on
+ * uncaught exceptions.
+ *
+ * @implNote Ensures that all threads produced by the {@link ExecutorService}s have a {@link
+ * WorkerUncaughtExceptionHandler} attached to prevent hidden/silent exceptions and errors.
+ */
+public final class TerminatingExecutors {
+ private TerminatingExecutors() {}
+
+ public static TerminatingExecutorService newSingleThreadExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newSingleThreadExecutor(terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingScheduledExecutorService newSingleThreadScheduledExecutor(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingScheduledExecutorService(
+ Executors.newSingleThreadScheduledExecutor(
+ terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newCachedThreadPool(
+ ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newCachedThreadPool(terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newFixedThreadPool(
+ int numThreads, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newFixedThreadPool(
+ numThreads, terminatingThreadFactory(threadFactoryBuilder, logger)));
+ }
+
+ public static TerminatingExecutorService newSingleThreadedExecutorForTesting(
+ JvmRuntime jvmRuntime, ThreadFactoryBuilder threadFactoryBuilder, Logger logger) {
+ return new TerminatingExecutorService(
+ Executors.newSingleThreadExecutor(
Review Comment:
sgtm will update
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1819751872
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/config/StreamingEngineComputationConfigFetcher.java:
##########
@@ -157,6 +157,19 @@ private static Optional<StreamingConfigTask> fetchConfigWithRetry(
}
}
+ private static Optional<ComputationConfig> createComputationConfig(StreamingConfigTask config) {
Review Comment:
done
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1821446935
##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/streaming/harness/SingleSourceWorkerHarnessTest.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.streaming.harness;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.util.Optional;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import org.apache.beam.runners.dataflow.worker.WorkerUncaughtExceptionHandler;
+import org.apache.beam.runners.dataflow.worker.streaming.ComputationState;
+import org.apache.beam.runners.dataflow.worker.util.common.worker.JvmRuntime;
+import org.apache.beam.runners.dataflow.worker.windmill.client.commits.WorkCommitter;
+import org.apache.beam.runners.dataflow.worker.windmill.client.getdata.GetDataClient;
+import org.apache.beam.runners.dataflow.worker.windmill.work.processing.StreamingWorkScheduler;
+import org.apache.beam.runners.dataflow.worker.windmill.work.refresh.HeartbeatSender;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(JUnit4.class)
+public class SingleSourceWorkerHarnessTest {
+ private static final Logger LOG = LoggerFactory.getLogger(SingleSourceWorkerHarnessTest.class);
+ private final WorkCommitter workCommitter = mock(WorkCommitter.class);
+ private final GetDataClient getDataClient = mock(GetDataClient.class);
+ private final HeartbeatSender heartbeatSender = mock(HeartbeatSender.class);
+ private final Runnable waitForResources = () -> {};
+ private final Function<String, Optional<ComputationState>> computationStateFetcher =
+ ignored -> Optional.empty();
+ private final StreamingWorkScheduler streamingWorkScheduler = mock(StreamingWorkScheduler.class);
+
+ private SingleSourceWorkerHarness createWorkerHarness(
+ SingleSourceWorkerHarness.GetWorkSender getWorkSender, JvmRuntime runtime) {
+ Thread.setDefaultUncaughtExceptionHandler(new WorkerUncaughtExceptionHandler(runtime, LOG));
Review Comment:
done
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "arunpandianp (via GitHub)" <gi...@apache.org>.
arunpandianp commented on code in PR #32922:
URL: https://github.com/apache/beam/pull/32922#discussion_r1821598253
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java:
##########
@@ -416,7 +413,8 @@ public static StreamingDataflowWorker fromOptions(DataflowWorkerHarnessOptions o
streamingCounters,
memoryMonitor,
configFetcherComputationStateCacheAndWindmillClient.windmillStreamFactory(),
- executorSupplier,
+ Executors.newSingleThreadScheduledExecutor(
+ new ThreadFactoryBuilder().setNameFormat("threadName").build()),
Review Comment:
```suggestion
new ThreadFactoryBuilder().setNameFormat("RefreshWork").build()),
```
##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/streaming/harness/SingleSourceWorkerHarnessTest.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.streaming.harness;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.util.Optional;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import org.apache.beam.runners.dataflow.worker.WorkerUncaughtExceptionHandler;
+import org.apache.beam.runners.dataflow.worker.streaming.ComputationState;
+import org.apache.beam.runners.dataflow.worker.util.common.worker.JvmRuntime;
+import org.apache.beam.runners.dataflow.worker.windmill.client.commits.WorkCommitter;
+import org.apache.beam.runners.dataflow.worker.windmill.client.getdata.GetDataClient;
+import org.apache.beam.runners.dataflow.worker.windmill.work.processing.StreamingWorkScheduler;
+import org.apache.beam.runners.dataflow.worker.windmill.work.refresh.HeartbeatSender;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(JUnit4.class)
+public class SingleSourceWorkerHarnessTest {
+ private static final Logger LOG = LoggerFactory.getLogger(SingleSourceWorkerHarnessTest.class);
+ private final WorkCommitter workCommitter = mock(WorkCommitter.class);
+ private final GetDataClient getDataClient = mock(GetDataClient.class);
+ private final HeartbeatSender heartbeatSender = mock(HeartbeatSender.class);
+ private final Runnable waitForResources = () -> {};
+ private final Function<String, Optional<ComputationState>> computationStateFetcher =
+ ignored -> Optional.empty();
+ private final StreamingWorkScheduler streamingWorkScheduler = mock(StreamingWorkScheduler.class);
+
+ private SingleSourceWorkerHarness createWorkerHarness(
+ SingleSourceWorkerHarness.GetWorkSender getWorkSender, JvmRuntime runtime) {
+ // In non-test scenario this is set in StreamingDataflowWorker.main(...).
Review Comment:
```suggestion
// In non-test scenario this is set in DataflowWorkerHarnessHelper.initializeLogging(...).
```
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix silent failures in dispatch loop from stalling the pipeline [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on PR #32922:
URL: https://github.com/apache/beam/pull/32922#issuecomment-2445083317
back to you @arunpandianp @scwhittle thanks!
--
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-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org