prestodb/presto · error · RuntimeException
Could not save table statistics data
Error message
Could not save table statistics data
What it means
TableStatisticsDataRepository.writeStatistics serializes TableStatisticsData to a JSON file in the statistics directory. Any IOException during write or trailing-newline append is wrapped in a RuntimeException 'Could not save table statistics data'. It indicates the connector could not persist statistics to disk.
Source
Thrown at presto-tpcds/src/main/java/com/facebook/presto/tpcds/statistics/TableStatisticsDataRepository.java:68
{
return schemaName.trim()
.replaceAll("\\.0+$", "");
}
private void writeStatistics(Path path, TableStatisticsData tableStatisticsData)
{
File file = path.toFile();
file.getParentFile().mkdirs();
try {
objectMapper
.writerWithDefaultPrettyPrinter()
.writeValue(file, tableStatisticsData);
try (BufferedWriter fileWriter = Files.newBufferedWriter(file.toPath(), StandardOpenOption.CREATE, StandardOpenOption.WRITE)) {
fileWriter.append('\n');
}
}
catch (IOException e) {
throw new RuntimeException("Could not save table statistics data", e);
}
}
public Optional<TableStatisticsData> load(String schemaName, Table table)
{
schemaName = normalizeSchemaName(schemaName);
String filename = table.getName();
String resourcePath = "/tpcds/statistics/" + schemaName + "/" + filename + ".json";
return readStatistics(resourcePath);
}
private Optional<TableStatisticsData> readStatistics(String resourcePath)
{
URL resource = getClass().getResource(resourcePath);
if (resource == null) {
return Optional.empty();
}
try {View on GitHub (pinned to 55bb57d202)
Solutions
- Ensure the configured statistics directory exists and is writable by the Presto process
- Check disk space on the node holding the statistics files
- Fix filesystem permissions (chown/chmod) on the stats directory
- Re-run the query / ANALYZE after fixing storage; statistics persistence failure is not fatal to query results
Example fix
// before mkdir /data/tpcds-stats # owned by root // after mkdir -p /data/tpcds-stats && chown presto:presto /data/tpcds-stats
Defensive patterns
Strategy: try-catch
Validate before calling
java.nio.file.Path dir = Path.of(statsDir);
if (!Files.isDirectory(dir) || !Files.isWritable(dir)) {
throw new IllegalStateException("Statistics dir missing or not writable: " + statsDir);
}
if (dir.toFile().getUsableSpace() < 1_000_000) throw new IllegalStateException("Low disk space for stats"); Try / catch
try {
repository.save(schemaName, table, stats);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().equals("Could not save table statistics data")) {
logger.warn(e, "Stats persistence failed; continuing without persisted stats");
} else { throw e; }
} Prevention
- Provision the stats directory with correct ownership (presto user) before startup
- Monitor disk space on nodes hosting the stats directory
- Verify after config changes that the configured stats path still exists
When it happens
Trigger: Calling save(schemaName, table, statistics) when the target file cannot be written: stats directory missing, permission denied, disk full, or the file is a directory.
Common situations: Read-only mount or wrong permissions on the tpcds statistics directory; disk full on the coordinator node; statistics directory deleted while the catalog is running.
Related errors
- ICEBERG_FILESYSTEM_ERROR
- Could not save table statistics data
- HIVE_FILESYSTEM_ERROR
- HIVE_FILESYSTEM_ERROR
- HIVE_FILESYSTEM_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/73b687cd91b85359.
Report an issue: GitHub.