apache/hadoop · error · IOException

Har: setReplication not allowed

Error message

Har: setReplication not allowed

What it means

setReplication is a mutation of physical file layout, and a har exposes only index metadata over immutable part files, so the override throws 'Har: setReplication not allowed'. Replication is a property of the underlying part files, not of archive members.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java:751

  @Override
  public void close() throws IOException {
    super.close();
    if (fs != null) {
      try {
        fs.close();
      } catch(IOException ie) {
        //this might already be closed
        // ignore
      }
    }
  }
  
  /**
   * Not implemented.
   */
  @Override
  public boolean setReplication(Path src, short replication) throws IOException{
    throw new IOException("Har: setReplication not allowed");
  }

  @Override
  public boolean rename(Path src, Path dst) throws IOException {
    throw new IOException("Har: rename not allowed");
  }

  @Override
  public FSDataOutputStream append(Path f) throws IOException {
    throw new IOException("Har: append not allowed");
  }

  /**
   * Not implemented.
   */
  @Override
  public boolean truncate(Path f, long newLength) throws IOException {
    throw new IOException("Har: truncate not allowed");

View on GitHub (pinned to 2add963021)

Solutions

  1. Apply setReplication to the physical .har files via the underlying filesystem, e.g. hdfs.setReplication(new Path("hdfs://nn:8020/a/data.har/part-0"), (short)3)
  2. Exclude har:// URIs from replication-tuning scripts (filter on scheme)
  3. Set the desired replication at archive creation time so the part files inherit it

Example fix

// before
harFs.setReplication(new Path("har://hdfs-nn:8020/a/data.har/f.txt"), (short)3);

// after
hdfs.setReplication(new Path("hdfs://nn:8020/a/data.har/part-0"), (short)3);
Defensive patterns

Strategy: validation

Validate before calling

if ("har".equals(p.toUri().getScheme())) {
  // tune replication of the physical part files instead
  hdfs.setReplication(new Path(underlyingArchiveDir, "part-0"), replication);
} else {
  fs.setReplication(p, replication);
}

Prevention

When it happens

Trigger: fs.setReplication(harPath, (short)N) on any har:// path — typically batch scripts that tune replication across many trees and sweep har URIs along with regular HDFS paths.

Common situations: Cluster-wide replication-policy scripts iterating over stored URIs; operators trying to shrink Namenode memory by adjusting replication of archived data via its har:// address.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/883f0d6f17be12ee. Report an issue: GitHub.