You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by mxm <gi...@git.apache.org> on 2015/05/15 17:23:19 UTC
[GitHub] flink pull request: implement a simple session management
GitHub user mxm opened a pull request:
https://github.com/apache/flink/pull/681
implement a simple session management
This pull request implements a rudimentary session management. Together with the backtracking #640, this will enable users to successively submit jobs to the cluster and access intermediate results. Session handling ensures that the results are cleared eventually.
ExecutionGraphs are kept as long as
- no timeout occurred or
- the session has not been explicitly ended
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/mxm/flink session
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/681.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #681
----
commit e403db9874b587042e3fa740afbf00c0825eb61b
Author: Maximilian Michels <mx...@apache.org>
Date: 2015-05-13T15:06:47Z
implement a simple session management
This pull request implements a rudimentary session management. Together with the backtracking #640, this will enable users to submit jobs to the cluster and access intermediate results. Session handling ensures that the results are cleared eventually.
ExecutionGraphs are kept as long as
- no timeout occurred or
- the session has not been explicitly ended
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the pull request:
https://github.com/apache/flink/pull/681#issuecomment-103072112
You introduce a separate session ID here. Why not use the JobID as the session ID? This is how the logic in the JobManager (that attaches the graphs) currently works. Is there any limitation with that approach that requires to introduce the new ID?
I am just trying to keep the number of correlated IDs to a minimum here...
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on a diff in the pull request:
https://github.com/apache/flink/pull/681#discussion_r30509801
--- Diff: flink-runtime/src/test/scala/org/apache/flink/runtime/jobmanager/JobManagerITCase.scala ---
@@ -609,6 +612,98 @@ WordSpecLike with Matchers with BeforeAndAfterAll {
cluster.stop()
}
}
+
+ "remove execution graphs when the client ends the session explicitly" in {
+ val vertex = new AbstractJobVertex("Test Vertex")
+ vertex.setInvokableClass(classOf[NoOpInvokable])
+
+ val slowVertex = new AbstractJobVertex("Slow Vertex")
+ slowVertex.setInvokableClass(classOf[WaitingNoOpInvokable])
+
+ val sessionID = UUID.randomUUID()
+
+ val jobGraph1 = new JobGraph("Test Job", vertex)
+ jobGraph1.setSessionID(sessionID)
+ jobGraph1.setSessionTimeout(9 hours)
+
+ val jobGraph2 = new JobGraph("Slow Test Job", slowVertex)
+ jobGraph2.setSessionID(sessionID)
+ jobGraph2.setSessionTimeout(9 hours)
+
+ val cluster = TestingUtils.startTestingCluster(1)
+ val jm = cluster.getJobManager
+
+ try {
+ within(TestingUtils.TESTING_DURATION) {
+ jm ! SubmitJob(jobGraph1, false)
+ expectMsg(Success(jobGraph1.getJobID))
+ expectMsgType[JobResultSuccess]
+
+ jm ! SubmitJob(jobGraph2, false)
+
+ // remove jobs while jobGraph2 is still running
+ jm ! RemoveCachedJobs(sessionID)
+
+ expectMsg(Success(jobGraph2.getJobID))
+ expectMsgType[JobResultSuccess]
+
+ jm ! RequestExecutionGraph(jobGraph1.getJobID)
+ val graph1 = expectMsgType[ExecutionGraphFound].executionGraph
+ assert(graph1.isArchived)
+
+ jm ! RequestExecutionGraph(jobGraph2.getJobID)
+ val graph2 = expectMsgType[ExecutionGraphFound].executionGraph
+ assert(graph2.isArchived)
+ }
+ } finally {
+ cluster.stop()
+ }
+ }
+
+ "remove execution graphs when when the client's session times out" in {
+ val vertex = new AbstractJobVertex("Test Vertex")
+ vertex.setParallelism(1)
+ vertex.setInvokableClass(classOf[NoOpInvokable])
+
+ val sessionID = UUID.randomUUID()
+
+ val jobGraph1 = new JobGraph("Test Job", vertex)
+ jobGraph1.setSessionID(sessionID)
+ jobGraph1.setSessionTimeout(1 second)
+
+ val jobGraph2 = new JobGraph("Test Job", vertex)
+ jobGraph2.setSessionID(sessionID)
+ jobGraph2.setSessionTimeout(1 second)
+
+ val cluster = TestingUtils.startTestingCluster(1)
+ val jm = cluster.getJobManager
+
+ try {
+ within(TestingUtils.TESTING_DURATION) {
+ jm ! SubmitJob(jobGraph1, false)
+ expectMsg(Success(jobGraph1.getJobID))
+ expectMsgType[JobResultSuccess]
+
+ jm ! SubmitJob(jobGraph2, false)
+ expectMsg(Success(jobGraph2.getJobID))
+ expectMsgType[JobResultSuccess]
+
+ // wait until graph is archived
+ Thread.sleep(2000)
--- End diff --
This may be unstable on the CI infrastructure. A 1 second timeout and a 2 second check may fail when the CI server is under load.
In other tests, I simply loop and try multiple times up to a conservative value (such as 15 seconds). That way the test succeeds fast under good conditions, but allows slack for corner cases (loaded CI server, GC stall)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by mxm <gi...@git.apache.org>.
Github user mxm closed the pull request at:
https://github.com/apache/flink/pull/681
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the pull request:
https://github.com/apache/flink/pull/681#issuecomment-103073033
You schedule the `removeJob()` call after job is done. Does that mean the job will be removed after that time, even if new activity on that job happens?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by mxm <gi...@git.apache.org>.
Github user mxm commented on the pull request:
https://github.com/apache/flink/pull/681#issuecomment-103833918
Thanks for your feedback.
>You introduce a separate session ID here. Why not use the JobID as the session ID? This is how the logic in the JobManager (that attaches the graphs) currently works. Is there any limitation with that approach that requires to introduce the new ID?
Having two ids, `JobID` and the `SessionID`, gives us the possibility to submit multiple independent job graphs in one session. Maybe that's a bit of an overkill since we can already attach multiple independent branches to one job graph.
>You schedule the removeJob() call after job is done. Does that mean the job will be removed after that time, even if new activity on that job happens?
Currently, that is the case but this will change once we support to resume or extend jobs. In this case, we can cancel the timer that removes the job.
>The Client is bound to a session now. Should we tie it strictly to a session, meaning it has to be initialized with a JobID, or lazily pick up the session. What happens if you submit a JobGraph that comes from a different session? Does it track multiple sessions then?
The Client is bound to a session if the `sessionID` is set, otherwise it defaults to null and the job manager removes the job immediately after it has finished. I guess this is the kind of lazy pick up you mentioned. It has the advantage that the session management is optional. The job manager tracks multiple sessions. For each session it currently accepts multiple job graphs. Like you suggested that might be unnecessary and we can just move to one job graph per session.
>The LocalExecutor used in the LocalExecutionEnvironment should probably allow you to maintain sessions as well. It would need to be started on the first execution and stopped when the environment terminates the session or runs out of scope.
Yes, I didn't add anything there but you're right that it is a valid use even for local executions.
>I think it makes a lot of sense to automatically terminate sessions as soon as the environment or the executor runs out of scope (becomes finalizable or garbage collectible).
We can probably implement this by overriding the `finalize()` method of the `ExecutionEnvironment` class.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the pull request:
https://github.com/apache/flink/pull/681#issuecomment-105982832
Looks very nice now. Few comments:
- I suggest to keep the JobID in the JobGraph final and force it to be passed via the constructor. The JobGraphGenerator would need to accept the JobID as a parameter then.
- Let's keep the actor system in the `Client` alive. The startup of the actor system is the longest delay in all client commands. For proper interactive behavior, we need to keep it running. Start it on first use, and stop it when the client is shut down. We need to make sure the client is always shut down, in the remote executor, and in the CLI frontend.
- We can probably remove the "lastJobID" from the client, it seems redundant.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the pull request:
https://github.com/apache/flink/pull/681#issuecomment-103075554
There are quite a few implicit assumptions in this pull request, some of which have quite an impact:
- The `Client` is bound to a session now. Should we tie it strictly to a session, meaning it has to be initialized with a `JobID`, or lazily pick up the session. What happens if you submit a JobGraph that comes from a different session? Does it track multiple sessions then?
- If the `Client` manages remote sessions, it should be created on the first use of the remote executor, and then be kept.
- The `LocalExecutor` used in the `LocalExecutionEnvironment` should probably allow you to maintain sessions as well. It would need to be started on the first execution and stopped when the environment terminates the session or runs out of scope.
- I think it makes a lot of sense to automatically terminate sessions as soon as the environment or the executor runs out of scope (becomes finalizable or garbage collectible).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the pull request:
https://github.com/apache/flink/pull/681#issuecomment-105983100
After a chat with @mxm , we decided it would be good to merge this sooner and fix point 2 (keeping the actor system alive) in a separate patch. I'll try and address remarks (1) and (3) in the merging process.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by mxm <gi...@git.apache.org>.
Github user mxm commented on a diff in the pull request:
https://github.com/apache/flink/pull/681#discussion_r30686981
--- Diff: flink-runtime/src/test/scala/org/apache/flink/runtime/jobmanager/JobManagerITCase.scala ---
@@ -609,6 +612,98 @@ WordSpecLike with Matchers with BeforeAndAfterAll {
cluster.stop()
}
}
+
+ "remove execution graphs when the client ends the session explicitly" in {
+ val vertex = new AbstractJobVertex("Test Vertex")
+ vertex.setInvokableClass(classOf[NoOpInvokable])
+
+ val slowVertex = new AbstractJobVertex("Slow Vertex")
+ slowVertex.setInvokableClass(classOf[WaitingNoOpInvokable])
+
+ val sessionID = UUID.randomUUID()
+
+ val jobGraph1 = new JobGraph("Test Job", vertex)
+ jobGraph1.setSessionID(sessionID)
+ jobGraph1.setSessionTimeout(9 hours)
+
+ val jobGraph2 = new JobGraph("Slow Test Job", slowVertex)
+ jobGraph2.setSessionID(sessionID)
+ jobGraph2.setSessionTimeout(9 hours)
+
+ val cluster = TestingUtils.startTestingCluster(1)
+ val jm = cluster.getJobManager
+
+ try {
+ within(TestingUtils.TESTING_DURATION) {
+ jm ! SubmitJob(jobGraph1, false)
+ expectMsg(Success(jobGraph1.getJobID))
+ expectMsgType[JobResultSuccess]
+
+ jm ! SubmitJob(jobGraph2, false)
+
+ // remove jobs while jobGraph2 is still running
+ jm ! RemoveCachedJobs(sessionID)
+
+ expectMsg(Success(jobGraph2.getJobID))
+ expectMsgType[JobResultSuccess]
+
+ jm ! RequestExecutionGraph(jobGraph1.getJobID)
+ val graph1 = expectMsgType[ExecutionGraphFound].executionGraph
+ assert(graph1.isArchived)
+
+ jm ! RequestExecutionGraph(jobGraph2.getJobID)
+ val graph2 = expectMsgType[ExecutionGraphFound].executionGraph
+ assert(graph2.isArchived)
+ }
+ } finally {
+ cluster.stop()
+ }
+ }
+
+ "remove execution graphs when when the client's session times out" in {
+ val vertex = new AbstractJobVertex("Test Vertex")
+ vertex.setParallelism(1)
+ vertex.setInvokableClass(classOf[NoOpInvokable])
+
+ val sessionID = UUID.randomUUID()
+
+ val jobGraph1 = new JobGraph("Test Job", vertex)
+ jobGraph1.setSessionID(sessionID)
+ jobGraph1.setSessionTimeout(1 second)
+
+ val jobGraph2 = new JobGraph("Test Job", vertex)
+ jobGraph2.setSessionID(sessionID)
+ jobGraph2.setSessionTimeout(1 second)
+
+ val cluster = TestingUtils.startTestingCluster(1)
+ val jm = cluster.getJobManager
+
+ try {
+ within(TestingUtils.TESTING_DURATION) {
+ jm ! SubmitJob(jobGraph1, false)
+ expectMsg(Success(jobGraph1.getJobID))
+ expectMsgType[JobResultSuccess]
+
+ jm ! SubmitJob(jobGraph2, false)
+ expectMsg(Success(jobGraph2.getJobID))
+ expectMsgType[JobResultSuccess]
+
+ // wait until graph is archived
+ Thread.sleep(2000)
--- End diff --
I see how this could potentially be a problem even with a second timeout. Will fix the test with a loop like you suggested.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by mxm <gi...@git.apache.org>.
Github user mxm commented on a diff in the pull request:
https://github.com/apache/flink/pull/681#discussion_r30686986
--- Diff: flink-runtime/src/test/scala/org/apache/flink/runtime/jobmanager/JobManagerITCase.scala ---
@@ -609,6 +612,98 @@ WordSpecLike with Matchers with BeforeAndAfterAll {
cluster.stop()
}
}
+
+ "remove execution graphs when the client ends the session explicitly" in {
--- End diff --
Yes, will do that in the future.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on a diff in the pull request:
https://github.com/apache/flink/pull/681#discussion_r30510108
--- Diff: flink-runtime/src/test/scala/org/apache/flink/runtime/jobmanager/JobManagerITCase.scala ---
@@ -609,6 +612,98 @@ WordSpecLike with Matchers with BeforeAndAfterAll {
cluster.stop()
}
}
+
+ "remove execution graphs when the client ends the session explicitly" in {
--- End diff --
I think the consensus was to "lazily" move the `flink-runtime` package back to Java and write all new code and tests in Java. So for any additional tests that may come, can you write them in a new Java test class?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the pull request:
https://github.com/apache/flink/pull/681#issuecomment-103063104
Weird, this fails with a compilation error: https://travis-ci.org/apache/flink/jobs/62807299
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by mxm <gi...@git.apache.org>.
Github user mxm commented on the pull request:
https://github.com/apache/flink/pull/681#issuecomment-104707707
I've updated the pull request.
- The `JobID` is now propagated from the `ExecutionEnvironment` to the `JobGraph`. That's why a setter for setting the `JobID` at the `JobGraph` was necessary. It is ensured that the `JobID` can never be set to null. Job graphs which are instantiated manually, still generate a random `JobID` which does not depend on the session.
- A session timeout has been introduced that specifies the life span of a session. A timeout of zero implies immediate termination of the session after the job has been completed. Otherwise the `ExecutionGraph` is kept for the specified number of seconds.
- The methods `startNewSession()` and `setSessionTimeout(timeout)` have been added to the `ExecutionEnvironment`.
- The method `endSession()` has been added to the `Client` which is invoked through the `RemoteExecutor` or the `ContextEnvironment`.
- The `LocalExecutor` has been modified to respect the session, i.e. it does not shut down the Flink cluster it creates after execution when a session timeout >0 has been specified. In case a new session is invoked through the `LocalEnvironment`, a new LocalExecutor is created.
- The `finalize()` and a shutdown hook try to end the session when the `ExecutionEnvironment` gets garbage collected or the JVM is shut down.
I'm missing integration tests for the `RemoteEnvironment` and `LocalEnvironment` but there is not much to test at the moment. The core session functionality is tested in the `JobManagerITCase`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: implement a simple session management
Posted by mxm <gi...@git.apache.org>.
Github user mxm commented on the pull request:
https://github.com/apache/flink/pull/681#issuecomment-114517003
Closing this in favor of the new pull request #858.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---