{"record":{"id":"52fae4bac59ca67e","repo":"apache/hadoop","slug":"providedreplica-does-not-yet-support-writes","errorCode":null,"errorMessage":"ProvidedReplica does not yet support writes","messagePattern":"ProvidedReplica does not yet support writes","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ProvidedReplica.java","lineNumber":295,"sourceCode":"  public boolean renameData(URI destURI) throws IOException {\n    throw new UnsupportedOperationException(\n        \"ProvidedReplica does not support renaming data\");\n  }\n\n  @Override\n  public boolean getPinning(LocalFileSystem localFS) throws IOException {\n    return false;\n  }\n\n  @Override\n  public void setPinning(LocalFileSystem localFS) throws IOException {\n    throw new UnsupportedOperationException(\n        \"ProvidedReplica does not support pinning\");\n  }\n\n  @Override\n  public void bumpReplicaGS(long newGS) throws IOException {\n    throw new UnsupportedOperationException(\n        \"ProvidedReplica does not yet support writes\");\n  }\n\n  @Override\n  public boolean breakHardLinksIfNeeded() throws IOException {\n    return false;\n  }\n\n  @Override\n  public ReplicaRecoveryInfo createInfo()\n      throws UnsupportedOperationException {\n    throw new UnsupportedOperationException(\n        \"ProvidedReplica does not yet support writes\");\n  }\n\n  @Override\n  public int compareWith(ScanInfo info) {\n    if (info.getFileRegion().equals(","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ProvidedReplica.java#L277-L313","documentation":"bumpReplicaGS(long) rewrites a replica's generation stamp on disk when a block is recovered or updated for a new writer. ProvidedReplica throws UnsupportedOperationException ('does not yet support writes') because the remote bytes, and hence their generation stamp, are fixed in the provided store.","triggerScenarios":"Block recovery (DataNode syncBlock) or updateBlock/updateReplica paths that call bumpReplicaGS on a replica which turns out to be a ProvidedReplica - i.e. a lease-recovery, append, or truncate-recovery attempt on a file backed by provided storage.","commonSituations":"A client opens an existing provided-storage file for append (or triggers lease recovery on it) while the DataNode serves that block from a PROVIDED volume; the write-path code assumes a mutable local replica.","solutions":["Keep append/overwrite/recovery workloads off provided-storage namespaces; provided replicas are read-only references.","Pre-check the replica/volume type (instanceof ProvidedReplica or ProvidedVolume) before bumpReplicaGS and reject the write with a clear NameNode-level error.","Copy data to local storage if a provided block truly must be re-opened for writes, then operate on the local copy.","Catch UnsupportedOperationException at the write-path boundary and fail the operation cleanly rather than crashing the DataNode thread."],"exampleFix":"// before\nreplica.bumpReplicaGS(newGS);\n\n// after\nif (replica instanceof ProvidedReplica) {\n  throw new IOException(\"Cannot bump GS of read-only PROVIDED replica \" + replica.getBlockId());\n}\nreplica.bumpReplicaGS(newGS);","handlingStrategy":"validation","validationCode":"if (replica instanceof ProvidedReplica) {\n  throw new IOException(\"Cannot bump GS of read-only PROVIDED replica \"\n      + replica.getBlockId());\n}\nreplica.bumpReplicaGS(newGS);","typeGuard":"static boolean isProvided(ReplicaInfo r) {\n  return r instanceof ProvidedReplica;\n}","tryCatchPattern":"try {\n  replica.bumpReplicaGS(newGS);\n} catch (UnsupportedOperationException e) {\n  throw new IOException(\"PROVIDED replica \" + replica.getBlockId()\n      + \" does not support writes (bump GS)\", e);\n}","preventionTips":["Keep append/lease-recovery workloads away from provided-storage files.","Validate replica writability before entering recovery handshakes.","Treat UnsupportedOperationException from a provided replica as a permanent 'read-only' signal, not a transient failure - never retry."],"tags":["hdfs","datanode","provided-storage","generation-stamp","block-recovery"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}