{"record":{"id":"112a0522f81c1055","repo":"apache/druid","slug":"error-while-reading-distribution-for-interval-s","errorCode":null,"errorMessage":"Error while reading distribution for interval [%s], task [%s]","messagePattern":"Error while reading distribution for interval \\[(.+?)\\], task \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/PartialDimensionDistributionParallelIndexTaskRunner.java","lineNumber":226,"sourceCode":"    catch (IOException e) {\n      String errorMsg = StringUtils.format(\n          \"Exception while writing distribution file for interval [%s], task [%s]\",\n          interval,\n          subTaskId\n      );\n      stopGracefully(errorMsg);\n      throw new ISE(e, errorMsg);\n    }\n  }\n\n  private StringDistribution readDistributionFromFile(File intervalDir, String subTaskId)\n  {\n    try {\n      File distributionJsonFile = getDistributionJsonFile(intervalDir, subTaskId);\n      return getToolbox().getJsonMapper().readValue(distributionJsonFile, StringDistribution.class);\n    }\n    catch (IOException e) {\n      throw new ISE(e, \"Error while reading distribution for interval [%s], task [%s]\",\n                    intervalDir.getName(), subTaskId\n      );\n    }\n  }\n\n  private File getIntervalDistributionDir(Interval interval)\n  {\n    return new File(tempDistributionsDir, toIntervalString(interval));\n  }\n\n  private File getDistributionJsonFile(File intervalDir, String subTaskId)\n  {\n    return new File(intervalDir, subTaskId);\n  }\n\n  /**\n   * Waits for distributions from pending reports (if any) to be extracted.\n   */","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/PartialDimensionDistributionParallelIndexTaskRunner.java#L208-L244","documentation":"After sub-tasks report distributions, the runner reads each persisted StringDistribution JSON file back from the task temp dir. An IOException during deserialization is wrapped in an ISE identifying the interval directory and sub-task id.","triggerScenarios":"The distribution JSON file is missing, truncated, or unreadable when readDistributionFromFile() executes - e.g. the file was deleted between write and read, or disk corruption occurred.","commonSituations":"Task temp dir partially cleaned by external jobs; node crash/restart leaving truncated files; NFS/ephemeral-storage flakiness on Middle Managers.","solutions":["Retry the ingestion task; the distribution files are transient and rebuilt on rerun.","Inspect the wrapped IOException to see whether the file is missing vs unreadable, and check the task temp dir contents.","Prevent external cleanup of Druid task temp dirs (tmpwatch/systemd-tmpfiles configs).","Check worker disk health and filesystem errors in system logs."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (IllegalStateException e) { if (e.getMessage().contains(\"Error while reading distribution\")) { retryTask(); /* files are transient and rebuilt */ } else { throw e; } }","preventionTips":["Keep Druid task temp dirs on reliable local storage, not flaky NFS.","Prevent external processes from deleting files under the task base dir while tasks run.","Check worker filesystem health if this recurs."],"tags":["druid","io","serialization","batch-ingestion"],"backgroundTag":"file-read-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}