Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue warning on long running DoFn.Setup on legacy Dataflow runner #34215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
import org.apache.beam.sdk.transforms.reflect.DoFnInvokers;
import org.apache.beam.sdk.util.DoFnInfo;
import org.apache.beam.sdk.util.SerializableUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Common {@link DoFnInstanceManager} implementations. */
@SuppressWarnings({
"nullness" // TODO(https://github.com/apache/beam/issues/20497)
})
public class DoFnInstanceManagers {
private static final Logger LOG = LoggerFactory.getLogger(DoFnInstanceManagers.class);
/**
* Returns a {@link DoFnInstanceManager} that returns {@link DoFnInfo} instances obtained by
* deserializing the provided bytes. {@link DoFnInstanceManager} will call {@link DoFn.Setup} as
Expand Down Expand Up @@ -83,7 +86,18 @@ private ConcurrentQueueInstanceManager(DoFnInfo<?, ?> info, PipelineOptions opti
private DoFnInfo<?, ?> deserializeCopy() throws Exception {
DoFnInfo<?, ?> fn;
fn = (DoFnInfo<?, ?>) SerializableUtils.deserializeFromByteArray(serializedFnInfo, null);
long startMillis = System.currentTimeMillis();
DoFnInvokers.tryInvokeSetupFor(fn.getDoFn(), options);
long elapsed = System.currentTimeMillis() - startMillis;
if (elapsed > 180_000) { // 3 min
// Work item could fail for long-running setup due to Dataflow worker lease timeout
LOG.warn(
String.format(
"DoFn.setup for %s ran for %d seconds.\nThis could cause Dataflow worker "
+ "lease expire and failing the job. DoFn.Setup should not contain long "
+ "running operations.",
fn.getDoFn().getClass(), elapsed / 1_000));
}
return fn;
}

Expand Down
Loading