apache/shardingsphere · error · FileIOException
30020
30020
Error message
File access failed, file is: %s
What it means
FileIOException (error code 30020) thrown by ExportUtils.exportToFile when writing exported data to the given path fails: parent directories are created if missing, then the bytes are written via Files.newOutputStream; any IOException (permission denied, non-directory parent, disk full) is caught and converted to FileIOException naming the file.
Source
Thrown at proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/ExportUtils.java:53
/**
* Export configuration data to specified file.
*
* @param filePath file path
* @param exportedData exported configuration data
* @throws FileIOException file IO exception
*/
@SuppressWarnings("ResultOfMethodCallIgnored")
public static void exportToFile(final String filePath, final String exportedData) {
File file = new File(filePath);
if (!file.exists() && null != file.getParentFile()) {
file.getParentFile().mkdirs();
}
try (OutputStream output = Files.newOutputStream(Paths.get(file.toURI()))) {
output.write(exportedData.getBytes());
output.flush();
} catch (final IOException ignore) {
throw new FileIOException(file);
}
}
}
View on GitHub (pinned to e952770a21)
Solutions
- Choose an export directory that exists and is writable by the proxy process (pre-create it and chown/chmod appropriately)
- In containers, export to a mounted writable volume, not the image root
- Check disk space on the proxy host and retry after freeing space
Example fix
-- before EXPORT DATABASE CONFIGURATION TO '/etc/shardingsphere/export.yaml'; -- after EXPORT DATABASE CONFIGURATION TO '/opt/shardingsphere/export/export.yaml';
Defensive patterns
Strategy: validation
Validate before calling
File dir = targetFile.getParentFile();
if (dir == null || (!dir.exists() && !dir.mkdirs()) || !dir.canWrite()) {
throw new IllegalArgumentException("Export directory not writable: " + dir);
}
if (targetFile.exists() && targetFile.isDirectory()) {
throw new IllegalArgumentException("Export target is a directory: " + targetFile);
} Try / catch
try {
ExportUtils.exportToFile(path, data);
} catch (final FileIOException ex) {
// surface the path; switch to a writable directory and retry
} Prevention
- Pre-create and chmod the export directory for the proxy user
- In containers, always export to a mounted volume; check disk space before large exports
When it happens
Trigger: EXPORT operations (e.g. EXPORT DATABASE CONFIGURATION / metadata export) targeting a path where mkdirs() failed or the open/write fails: unwritable directory, path is an existing directory, read-only filesystem, or no space left.
Common situations: Exporting to /tmp or a config dir not writable by the proxy user; running the proxy in a container with a read-only root filesystem; passing a path whose parent exists as a regular file; disk exhaustion on the proxy host.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/254f4c742c2eeb8e.
Report an issue: GitHub.