apache/dolphinscheduler · error · RuntimeException
Generate flink SQL script error
Error message
Generate flink SQL script error
What it means
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.
Source
Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FileUtils.java:95
Set<PosixFilePermission> perms = PosixFilePermissions.fromString(RWXR_XR_X);
FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
try {
if (SystemUtils.IS_OS_WINDOWS) {
Files.createFile(path);
} else {
if (!scriptFile.getParentFile().exists()) {
scriptFile.getParentFile().mkdirs();
}
Files.createFile(path, attr);
}
if (StringUtils.isNotEmpty(script)) {
String replacedScript = script.replaceAll("\\r\\n", "\n");
FileUtils.writeStringToFile(scriptFile, replacedScript, StandardOpenOption.APPEND);
}
} catch (IOException e) {
throw new RuntimeException("Generate flink SQL script error", e);
}
}
private static void writeStringToFile(File file, String content, StandardOpenOption standardOpenOption) {
try {
log.info("Writing content: " + content);
log.info("To file: " + file.getAbsolutePath());
Files.write(file.getAbsoluteFile().toPath(), content.getBytes(StandardCharsets.UTF_8), standardOpenOption);
} catch (IOException e) {
throw new RuntimeException("Error writing file: " + file.getAbsoluteFile(), e);
}
}
}
View on GitHub (pinned to 02eac45a1b)
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
Example fix
// before
throw new RuntimeException("Generate flink SQL script error", e);
// after
throw new RuntimeException("Generate flink SQL script error for file " + scriptFile.getAbsolutePath(), e); Defensive patterns
Strategy: try-catch
Validate before calling
Path dir = Paths.get(scriptFileFullPath).getParent();
if (!Files.isWritable(dir)) throw new IllegalStateException("script dir not writable: " + dir);
if (dir.getFileStore().getUsableSpace() < 10_000_000) throw new IllegalStateException("low disk space"); Try / catch
try {
task.handle(null);
} catch (RuntimeException e) {
if (e.getMessage().contains("Generate flink SQL script error")) {
// check wrapped cause: AccessDenied vs NoSpaceLeft
log.error("script generation failed: {}", e.getCause(), e);
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Full disk on worker; tenant directory permissions changed; extremely large SQL scripts hitting disk quotas; concurrent tasks colliding on the same temp path.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Error writing file:
- cancel application error
- Flink Script file exists in path: %s before creation and can
- Calculate checksum error.
- Error reading file: ${filePath}
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/eb834137d7e7db68.
Report an issue: GitHub.