{"record":{"id":"881eef9198f4c831","repo":"prestodb/presto","slug":"generic-internal-error-881eef","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"cannot create cache directory ","messagePattern":"cannot create cache directory ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"critical","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/FileFragmentResultCacheManager.java","lineNumber":116,"sourceCode":"        this.pagesSerdeFactory = new PagesSerdeFactory(blockEncodingSerde, cacheConfig.getBlockEncodingCompressionCodec());\n        this.fragmentCacheStats = requireNonNull(fragmentCacheStats, \"fragmentCacheStats is null\");\n        this.flushExecutor = requireNonNull(flushExecutor, \"flushExecutor is null\");\n        this.removalExecutor = requireNonNull(removalExecutor, \"removalExecutor is null\");\n        this.cache = CacheBuilder.newBuilder()\n                .maximumSize(cacheConfig.getMaxCachedEntries())\n                .expireAfterAccess(cacheConfig.getCacheTtl().toMillis(), MILLISECONDS)\n                .removalListener(new CacheRemovalListener())\n                .recordStats()\n                .build();\n        this.inputDataStatsEnabled = cacheConfig.isInputDataStatsEnabled();\n\n        File target = Paths.get(baseDirectory.toUri()).toFile();\n        if (!target.exists()) {\n            try {\n                Files.createDirectories(target.toPath());\n            }\n            catch (IOException e) {\n                throw new PrestoException(GENERIC_INTERNAL_ERROR, \"cannot create cache directory \" + target, e);\n            }\n        }\n        else {\n            File[] files = target.listFiles();\n            if (files == null) {\n                return;\n            }\n\n            this.removalExecutor.submit(() -> Arrays.stream(files).forEach(file -> {\n                try {\n                    Files.delete(file.toPath());\n                }\n                catch (IOException e) {\n                    // ignore\n                }\n            }));\n        }\n    }","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/FileFragmentResultCacheManager.java#L98-L134","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Create the directory manually and grant the Presto process user write access: mkdir -p <dir> && chown presto:presto <dir>","Correct fragment-result-cache-base-directory to a valid writable path in the coordinator config","Check mount/disk health (read-only volume, full disk)"],"exampleFix":"// etc/config.properties\n// before: fragment-result-cache-base-directory=/root/fragment-cache\n// after\nfragment-result-cache-base-directory=/var/presto/fragment-cache\n// shell: mkdir -p /var/presto/fragment-cache && chown presto:presto /var/presto/fragment-cache","handlingStrategy":"validation","validationCode":"import java.nio.file.*;\nimport java.nio.file.attribute.*;\nPath dir = Paths.get(cacheBaseDir);\nFile dirFile = dir.toFile();\nif (!dirFile.exists()) {\n    boolean ok = dirFile.mkdirs();\n    if (!ok || !Files.isWritable(dir)) {\n        throw new IllegalStateException(\"cache dir not creatable/writable: \" + dir);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-create fragment-result-cache-base-directory and chown it to the Presto service user","Avoid paths in read-only containers/volumes; mount a writable volume","Verify config in staging with the same user/permissions as production"],"tags":["configuration","filesystem","cache","startup"],"backgroundTag":"cache-directory-not-writable","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}