{"record":{"id":"ea3f2444744988b3","repo":"apache/beam","slug":"encountered-exception-creating-directory-for-heap-dumps","errorCode":null,"errorMessage":"Encountered exception creating directory for heap dumps, disabling heap dumping.","messagePattern":"Encountered exception creating directory for heap dumps, disabling heap dumping\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/MemoryMonitor.java","lineNumber":222,"sourceCode":"    SdkHarnessOptions sdkHarnessOptions = options.as(SdkHarnessOptions.class);\n    @Nullable String uploadFilePath = sdkHarnessOptions.getRemoteHeapDumpLocation();\n    if (uploadFilePath == null) {\n      uploadFilePath = options.getTempLocation();\n    }\n    PortablePipelineOptions portableOptions = options.as(PortablePipelineOptions.class);\n    boolean canDumpHeap = false;\n    File localDumpFolder = getHeapDumpDir();\n    if (portableOptions.getEnableHeapDumps()) {\n      if (uploadFilePath == null) {\n        LOG.warn(\n            \"Heap dumps are requested with --enableHeapDumps but neither --remoteHeapDumpLocation nor \"\n                + \"--tempLocation was provided to specify where to copy captured heap dumps to.\");\n      } else {\n        try {\n          Files.createDirectories(localDumpFolder.toPath());\n          canDumpHeap = true;\n        } catch (Exception e) {\n          LOG.warn(\n              \"Encountered exception creating directory for heap dumps, disabling heap dumping.\",\n              e);\n        }\n      }\n    }\n\n    double gcThrashingPercentagePerPeriod = sdkHarnessOptions.getGCThrashingPercentagePerPeriod();\n    return new MemoryMonitor(\n        new SystemGCStatsProvider(),\n        DEFAULT_SLEEP_TIME_MILLIS,\n        DEFAULT_SHUT_DOWN_AFTER_NUM_GCTHRASHING,\n        canDumpHeap,\n        gcThrashingPercentagePerPeriod,\n        uploadFilePath,\n        getHeapDumpDir(),\n        sdkHarnessOptions.getGzipCompressHeapDumps());\n  }\n","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/MemoryMonitor.java#L204-L240","documentation":"This is a warning logged by Beam's fn-harness MemoryMonitor when it fails to create the local directory used to store heap dumps (Files.createDirectories on localDumpFolder throws). When this happens the monitor disables heap dumping entirely (canDumpHeap = false), so on OOM no heap dump will be captured. The message itself wraps the underlying filesystem exception.","triggerScenarios":"MemoryMonitor.fromOptions is invoked with a heap dump folder (heapDumpFolder option) whose path cannot be created: permission denied, path exists as a regular file, invalid path characters, read-only filesystem, or a security manager blocking file creation.","commonSituations":"Container images running as non-root with an unwritable dump path (e.g. /tmp not writable), users pointing the dump folder at a mounted volume owned by another UID, or a typo making the path resolve to an existing file.","solutions":["Verify the configured heap dump folder path does not already exist as a regular file and its parent directories are writable by the harness process user.","Point the heap dump folder to a writable location such as /tmp/heapdumps or a writable mounted volume.","Check the wrapped exception in the log (cause) for the exact filesystem error (access denied vs other) and fix permissions (chmod/chown) accordingly.","If heap dumping is not needed, this warning can be ignored; the pipeline continues without heap dump capture."],"exampleFix":"// before (path is a file or unwritable)\n--heapDumpFolder=/var/log\n// after (fresh writable directory)\n--heapDumpFolder=/tmp/heapdumps","handlingStrategy":"validation","validationCode":"File dir = new File(heapDumpFolder);\nif (dir.exists() && !dir.isDirectory()) throw new IllegalStateException(heapDumpFolder + \" is not a directory\");\nif (!dir.exists() && !dir.mkdirs() && !dir.setWritable(true)) throw new IllegalStateException(\"cannot create/write \" + heapDumpFolder);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose a heap dump folder inside a writable location (/tmp) for containerized workers","Do not point the folder at an existing regular file","Run the harness process with a UID that owns or can write the dump directory"],"tags":["java","apache-beam","heap-dump","filesystem"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}