{"record":{"id":"2c61df3398a9a815","repo":"apache/flink","slug":"parallelism-must-be-at-least-one-or-executionconf","errorCode":null,"errorMessage":"Parallelism must be at least one, or ExecutionConfig.PARALLELISM_DEFAULT (use system default).","messagePattern":"Parallelism must be at least one, or ExecutionConfig\\.PARALLELISM_DEFAULT \\(use system default\\)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java","lineNumber":290,"sourceCode":"        return configuration.get(CoreOptions.DEFAULT_PARALLELISM);\n    }\n\n    /**\n     * Sets the parallelism for operations executed through this environment. Setting a parallelism\n     * of x here will cause all operators (such as join, map, reduce) to run with x parallel\n     * instances.\n     *\n     * <p>This method overrides the default parallelism for this environment. The local execution\n     * environment uses by default a value equal to the number of hardware contexts (CPU cores /\n     * threads). When executing the program via the command line client from a JAR file, the default\n     * parallelism is the one configured for that setup.\n     *\n     * @param parallelism The parallelism to use\n     */\n    public ExecutionConfig setParallelism(int parallelism) {\n        if (parallelism != PARALLELISM_UNKNOWN) {\n            if (parallelism < 1 && parallelism != PARALLELISM_DEFAULT) {\n                throw new IllegalArgumentException(\n                        \"Parallelism must be at least one, or ExecutionConfig.PARALLELISM_DEFAULT (use system default).\");\n            }\n            configuration.set(CoreOptions.DEFAULT_PARALLELISM, parallelism);\n        }\n        return this;\n    }\n\n    @Internal\n    public void resetParallelism() {\n        configuration.removeConfig(CoreOptions.DEFAULT_PARALLELISM);\n    }\n\n    /**\n     * Gets the maximum degree of parallelism defined for the program.\n     *\n     * <p>The maximum degree of parallelism specifies the upper limit for dynamic scaling. It also\n     * defines the number of key groups used for partitioned state.\n     *","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java#L272-L308","documentation":"Thrown by ExecutionConfig.setParallelism when the value is neither PARALLELISM_UNKNOWN (-1, meaning leave unchanged) nor a valid positive number, nor PARALLELISM_DEFAULT (-1 used as 'use system default'). Any value < 1 that is not the DEFAULT sentinel is rejected because parallelism must be at least 1 task. The guard prevents nonsensical zero or negative parallelism that would break scheduling.","triggerScenarios":"Calling executionConfig.setParallelism(0) or any negative value other than the sentinels; passing a parsed config value of 0 when an option defaulted unexpectedly; computing parallelism as max(a,b) where both were 0.","commonSituations":"Reading parallelism from a Configuration/CoreOptions key that returned 0; arithmetic on CPU counts that underflowed; users misreading PARALLELISM_DEFAULT semantics.","solutions":["If you mean 'use the system/cl default', pass ExecutionConfig.PARALLELISM_DEFAULT rather than 0.","Compute parallelism defensively: int p = Math.max(1, requested) before calling setParallelism, or pass PARALLELISM_UNKNOWN to leave it unset.","Validate config values at the boundary (CLI parser, config loader) so 0 never reaches setParallelism."],"exampleFix":"// before\nexecutionConfig.setParallelism(configured);\n// after\nif (configured <= 0) {\n    executionConfig.setParallelism(ExecutionConfig.PARALLELISM_DEFAULT);\n} else {\n    executionConfig.setParallelism(configured);\n}","handlingStrategy":"validation","validationCode":"int p = (configured == ExecutionConfig.PARALLELISM_UNKNOWN\n          || configured == ExecutionConfig.PARALLELISM_DEFAULT)\n        ? configured\n        : Math.max(1, configured);\nexecutionConfig.setParallelism(p);","typeGuard":"public static boolean isValidParallelism(int p) {\n    return p == ExecutionConfig.PARALLELISM_UNKNOWN\n        || p == ExecutionConfig.PARALLELISM_DEFAULT\n        || p >= 1;\n}","tryCatchPattern":null,"preventionTips":["Validate config-derived parallelism at load time, not at setParallelism.","Use PARALLELISM_DEFAULT intentionally to mean 'system default'.","Default unknown/unset to PARALLELISM_UNKNOWN rather than 0."],"tags":["parallelism","execution-config","validation","config"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}