{"record":{"id":"eb834137d7e7db68","repo":"apache/dolphinscheduler","slug":"generate-flink-sql-script-error","errorCode":null,"errorMessage":"Generate flink SQL script error","messagePattern":"Generate flink SQL script error","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FileUtils.java","lineNumber":95,"sourceCode":"\n        Set<PosixFilePermission> perms = PosixFilePermissions.fromString(RWXR_XR_X);\n        FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);\n        try {\n            if (SystemUtils.IS_OS_WINDOWS) {\n                Files.createFile(path);\n            } else {\n                if (!scriptFile.getParentFile().exists()) {\n                    scriptFile.getParentFile().mkdirs();\n                }\n                Files.createFile(path, attr);\n            }\n\n            if (StringUtils.isNotEmpty(script)) {\n                String replacedScript = script.replaceAll(\"\\\\r\\\\n\", \"\\n\");\n                FileUtils.writeStringToFile(scriptFile, replacedScript, StandardOpenOption.APPEND);\n            }\n        } catch (IOException e) {\n            throw new RuntimeException(\"Generate flink SQL script error\", e);\n        }\n    }\n\n    private static void writeStringToFile(File file, String content, StandardOpenOption standardOpenOption) {\n        try {\n            log.info(\"Writing content: \" + content);\n            log.info(\"To file: \" + file.getAbsolutePath());\n            Files.write(file.getAbsoluteFile().toPath(), content.getBytes(StandardCharsets.UTF_8), standardOpenOption);\n        } catch (IOException e) {\n            throw new RuntimeException(\"Error writing file: \" + file.getAbsoluteFile(), e);\n        }\n    }\n}\n","sourceCodeStart":77,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FileUtils.java#L77-L109","documentation":"After creating the script file, writeScriptFile() appends the (CRLF-normalized) Flink SQL script via a private writeStringToFile. Any IOException during generation/appending is rethrown as RuntimeException('Generate flink SQL script error'). It means the executable SQL script could not be materialized on disk.","triggerScenarios":"IOException while appending the script content: disk full, permission denied on the created file, or failure inside the nested writeStringToFile call within the try block.","commonSituations":"Full disk on worker; tenant directory permissions changed; extremely large SQL scripts hitting disk quotas; concurrent tasks colliding on the same temp path.","solutions":["Check worker disk space (df -h) and inode usage","Verify the task's temp/execution directory is writable by the worker user","Retry the task; if a partial file exists, delete it first","Enable finer logging of the failing path from the wrapped cause"],"exampleFix":"// before\nthrow new RuntimeException(\"Generate flink SQL script error\", e);\n// after\nthrow new RuntimeException(\"Generate flink SQL script error for file \" + scriptFile.getAbsolutePath(), e);","handlingStrategy":"try-catch","validationCode":"Path dir = Paths.get(scriptFileFullPath).getParent();\nif (!Files.isWritable(dir)) throw new IllegalStateException(\"script dir not writable: \" + dir);\nif (dir.getFileStore().getUsableSpace() < 10_000_000) throw new IllegalStateException(\"low disk space\");","typeGuard":null,"tryCatchPattern":"try {\n    task.handle(null);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"Generate flink SQL script error\")) {\n        // check wrapped cause: AccessDenied vs NoSpaceLeft\n        log.error(\"script generation failed: {}\", e.getCause(), e);\n    }\n    throw e;\n}","preventionTips":["Monitor worker disk space and quotas","Keep unique temp paths per task execution to avoid collisions","Ensure the worker user owns the tenant execution directory","Delete partial script files before retrying"],"tags":["flink","file-io","sql-script","ioexception"],"backgroundTag":"file-write-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}