{"record":{"id":"22fcbe4e4fdaed66","repo":"apache/druid","slug":"failed-to-create-factory-json-for-tombstone-in-dir","errorCode":null,"errorMessage":"Failed to create factory.json for tombstone in dir [%s]","messagePattern":"Failed to create factory\\.json for tombstone in dir \\[(.+?)\\]","errorType":"exception","errorClass":"SegmentLoadingException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/loading/TombstoneLoadSpec.java","lineNumber":41,"sourceCode":"import com.google.common.annotations.VisibleForTesting;\nimport com.google.common.io.Files;\nimport org.apache.druid.initialization.TombstoneDataStorageModule;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.nio.charset.StandardCharsets;\n\n@JsonTypeName(TombstoneDataStorageModule.SCHEME)\npublic class TombstoneLoadSpec implements LoadSpec\n{\n  @Override\n  public LoadSpecResult loadSegment(File destDir) throws SegmentLoadingException\n  {\n    try {\n      return new LoadSpecResult(writeFactoryFile(destDir));\n    }\n    catch (IOException e) {\n      throw new SegmentLoadingException(\n          \"Failed to create factory.json for tombstone in dir [%s]\",\n          destDir.getAbsolutePath()\n      );\n\n    }\n  }\n\n  @VisibleForTesting\n  public static int writeFactoryFile(File destDir) throws IOException\n  {\n    final String factoryJSONString = \"{\\\"type\\\":\\\"tombstoneSegmentFactory\\\"}\";\n    final File factoryJson = new File(destDir, \"factory.json\");\n    factoryJson.createNewFile();\n    Files.write(factoryJSONString.getBytes(StandardCharsets.UTF_8), factoryJson);\n    return factoryJSONString.length();\n  }\n}\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/loading/TombstoneLoadSpec.java#L23-L59","documentation":"TombstoneLoadSpec.loadSegment writes a factory.json marker file into the destination directory so the segment loader recognizes the tombstone; if any IOException occurs during that write it fails with SegmentLoadingException naming the directory. It indicates the tombstone could not be materialized locally.","triggerScenarios":"loadSegment(destDir) called when the destination dir is not writable, does not exist, is full, or writeFactoryFile fails with an IOException.","commonSituations":"Segment cache directory owned by another user; read-only filesystem or full disk; race where the target directory was removed while loading tombstones after segment deletion.","solutions":["Ensure destDir exists and the Druid process has write permission to it","Free disk space if the volume is full","Recreate the segment cache directory and reload","Check the wrapped IOException/cause for the underlying filesystem error"],"exampleFix":"// before\n// writing into a read-only dir\nFile destDir = new File(\"/var/druid/segment-cache/seg\");\n// after\nif (!destDir.canWrite()) { logger.error(\"Dir not writable: %s\", destDir); throw ... }\nresult = tombstoneLoadSpec.loadSegment(destDir);","handlingStrategy":"try-catch","validationCode":"if (!destDir.exists() && !destDir.mkdirs()) throw new IOException(\"cannot create \" + destDir); if (!destDir.canWrite()) throw new IOException(\"not writable: \" + destDir);","typeGuard":"boolean writableDir(File d) { return d != null && d.isDirectory() && d.canWrite(); }","tryCatchPattern":"try { return loadSpec.loadSegment(destDir); } catch (SegmentLoadingException e) { log.error(e, \"Tombstone load failed in %s\", destDir); FileUtils.deleteQuietly(destDir); throw e; }","preventionTips":["Ensure the druid process user owns the segment cache directory","Monitor disk free space on cache volumes","Avoid concurrent tombstone loads into the same directory"],"tags":["tombstone","file-write","segment-loading"],"backgroundTag":"file-write-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}