You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by yh...@apache.org on 2024/10/31 21:46:06 UTC
(beam) branch debugsparkpvr updated (2fd522c6914 -> 78421b5fc0b)
This is an automated email from the ASF dual-hosted git repository.
yhu pushed a change to branch debugsparkpvr
in repository https://gitbox.apache.org/repos/asf/beam.git
discard 2fd522c6914 Debug PreCommit Spark PVR Batch
new 78421b5fc0b Suppress errors in JvmInitializer#beforeProcessing if successfully initialized before
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (2fd522c6914)
\
N -- N -- N refs/heads/debugsparkpvr (78421b5fc0b)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
(beam) 01/01: Suppress errors in JvmInitializer#beforeProcessing if successfully initialized before
Posted by yh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
yhu pushed a commit to branch debugsparkpvr
in repository https://gitbox.apache.org/repos/asf/beam.git
commit 78421b5fc0b1030d3ac35f3e7d241e7491488234
Author: Yi Hu <ya...@google.com>
AuthorDate: Wed Oct 30 14:16:42 2024 -0400
Suppress errors in JvmInitializer#beforeProcessing if successfully initialized before
---
.../beam_PostCommit_Java_PVR_Spark_Batch.json | 2 +-
.../environment/EmbeddedEnvironmentFactory.java | 2 ++
.../org/apache/beam/sdk/fn/JvmInitializers.java | 24 ++++++++++++++++++----
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/.github/trigger_files/beam_PostCommit_Java_PVR_Spark_Batch.json b/.github/trigger_files/beam_PostCommit_Java_PVR_Spark_Batch.json
index e0266d62f2e..f1ba03a243e 100644
--- a/.github/trigger_files/beam_PostCommit_Java_PVR_Spark_Batch.json
+++ b/.github/trigger_files/beam_PostCommit_Java_PVR_Spark_Batch.json
@@ -1,4 +1,4 @@
{
"comment": "Modify this file in a trivial way to cause this test suite to run",
- "modification": 4
+ "modification": 5
}
diff --git a/runners/java-fn-execution/src/main/java/org/apache/beam/runners/fnexecution/environment/EmbeddedEnvironmentFactory.java b/runners/java-fn-execution/src/main/java/org/apache/beam/runners/fnexecution/environment/EmbeddedEnvironmentFactory.java
index 72fa991c1f7..470692e7510 100644
--- a/runners/java-fn-execution/src/main/java/org/apache/beam/runners/fnexecution/environment/EmbeddedEnvironmentFactory.java
+++ b/runners/java-fn-execution/src/main/java/org/apache/beam/runners/fnexecution/environment/EmbeddedEnvironmentFactory.java
@@ -140,6 +140,8 @@ public class EmbeddedEnvironmentFactory implements EnvironmentFactory {
try {
fnHarness.get();
} catch (Throwable t) {
+ // Print stacktrace to stderr. Could be useful if underlying error not surfaced earlier
+ t.printStackTrace();
executor.shutdownNow();
}
});
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/fn/JvmInitializers.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/fn/JvmInitializers.java
index f739a797af8..453c1cd79a4 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/fn/JvmInitializers.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/fn/JvmInitializers.java
@@ -17,6 +17,7 @@
*/
package org.apache.beam.sdk.fn;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.beam.sdk.harness.JvmInitializer;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.util.common.ReflectHelpers;
@@ -25,6 +26,8 @@ import org.slf4j.LoggerFactory;
/** Helpers for executing {@link JvmInitializer} implementations. */
public class JvmInitializers {
+ private static final AtomicBoolean initialized = new AtomicBoolean(false);
+
/**
* Finds all registered implementations of JvmInitializer and executes their {@code onStartup}
* methods. Should be called in worker harness implementations at the very beginning of their main
@@ -50,10 +53,23 @@ public class JvmInitializers {
// We load the logger in the method to minimize the amount of class loading that happens
// during class initialization.
Logger logger = LoggerFactory.getLogger(JvmInitializers.class);
- for (JvmInitializer initializer : ReflectHelpers.loadServicesOrdered(JvmInitializer.class)) {
- logger.info("Running JvmInitializer#beforeProcessing for {}", initializer);
- initializer.beforeProcessing(options);
- logger.info("Completed JvmInitializer#beforeProcessing for {}", initializer);
+
+ try {
+ for (JvmInitializer initializer : ReflectHelpers.loadServicesOrdered(JvmInitializer.class)) {
+ logger.info("Running JvmInitializer#beforeProcessing for {}", initializer);
+ initializer.beforeProcessing(options);
+ logger.info("Completed JvmInitializer#beforeProcessing for {}", initializer);
+ }
+ initialized.compareAndSet(false, true);
+ } catch (Error e) {
+ if (initialized.get()) {
+ logger.warn(
+ "Error at JvmInitializer#beforeProcessing. This error is suppressed after "
+ + "previous success runs. It is expected on Embedded environment",
+ e);
+ } else {
+ throw e;
+ }
}
}
}