You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by aljoscha <gi...@git.apache.org> on 2017/03/10 13:42:05 UTC
[GitHub] flink pull request #3509: [FLINK-5808] Fix Missing verification for setParal...
GitHub user aljoscha opened a pull request:
https://github.com/apache/flink/pull/3509
[FLINK-5808] Fix Missing verification for setParallelism and setMaxParallelism
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/aljoscha/flink jira-5808-max-parallelism-verification
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/3509.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 #3509
----
commit 59b049bbad2c889dcb29ffbd900a458580c20728
Author: Aljoscha Krettek <al...@gmail.com>
Date: 2017-03-10T12:30:21Z
[FLINK-5808] Move default parallelism to StreamingJobGraphGenerator
Before, it was set on the ExecutionConfig for some stream execution
environments and later for others. Now, we don't set the default
parallelism on the ExecutionConfig but instead set it at the latest
possible point, in the StreamingJobGraphGenerator.
This also adds tests that verify that we don't set the default
parallelism on the ExecutionConfig.
commit 5527eae6f29ed80baedd1f5feadf3a4e17ac7865
Author: Aljoscha Krettek <al...@gmail.com>
Date: 2017-03-10T13:37:26Z
[FLINK-5808] Move max keygroup constants to ExecutionConfig
We need to have them there if we want to properly test the arguments of
setMaxParallelism() in the ExecutionConfig itself.
commit 096dcca374a052d90bfe09a5a147435f2614aa05
Author: Aljoscha Krettek <al...@gmail.com>
Date: 2017-03-10T13:35:37Z
[FLINK-5808] Add proper checks in setParallelism()/setMaxParallelism()
Before, there where some checks in
StreamExecutionEnvironment.set(Max)Parallelism() but a user would
circumvent these if using the ExecutionConfig directly. Now, all checks
are moved to the ExecutionConfig.
----
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r105614743
--- Diff: flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java ---
@@ -280,13 +289,18 @@ public int getParallelism() {
* @param parallelism The parallelism to use
*/
public ExecutionConfig setParallelism(int parallelism) {
- if (parallelism != PARALLELISM_UNKNOWN) {
- if (parallelism < 1 && parallelism != PARALLELISM_DEFAULT) {
- throw new IllegalArgumentException(
- "Parallelism must be at least one, or ExecutionConfig.PARALLELISM_DEFAULT (use system default).");
- }
- this.parallelism = parallelism;
- }
+ checkArgument(parallelism != PARALLELISM_UNKNOWN, "Cannot specify UNKNOWN_PARALLELISM.");
+ checkArgument(
+ parallelism >= 1 || parallelism == PARALLELISM_DEFAULT,
+ "Parallelism must be at least one, or ExecutionConfig.PARALLELISM_DEFAULT " +
+ "(use system default).");
+ checkArgument(
+ maxParallelism == -1 || parallelism <= maxParallelism,
--- End diff --
Since this basically enforces that you may only call ```setParallelism()``` after you called ```setMaxParallelism()``` how about we merge both methods instead? i.e ```setParallelism(int initialParallelism, int maxParallelism)```.
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by aljoscha <gi...@git.apache.org>.
Github user aljoscha commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r105667466
--- Diff: flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java ---
@@ -280,13 +289,18 @@ public int getParallelism() {
* @param parallelism The parallelism to use
*/
public ExecutionConfig setParallelism(int parallelism) {
- if (parallelism != PARALLELISM_UNKNOWN) {
- if (parallelism < 1 && parallelism != PARALLELISM_DEFAULT) {
- throw new IllegalArgumentException(
- "Parallelism must be at least one, or ExecutionConfig.PARALLELISM_DEFAULT (use system default).");
- }
- this.parallelism = parallelism;
- }
+ checkArgument(parallelism != PARALLELISM_UNKNOWN, "Cannot specify UNKNOWN_PARALLELISM.");
+ checkArgument(
+ parallelism >= 1 || parallelism == PARALLELISM_DEFAULT,
+ "Parallelism must be at least one, or ExecutionConfig.PARALLELISM_DEFAULT " +
+ "(use system default).");
+ checkArgument(
+ maxParallelism == -1 || parallelism <= maxParallelism,
--- End diff --
This verifies that the parallelism is smaller-or-equal the max parallelism, but only if a max parallelism is set. If no max parallelism is set you should be able to set any parallelism (that is > 0).
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by aljoscha <gi...@git.apache.org>.
Github user aljoscha commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r105671778
--- Diff: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamContextEnvironment.java ---
@@ -38,14 +38,10 @@
private final ContextEnvironment ctx;
protected StreamContextEnvironment(ContextEnvironment ctx) {
+ super(GlobalConfiguration.loadConfiguration().getInteger(
--- End diff --
This is not introducing the global configuration call. (Interestingly, this is one of the oldest portions of code in the streaming API: https://github.com/apache/flink/commit/6867f9b#diff-615270fa9777c5c18e374b0269e358e5, more than 2 years old \U0001f609)
I agree that there are some problems in how the streaming execution environments work but I think we cannot easily get rid of that right now. The call graph is roughly `user main() -> StreamExecutionEnvironment.getEnv() -> create context env` so there is nothing on that path that would allow us to get the default parallelism. What we could do is have the Flink client program put the default parallelism in the environment so that we can pick it up here. This also seems highly hacky, though.
I think the solution to this is to remove the default parallelism parameter from the config. It seems kind of magical how that actually ends up in a user program. Both for the batch and streaming APIs.
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r105635537
--- Diff: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamContextEnvironment.java ---
@@ -38,14 +38,10 @@
private final ContextEnvironment ctx;
protected StreamContextEnvironment(ContextEnvironment ctx) {
+ super(GlobalConfiguration.loadConfiguration().getInteger(
--- End diff --
This is bound to cause problems, as it relies on that fact that where ever this is called the proper environment variables are set.
I think we need to get rid of all ad-hoc loading of configuration and not introduce more places.
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r105613941
--- Diff: flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java ---
@@ -83,6 +83,15 @@
*/
public static final int PARALLELISM_UNKNOWN = -2;
+ /**
+ * The default lower bound for max parallelism if nothing was configured by the user. We have this so allow users
--- End diff --
so -> to
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by aljoscha <gi...@git.apache.org>.
Github user aljoscha commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r106040063
--- Diff: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamContextEnvironment.java ---
@@ -38,14 +38,10 @@
private final ContextEnvironment ctx;
protected StreamContextEnvironment(ContextEnvironment ctx) {
+ super(GlobalConfiguration.loadConfiguration().getInteger(
--- End diff --
@StephanEwen ping \U0001f609
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by aljoscha <gi...@git.apache.org>.
Github user aljoscha commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r106125756
--- Diff: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamContextEnvironment.java ---
@@ -38,14 +38,10 @@
private final ContextEnvironment ctx;
protected StreamContextEnvironment(ContextEnvironment ctx) {
+ super(GlobalConfiguration.loadConfiguration().getInteger(
--- End diff --
I had a quick offline chat with @StephanEwen and he agreed that we should address this in a follow-up PR. I created a new Jira issue: https://issues.apache.org/jira/browse/FLINK-6058.
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by aljoscha <gi...@git.apache.org>.
Github user aljoscha commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r105672152
--- Diff: flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java ---
@@ -83,6 +83,15 @@
*/
public static final int PARALLELISM_UNKNOWN = -2;
+ /**
+ * The default lower bound for max parallelism if nothing was configured by the user. We have this so allow users
--- End diff --
Thanks! (I actually just copy/pasted this comment ... \U0001f631 )
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r106141959
--- Diff: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamContextEnvironment.java ---
@@ -38,14 +38,10 @@
private final ContextEnvironment ctx;
protected StreamContextEnvironment(ContextEnvironment ctx) {
+ super(GlobalConfiguration.loadConfiguration().getInteger(
--- End diff --
Yes, thanks!
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by aljoscha <gi...@git.apache.org>.
Github user aljoscha commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r105690923
--- Diff: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamContextEnvironment.java ---
@@ -38,14 +38,10 @@
private final ContextEnvironment ctx;
protected StreamContextEnvironment(ContextEnvironment ctx) {
+ super(GlobalConfiguration.loadConfiguration().getInteger(
--- End diff --
Or we could somehow hand the `Configuration` that the `CliFrontend` loads through to the `StreamingExecutionConfig`. I think that's a bigger, unrelated changed, however.
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:
https://github.com/apache/flink/pull/3509#discussion_r105675052
--- Diff: flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java ---
@@ -280,13 +289,18 @@ public int getParallelism() {
* @param parallelism The parallelism to use
*/
public ExecutionConfig setParallelism(int parallelism) {
- if (parallelism != PARALLELISM_UNKNOWN) {
- if (parallelism < 1 && parallelism != PARALLELISM_DEFAULT) {
- throw new IllegalArgumentException(
- "Parallelism must be at least one, or ExecutionConfig.PARALLELISM_DEFAULT (use system default).");
- }
- this.parallelism = parallelism;
- }
+ checkArgument(parallelism != PARALLELISM_UNKNOWN, "Cannot specify UNKNOWN_PARALLELISM.");
+ checkArgument(
+ parallelism >= 1 || parallelism == PARALLELISM_DEFAULT,
+ "Parallelism must be at least one, or ExecutionConfig.PARALLELISM_DEFAULT " +
+ "(use system default).");
+ checkArgument(
+ maxParallelism == -1 || parallelism <= maxParallelism,
--- End diff --
ah right, i was confused how checkArgument worked.
---
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 #3509: [FLINK-5808] Fix Missing verification for setParal...
Posted by aljoscha <gi...@git.apache.org>.
Github user aljoscha closed the pull request at:
https://github.com/apache/flink/pull/3509
---
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.
---