{"record":{"id":"53c787c91fa33cc0","repo":"apache/druid","slug":"failed-to-remove-output-directory-s-for-segment","errorCode":null,"errorMessage":"Failed to remove output directory [%s] for segment pulled from [%s]","messagePattern":"Failed to remove output directory \\[(.+?)\\] for segment pulled from \\[(.+?)\\]","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"extensions-contrib/aliyun-oss-extensions/src/main/java/org/apache/druid/storage/aliyun/OssDataSegmentPuller.java","lineNumber":129,"sourceCode":"        log.info(\"Loaded %d bytes from [%s] to [%s]\", result.size(), ossCoords.toString(), outDir.getAbsolutePath());\n        return result;\n      }\n      if (CompressionUtils.isGz(ossCoords.getPath())) {\n        final String fname = Files.getNameWithoutExtension(uri.getPath());\n        final File outFile = new File(outDir, fname);\n\n        final FileUtils.FileCopyResult result = CompressionUtils.gunzip(byteSource, outFile, OssUtils.RETRYABLE);\n        log.info(\"Loaded %d bytes from [%s] to [%s]\", result.size(), ossCoords.toString(), outFile.getAbsolutePath());\n        return result;\n      }\n      throw new IAE(\"Do not know how to load file type at [%s]\", uri.toString());\n    }\n    catch (Exception e) {\n      try {\n        FileUtils.deleteDirectory(outDir);\n      }\n      catch (IOException ioe) {\n        log.warn(\n            ioe,\n            \"Failed to remove output directory [%s] for segment pulled from [%s]\",\n            outDir.getAbsolutePath(),\n            ossCoords.toString()\n        );\n      }\n      throw new SegmentLoadingException(e, e.getMessage());\n    }\n  }\n\n  @Override\n  public InputStream getInputStream(URI uri) throws IOException\n  {\n    try {\n      return buildFileObject(uri).openInputStream();\n    }\n    catch (OSSException e) {\n      throw new IOE(e, \"Could not load URI [%s]\", uri);","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/aliyun-oss-extensions/src/main/java/org/apache/druid/storage/aliyun/OssDataSegmentPuller.java#L111-L147","documentation":"OssDataSegmentPuller.getSegmentFiles() downloads a segment from Aliyun OSS into a temp output directory; if the download/extract fails it tries to delete that directory, and logs this warning when the deletion itself throws IOException. The original SegmentLoadingException is still thrown — this warning only indicates leftover temp files on disk.","triggerScenarios":"A segment pull from OSS fails (missing object, 404, credentials error, corrupt zip) AND FileUtils.deleteDirectory(outDir) cannot delete the temp dir (locked files, permission issues, NFS staleness).","commonSituations":"Wrong OSS bucket/path config or expired STS credentials causing pull failures; read-only or full disk; segment cache dir on NFS where unlink fails; concurrent processes holding files in outDir.","solutions":["Fix the root cause of the pull failure (check OSS object exists, credentials, endpoint config)","Manually delete the leftover temp directory under the druid segment cache/tmp location","Check filesystem permissions and free space for the cache directory","Avoid NFS for segment cache dirs if deletion errors persist"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight OSS access before segment load\n OSSObject obj = ossClient.getObject(bucket, key); // throws on missing object/bad creds","typeGuard":null,"tryCatchPattern":"try {\n  Map<String,File> files = puller.getSegmentFiles(segment);\n} catch (SegmentLoadingException e) {\n  log.warn(e, \"Segment pull from OSS failed; leftover temp dir possible\");\n}","preventionTips":["Validate OSS credentials/bucket/path config before deployment","Use local (non-NFS) disk for the segment cache directory","Monitor disk space and permissions for the druid segment cache","Alert on this warning since it implies a prior pull failure too"],"tags":["oss","aliyun","segment-loading","filesystem-cleanup"],"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"}