{"record":{"id":"8711cb877b27bdf2","repo":"apache/druid","slug":"error-while-cleaning-up-temporary-files-at-path-s","errorCode":null,"errorMessage":"Error while cleaning up temporary files at path[%s]. Skipping.","messagePattern":"Error while cleaning up temporary files at path\\[(.+?)\\]\\. Skipping\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerImpl.java","lineNumber":1984,"sourceCode":"\n  /**\n   * Clean up durable storage, if used for stage output.\n   * <p>\n   * Note that this is only called by the controller task itself. It isn't called automatically by anything in\n   * particular if the controller fails early without being able to run its cleanup routines. This can cause files\n   * to be left in durable storage beyond their useful life.\n   */\n  private void cleanUpDurableStorageIfNeeded()\n  {\n    if (queryKernelConfig != null && queryKernelConfig.isDurableStorage()) {\n      final String controllerDirName = DurableStorageUtils.getControllerDirectory(queryId());\n      try {\n        // Delete all temporary files as a failsafe\n        MSQTasks.makeStorageConnector(context.injector()).deleteRecursively(controllerDirName);\n      }\n      catch (Exception e) {\n        // If an error is thrown while cleaning up a file, log it and try to continue with the cleanup\n        log.warn(e, \"Error while cleaning up temporary files at path[%s]. Skipping.\", controllerDirName);\n      }\n    }\n  }\n\n  private static String getDataSourceForIngestion(final MSQSpec querySpec)\n  {\n    return ((DataSourceMSQDestination) querySpec.getDestination()).getDataSource();\n  }\n\n  /**\n   * Compute shard columns for {@link DimensionRangeShardSpec}. Returns an empty list if range-based sharding\n   * is not applicable.\n   *\n   * @return pair of shard columns and commentary\n   */\n  private static Pair<List<String>, String> computeShardColumns(\n      final RowSignature signature,\n      final ClusterBy clusterBy,","sourceCodeStart":1966,"sourceCodeEnd":2002,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerImpl.java#L1966-L2002","documentation":"At the end of a MSQ controller run, ControllerImpl deletes the controller's temporary directory through the storage connector as a failsafe cleanup. If deleteRecursively throws, the controller logs 'Error while cleaning up temporary files at path[%s]. Skipping.' and continues — cleanup errors never fail the query.","triggerScenarios":"The final cleanup call MSQTasks.makeStorageConnector(context.injector()).deleteRecursively(controllerDirName) throws, e.g. due to local disk errors, permissions on the job temp directory, or storage connector (S3/HDFS/local) transient failures.","commonSituations":"Permission problems on druid.indexer.task.baseTaskDir, disk-full or NFS/HDFS flakiness, or cloud storage throttling (S3 503s) during recursive deletion; leftover temp files may accumulate on the affected storage.","solutions":["Check the attached exception and manually delete the reported controllerDirName path if it remains.","Verify permissions and free space on the base task directory / storage location used by the MSQ storage connector.","Retry or rely on periodic garbage collection (e.g. druid-cleaner for the local task dir) to remove stale temporary files."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  connector.deleteRecursively(dirName);\n} catch (Exception e) {\n  log.warn(e, \"Temp cleanup failed for %s; schedule manual/GC removal\", dirName);\n}","preventionTips":["Ensure correct permissions and free space on the base task directory.","Enable/verify the Druid cleaner job to garbage-collect leftover temp dirs.","Watch cloud storage rate limits (S3 503s) during recursive deletes."],"tags":["druid","msq","cleanup","temporary-files","storage"],"backgroundTag":"file-cleanup-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}