{"record":{"id":"117ae42ed0d2a94f","repo":"apache/druid","slug":"failed-to-rewrite-info-file-for-segment-s-while","errorCode":null,"errorMessage":"Failed to rewrite info file for segment[%s] while releasing partial-load rule[fingerprint=%s]","messagePattern":"Failed to rewrite info file for segment\\[(.+?)\\] while releasing partial-load rule\\[fingerprint=(.+?)\\]","errorType":"exception","errorClass":"SegmentLoadingException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java","lineNumber":1630,"sourceCode":"   * clears the rule and removes the info file, so there is no stale rule for a restart to reinstate. Leaving the rule\n   * applied and carrying on is not an option, because an unwrapped request announces as a full load either way, so the\n   * coordinator would record a replica with no profile and never ask again.\n   * <p>\n   * Callers must hold this segment's {@link #lock(DataSegment)}, which is the external lock that\n   * {@link PartialSegmentMetadataCacheEntry#clearRule} requires to be serialized against\n   * {@link PartialSegmentMetadataCacheEntry#applyRule}.\n   */\n  private void releaseRuleForFullLoad(DataSegment dataSegment, PartialSegmentMetadataCacheEntry partial)\n      throws SegmentLoadingException\n  {\n    // Snapshot both before clearRule zeroes out the rule state so the log can describe what was released.\n    final String priorFingerprint = partial.getRuleFingerprint();\n    final long priorRealizedBytes = partial.getRealizedBytes();\n    try {\n      rewriteInfoFile(dataSegment);\n    }\n    catch (IOException e) {\n      throw new SegmentLoadingException(\n          e,\n          \"Failed to rewrite info file for segment[%s] while releasing partial-load rule[fingerprint=%s]\",\n          dataSegment.getId(),\n          priorFingerprint\n      );\n    }\n    partial.clearRule();\n    log.info(\n        \"Released partial-load rule[fingerprint=%s, realizedBytes=%d] for segment[%s]; it is a regular full load now.\",\n        priorFingerprint,\n        priorRealizedBytes,\n        dataSegment.getId()\n    );\n  }\n\n  /**\n   * Whether any location already has a cache entry for {@code id}\n   */","sourceCodeStart":1612,"sourceCodeEnd":1648,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java#L1612-L1648","documentation":"When releasing a partial-load rule, SegmentLocalCacheManager rewrites the segment's info file so it no longer carries the rule-wrapped loadSpec. If the rewrite throws an IOException, it is wrapped in this SegmentLoadingException including the prior rule fingerprint.","triggerScenarios":"Rule release path calls rewriteInfoFile(dataSegment) and the file write fails — disk full, read-only filesystem, missing info-hierarchy directory, or the file was removed concurrently.","commonSituations":"Cache disk full when dropping a partial-load rule; cache directory cleaned by external tooling while the historical holds state; permissions issues; races between rule release and cache eviction.","solutions":["Check disk space and permissions on the cache location and repair the underlying write failure.","Ensure no external processes delete or modify the segment cache info-hierarchy while the historical runs.","After fixing, retry the rule release or restart the historical so it reconciles info files with in-memory state.","Investigate concurrent eviction/drop operations targeting the same segment id."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"final File infoFile = infoHierarchy.fileFor(dataSegment.getId());\nif (!infoFile.canWrite() || infoFile.getParentFile().getUsableSpace() < MIN_FREE_BYTES) {\n  throw new IllegalStateException(\"Cannot rewrite info file for rule release: \" + infoFile);\n}","typeGuard":null,"tryCatchPattern":"try {\n  cacheManager.releasePartialLoadRule(segment);\n} catch (SegmentLoadingException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"releasing partial-load rule\")) {\n    alertDiskProblem(e); // rule state may be inconsistent; repair disk then restart/reconcile\n  } else {\n    throw e;\n  }\n}","preventionTips":["Monitor cache-location disk space so rule-release rewrites don't fail.","Never externally delete or modify the info-hierarchy while the historical runs.","Handle concurrent drop/eviction of the same segment id carefully.","If release fails, restart the historical to reconcile in-memory rule state with on-disk info files."],"tags":["file-write","partial-load","info-file","io"],"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-14T11:17:12.474Z"}