apache/druid · error · SegmentLoadingException

Failed to rewrite info file for segment[%s] while releasing

Error message

Failed to rewrite info file for segment[%s] while releasing partial-load rule[fingerprint=%s]

What it means

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.

Source

Thrown at server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java:1630

   * clears the rule and removes the info file, so there is no stale rule for a restart to reinstate. Leaving the rule
   * applied and carrying on is not an option, because an unwrapped request announces as a full load either way, so the
   * coordinator would record a replica with no profile and never ask again.
   * <p>
   * Callers must hold this segment's {@link #lock(DataSegment)}, which is the external lock that
   * {@link PartialSegmentMetadataCacheEntry#clearRule} requires to be serialized against
   * {@link PartialSegmentMetadataCacheEntry#applyRule}.
   */
  private void releaseRuleForFullLoad(DataSegment dataSegment, PartialSegmentMetadataCacheEntry partial)
      throws SegmentLoadingException
  {
    // Snapshot both before clearRule zeroes out the rule state so the log can describe what was released.
    final String priorFingerprint = partial.getRuleFingerprint();
    final long priorRealizedBytes = partial.getRealizedBytes();
    try {
      rewriteInfoFile(dataSegment);
    }
    catch (IOException e) {
      throw new SegmentLoadingException(
          e,
          "Failed to rewrite info file for segment[%s] while releasing partial-load rule[fingerprint=%s]",
          dataSegment.getId(),
          priorFingerprint
      );
    }
    partial.clearRule();
    log.info(
        "Released partial-load rule[fingerprint=%s, realizedBytes=%d] for segment[%s]; it is a regular full load now.",
        priorFingerprint,
        priorRealizedBytes,
        dataSegment.getId()
    );
  }

  /**
   * Whether any location already has a cache entry for {@code id}
   */

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Check disk space and permissions on the cache location and repair the underlying write failure.
  2. Ensure no external processes delete or modify the segment cache info-hierarchy while the historical runs.
  3. After fixing, retry the rule release or restart the historical so it reconciles info files with in-memory state.
  4. Investigate concurrent eviction/drop operations targeting the same segment id.
Defensive patterns

Strategy: try-catch

Validate before calling

final File infoFile = infoHierarchy.fileFor(dataSegment.getId());
if (!infoFile.canWrite() || infoFile.getParentFile().getUsableSpace() < MIN_FREE_BYTES) {
  throw new IllegalStateException("Cannot rewrite info file for rule release: " + infoFile);
}

Try / catch

try {
  cacheManager.releasePartialLoadRule(segment);
} catch (SegmentLoadingException e) {
  if (e.getMessage() != null && e.getMessage().contains("releasing partial-load rule")) {
    alertDiskProblem(e); // rule state may be inconsistent; repair disk then restart/reconcile
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/117ae42ed0d2a94f. Report an issue: GitHub.