johnjcasey commented on code in PR #23234:
URL: https://github.com/apache/beam/pull/23234#discussion_r983824896


##########
sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/options/GcsOptions.java:
##########
@@ -157,6 +178,30 @@ public ExecutorService create(PipelineOptions options) {
     }
   }
 
+  /**
+   * Returns the default {@link ExecutorService} to use within the Apache Beam 
SDK. The {@link
+   * ExecutorService} is compatible with AppEngine.
+   */
+  class ScheduledExecutorServiceFactory implements 
DefaultValueFactory<ScheduledExecutorService> {
+    @SuppressWarnings("deprecation") // IS_APP_ENGINE is deprecated for 
internal use only.
+    @Override
+    public ScheduledExecutorService create(PipelineOptions options) {
+      ThreadFactoryBuilder threadFactoryBuilder = new ThreadFactoryBuilder();
+      
threadFactoryBuilder.setThreadFactory(MoreExecutors.platformThreadFactory());
+      threadFactoryBuilder.setDaemon(true);
+      /* The SDK requires an unbounded thread pool because a step may create X 
writers
+       * each requiring their own thread to perform the writes otherwise a 
writer may
+       * block causing deadlock for the step because the writers buffer is 
full.
+       * Also, the MapTaskExecutor launches the steps in reverse order and 
completes
+       * them in forward order thus requiring enough threads so that each 
step's writers
+       * can be active.
+       */
+
+      return Executors.newScheduledThreadPool(
+          Math.max(4, Runtime.getRuntime().availableProcessors()), 
threadFactoryBuilder.build());

Review Comment:
   I dug into the default configuration in BQ. When we set the minimum to 0, 
threads weren't firing, so I looked to the known working configuration in BQ, 
and used that



-- 
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