prestodb/presto · critical · PrestoException

GENERIC_INTERNAL_ERROR

GENERIC_INTERNAL_ERROR

Error message

cannot create cache directory 

What it means

FileFragmentResultCacheManager's constructor ensures the configured base directory for the fragment result cache exists by calling Files.createDirectories. If the directory cannot be created due to an IOException (permissions, read-only filesystem, invalid path), it throws GENERIC_INTERNAL_ERROR wrapping the cause.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/FileFragmentResultCacheManager.java:116

        this.pagesSerdeFactory = new PagesSerdeFactory(blockEncodingSerde, cacheConfig.getBlockEncodingCompressionCodec());
        this.fragmentCacheStats = requireNonNull(fragmentCacheStats, "fragmentCacheStats is null");
        this.flushExecutor = requireNonNull(flushExecutor, "flushExecutor is null");
        this.removalExecutor = requireNonNull(removalExecutor, "removalExecutor is null");
        this.cache = CacheBuilder.newBuilder()
                .maximumSize(cacheConfig.getMaxCachedEntries())
                .expireAfterAccess(cacheConfig.getCacheTtl().toMillis(), MILLISECONDS)
                .removalListener(new CacheRemovalListener())
                .recordStats()
                .build();
        this.inputDataStatsEnabled = cacheConfig.isInputDataStatsEnabled();

        File target = Paths.get(baseDirectory.toUri()).toFile();
        if (!target.exists()) {
            try {
                Files.createDirectories(target.toPath());
            }
            catch (IOException e) {
                throw new PrestoException(GENERIC_INTERNAL_ERROR, "cannot create cache directory " + target, e);
            }
        }
        else {
            File[] files = target.listFiles();
            if (files == null) {
                return;
            }

            this.removalExecutor.submit(() -> Arrays.stream(files).forEach(file -> {
                try {
                    Files.delete(file.toPath());
                }
                catch (IOException e) {
                    // ignore
                }
            }));
        }
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Create the directory manually and grant the Presto process user write access: mkdir -p <dir> && chown presto:presto <dir>
  2. Correct fragment-result-cache-base-directory to a valid writable path in the coordinator config
  3. Check mount/disk health (read-only volume, full disk)

Example fix

// etc/config.properties
// before: fragment-result-cache-base-directory=/root/fragment-cache
// after
fragment-result-cache-base-directory=/var/presto/fragment-cache
// shell: mkdir -p /var/presto/fragment-cache && chown presto:presto /var/presto/fragment-cache
Defensive patterns

Strategy: validation

Validate before calling

import java.nio.file.*;
import java.nio.file.attribute.*;
Path dir = Paths.get(cacheBaseDir);
File dirFile = dir.toFile();
if (!dirFile.exists()) {
    boolean ok = dirFile.mkdirs();
    if (!ok || !Files.isWritable(dir)) {
        throw new IllegalStateException("cache dir not creatable/writable: " + dir);
    }
}

Prevention

When it happens

Trigger: Server startup with fragment-result-cache-enabled=true where the configured base directory does not exist and cannot be created (bad path, no write permission, disk issue).

Common situations: Misconfigured fragment-result-cache-base-directory pointing to a path owned by another user, a non-writable volume, or a placeholder path in config templates.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/881eef9198f4c831. Report an issue: GitHub.