XComp commented on code in PR #29290: URL: https://github.com/apache/flink/pull/29290#discussion_r4661936821
########## flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/RetryingExecutionGraphCreation.java: ########## @@ -0,0 +1,122 @@ +/* + * 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.flink.runtime.scheduler.adaptive; + +import org.apache.flink.api.common.JobStatus; +import org.apache.flink.runtime.executiongraph.ExecutionGraph; + +import org.slf4j.Logger; + +import javax.annotation.Nullable; + +import java.time.Duration; +import java.util.concurrent.ScheduledFuture; + +/** + * State entered when {@link CreatingExecutionGraph} fails to create the {@link ExecutionGraph} with + * a recoverable error. + */ +class RetryingExecutionGraphCreation extends StateWithoutExecutionGraph { + + private final Context context; + + private final Duration backoffTime; Review Comment: field is never used ########## flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/RetryingExecutionGraphCreation.java: ########## @@ -0,0 +1,122 @@ +/* + * 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.flink.runtime.scheduler.adaptive; + +import org.apache.flink.api.common.JobStatus; +import org.apache.flink.runtime.executiongraph.ExecutionGraph; + +import org.slf4j.Logger; + +import javax.annotation.Nullable; + +import java.time.Duration; +import java.util.concurrent.ScheduledFuture; + +/** + * State entered when {@link CreatingExecutionGraph} fails to create the {@link ExecutionGraph} with + * a recoverable error. + */ +class RetryingExecutionGraphCreation extends StateWithoutExecutionGraph { + + private final Context context; + + private final Duration backoffTime; + + @Nullable private final ExecutionGraph previousExecutionGraph; + + @Nullable private ScheduledFuture<?> goToSubsequentStateFuture; Review Comment: ```suggestion private final ScheduledFuture<?> goToSubsequentStateFuture; ``` That has some implications on correlated code because the null check becomes obsolete ########## flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/CreatingExecutionGraph.java: ########## @@ -94,16 +94,28 @@ private void handleExecutionGraphCreation( @Nullable ExecutionGraphWithVertexParallelism executionGraphWithVertexParallelism, @Nullable Throwable throwable) { if (throwable != null) { - getLogger() - .info( - "Failed to go from {} to {} because the ExecutionGraph creation failed.", - CreatingExecutionGraph.class.getSimpleName(), - Executing.class.getSimpleName(), - throwable); + final FailureResult failureResult = context.howToHandleEGCreationFailure(throwable); + if (failureResult.canRestart()) { + getLogger() + .info( + "Failed to create the ExecutionGraph; retrying after {} (backoff).", + failureResult.getBackoffTime(), + throwable); + context.goToRetryingExecutionGraphCreation( Review Comment: I had the initial idea to just overload `AdaptiveScheduler#goToWaitingForResources` which expects the backoff. That can be passed in from here using `failureResult#getBackoffTime`. We then use the the backoff to set the cooldown parameter and the `submissionResourceWaitTimeout` in the overloaded method. See ```java @Override public void goToWaitingForResources( @Nullable ExecutionGraph previousExecutionGraph, Duration backoff) { declareDesiredResources(); final Duration waitTimeout = settings.getSubmissionResourceWaitTimeout(); transitionToState( new WaitingForResources.Factory( this, LOG, // a negative timeout disables it and has to stay negative waitTimeout.isNegative() ? waitTimeout : waitTimeout.plus(backoff), ctx -> createWaitingForResourceStateTransitionManager(ctx, backoff), previousExecutionGraph)); } private StateTransitionManager createWaitingForResourceStateTransitionManager( StateTransitionManager.Context ctx, Duration cooldown) { return stateTransitionManagerFactory.create( ctx, clock, cooldown, settings.getSubmissionResourceStabilizationTimeout(), Duration.ZERO); } ``` What do you think of that approach? Only one method overload instead of an entirely new class. -- 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]
