You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2020/11/09 09:11:07 UTC
[flink] branch release-1.11 updated (1b75ae8 -> 32e2305)
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a change to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git.
from 1b75ae8 [hotfix][python][docs] Fix the mistakes of connector options in the examples
new d9be318 [FLINK-19237] Fix rejected slot offer bug in JobMaster
new 90fb07c [FLINK-20033] Make JobManagerJobStatusListener call back run directly
new 32e2305 [FLINK-20033] Ensure that stopping a JobMaster will suspend the running job
The 3 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:
.../apache/flink/runtime/jobmaster/JobMaster.java | 35 ++-----
.../flink/runtime/jobmaster/JobMasterTest.java | 111 +++++++++++++++++++++
2 files changed, 121 insertions(+), 25 deletions(-)
[flink] 03/03: [FLINK-20033] Ensure that stopping a JobMaster will
suspend the running job
Posted by tr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 32e23052af547bb1b99274778c666f3d814201a8
Author: Till Rohrmann <tr...@apache.org>
AuthorDate: Sat Nov 7 17:22:52 2020 +0100
[FLINK-20033] Ensure that stopping a JobMaster will suspend the running job
This commit adds a test which ensures that stopping a JobMaster will suspend the running job.
This closes #13979.
---
.../flink/runtime/jobmaster/JobMasterTest.java | 52 ++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
index 83016f8..5a28fad 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
@@ -1961,6 +1961,58 @@ public class JobMasterTest extends TestLogger {
);
}
+ /**
+ * Tests that the job gets suspended when the JobMaster stops. See FLINK-20033.
+ */
+ @Test
+ public void testJobSuspensionWhenJobMasterStops() throws Exception {
+ final JobMasterBuilder.TestingOnCompletionActions onCompletionActions = new JobMasterBuilder.TestingOnCompletionActions();
+
+ final JobMaster jobMaster = createJobMaster(
+ configuration,
+ JobGraphTestUtils.createSingleVertexJobGraph(),
+ haServices,
+ new TestingJobManagerSharedServicesBuilder().build(),
+ heartbeatServices,
+ onCompletionActions);
+
+ CompletableFuture<Acknowledge> startFuture = jobMaster.start(jobMasterId);
+
+ try {
+ // wait for the start of the JobMaster
+ startFuture.get();
+
+ final CompletableFuture<TaskDeploymentDescriptor> tddFuture = new CompletableFuture<>();
+ final TestingTaskExecutorGateway testingTaskExecutorGateway = new TestingTaskExecutorGatewayBuilder()
+ .setSubmitTaskConsumer((taskDeploymentDescriptor, jobMasterId) -> {
+ tddFuture.complete(taskDeploymentDescriptor);
+ return CompletableFuture.completedFuture(Acknowledge.get());
+ })
+ .createTestingTaskExecutorGateway();
+ final LocalUnresolvedTaskManagerLocation taskManagerLocation = new LocalUnresolvedTaskManagerLocation();
+ final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);
+
+ registerSlotsAtJobMaster(1, jobMasterGateway, testingTaskExecutorGateway, taskManagerLocation);
+
+ // wait for deployment
+ tddFuture.get();
+
+ // trigger termination of JobMaster and also the job
+ jobMaster.close();
+
+ try {
+ final ArchivedExecutionGraph archivedExecutionGraph = onCompletionActions
+ .getJobReachedGloballyTerminalStateFuture()
+ .get(50, TimeUnit.MILLISECONDS);
+ fail(String.format("Job must not reach the globally terminal state %s when stopping the JobMaster.", archivedExecutionGraph.getState()));
+ } catch (TimeoutException expected) {
+ // expected
+ }
+ } finally {
+ RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
+ }
+ }
+
private void runJobFailureWhenTaskExecutorTerminatesTest(
HeartbeatServices heartbeatServices,
BiConsumer<LocalUnresolvedTaskManagerLocation, JobMasterGateway> jobReachedRunningState,
[flink] 02/03: [FLINK-20033] Make JobManagerJobStatusListener call
back run directly
Posted by tr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 90fb07c311aa6c91ad544705ee96a14ab9302122
Author: Till Rohrmann <tr...@apache.org>
AuthorDate: Sat Nov 7 17:20:25 2020 +0100
[FLINK-20033] Make JobManagerJobStatusListener call back run directly
Since the ExecutionGraph can only be modified using the JobMaster's main thread, we no longer
need to trigger a jobStatusChanged async message when the JobManagerJobStatusListener.jobStatusChanges
callback is triggered. This ensures that job status changes will directly be reported.
---
.../org/apache/flink/runtime/jobmaster/JobMaster.java | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
index 883b313..3f0c701 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
@@ -921,10 +921,6 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
if (jobManagerJobMetricGroup != null) {
jobManagerJobMetricGroup.close();
}
-
- if (jobStatusListener != null) {
- jobStatusListener.stop();
- }
}
private void clearSchedulerFields() {
@@ -1178,23 +1174,13 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
private class JobManagerJobStatusListener implements JobStatusListener {
- private volatile boolean running = true;
-
@Override
public void jobStatusChanges(
final JobID jobId,
final JobStatus newJobStatus,
final long timestamp,
final Throwable error) {
-
- if (running) {
- // run in rpc thread to avoid concurrency
- runAsync(() -> jobStatusChanged(newJobStatus, timestamp, error));
- }
- }
-
- private void stop() {
- running = false;
+ jobStatusChanged(newJobStatus, timestamp, error);
}
}
[flink] 01/03: [FLINK-19237] Fix rejected slot offer bug in
JobMaster
Posted by tr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git
commit d9be3188e49fe93e3bf56b3077aca3e53177807a
Author: Robert Metzger <rm...@apache.org>
AuthorDate: Wed Oct 14 08:17:10 2020 +0200
[FLINK-19237] Fix rejected slot offer bug in JobMaster
The JobMaster was rejecting slot offers from TaskExecutors erroneously in cases where the TaskExecutor ID is reused.
This fixes the JobMaster.suspend() behavior to do proper bookkeeping of TaskExecutors.
---
.../apache/flink/runtime/jobmaster/JobMaster.java | 19 ++++---
.../flink/runtime/jobmaster/JobMasterTest.java | 59 ++++++++++++++++++++++
2 files changed, 68 insertions(+), 10 deletions(-)
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
index 12d65fc..883b313 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
@@ -349,17 +349,9 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
public CompletableFuture<Void> onStop() {
log.info("Stopping the JobMaster for job {}({}).", jobGraph.getName(), jobGraph.getJobID());
- // disconnect from all registered TaskExecutors
- final Set<ResourceID> taskManagerResourceIds = new HashSet<>(registeredTaskManagers.keySet());
- final FlinkException cause = new FlinkException("Stopping JobMaster for job " + jobGraph.getName() +
- '(' + jobGraph.getJobID() + ").");
-
- for (ResourceID taskManagerResourceId : taskManagerResourceIds) {
- disconnectTaskManager(taskManagerResourceId, cause);
- }
-
// make sure there is a graceful exit
- suspendExecution(new FlinkException("JobManager is shutting down."));
+ suspendExecution(new FlinkException("Stopping JobMaster for job " + jobGraph.getName() +
+ '(' + jobGraph.getJobID() + ")."));
// shut down will internally release all registered slots
slotPool.close();
@@ -836,6 +828,13 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
suspendAndClearSchedulerFields(cause);
+ // disconnect from all registered TaskExecutors
+ final Set<ResourceID> taskManagerResourceIds = new HashSet<>(registeredTaskManagers.keySet());
+
+ for (ResourceID taskManagerResourceId : taskManagerResourceIds) {
+ disconnectTaskManager(taskManagerResourceId, cause);
+ }
+
// the slot pool stops receiving messages and clears its pooled slots
slotPool.suspend();
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
index 5953260..83016f8 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
@@ -142,6 +142,7 @@ import akka.actor.ActorSystem;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
@@ -282,6 +283,64 @@ public class JobMasterTest extends TestLogger {
}
}
+ /**
+ * This test ensures that the bookkeeping of TaskExecutors in the JobMaster handles cases where TaskExecutors with the same
+ * ID re-register properly. FLINK-19237 was a bug where the TaskExecutors and the SlotPool got out of sync, and
+ * slot offers were rejected.
+ */
+ @Test
+ public void testAcceptSlotOfferAfterLeaderChange() throws Exception {
+
+ final JobManagerSharedServices jobManagerSharedServices = new TestingJobManagerSharedServicesBuilder().build();
+ final JobMasterConfiguration jobMasterConfiguration = JobMasterConfiguration.fromConfiguration(configuration);
+
+ final SchedulerNGFactory schedulerNGFactory = SchedulerNGFactoryFactory.createSchedulerNGFactory(configuration);
+
+ final JobMaster testingJobMaster = new JobMaster(
+ rpcService,
+ jobMasterConfiguration,
+ jmResourceId,
+ jobGraph,
+ haServices,
+ DefaultSlotPoolFactory.fromConfiguration(configuration),
+ DefaultSchedulerFactory.fromConfiguration(configuration),
+ jobManagerSharedServices,
+ heartbeatServices,
+ UnregisteredJobManagerJobMetricGroupFactory.INSTANCE,
+ new JobMasterBuilder.TestingOnCompletionActions(),
+ testingFatalErrorHandler,
+ JobMasterTest.class.getClassLoader(),
+ schedulerNGFactory,
+ NettyShuffleMaster.INSTANCE,
+ NoOpJobMasterPartitionTracker.FACTORY);
+
+ testingJobMaster.start(jobMasterId).get();
+
+ JobMasterGateway jobMasterGateway = testingJobMaster.getSelfGateway(JobMasterGateway.class);
+
+ log.info("Register TaskManager");
+
+ String testingTaskManagerAddress = "fake";
+ UnresolvedTaskManagerLocation unresolvedTaskManagerLocation = new LocalUnresolvedTaskManagerLocation();
+ TestingTaskExecutorGateway testingTaskExecutorGateway = new TestingTaskExecutorGatewayBuilder().createTestingTaskExecutorGateway();
+ rpcService.registerGateway(testingTaskManagerAddress, testingTaskExecutorGateway);
+ Assert.assertThat(jobMasterGateway.registerTaskManager(testingTaskManagerAddress, unresolvedTaskManagerLocation, testingTimeout).get(), instanceOf(RegistrationResponse.Success.class));
+
+ log.info("Revoke leadership & re-grant leadership");
+ testingJobMaster.suspend(new FlinkException("Lost leadership")).get();
+
+ testingJobMaster.start(JobMasterId.generate()).get();
+
+ log.info("re-register same TaskManager");
+ Assert.assertThat(jobMasterGateway.registerTaskManager(testingTaskManagerAddress, unresolvedTaskManagerLocation, testingTimeout).get(), instanceOf(RegistrationResponse.Success.class));
+
+ log.info("Ensure JobMaster accepts slot offer");
+ final SlotOffer slotOffer = new SlotOffer(new AllocationID(), 0, ResourceProfile.ANY);
+
+ Collection<SlotOffer> acceptedSlots = jobMasterGateway.offerSlots(unresolvedTaskManagerLocation.getResourceID(), Collections.singleton(slotOffer), testingTimeout).get();
+ Assert.assertThat(acceptedSlots.size(), is(1));
+ }
+
@Test
public void testDeclineCheckpointInvocationWithUserException() throws Exception {
RpcService rpcService1 = null;