{"record":{"id":"1a9467e6acd943d0","repo":"apache/hadoop","slug":"providedreplica-does-not-yet-support-copy-data","errorCode":null,"errorMessage":"ProvidedReplica does not yet support copy data","messagePattern":"ProvidedReplica does not yet support copy data","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":342,"sourceCode":"    throw new UnsupportedOperationException(\n        \"ProvidedReplica does not yet support truncate\");\n  }\n\n  @Override\n  public void updateWithReplica(StorageLocation replicaLocation) {\n    throw new UnsupportedOperationException(\n        \"ProvidedReplica does not yet support update\");\n  }\n\n  @Override\n  public void copyMetadata(URI destination) throws IOException {\n    throw new UnsupportedOperationException(\n        \"ProvidedReplica does not yet support copy metadata\");\n  }\n\n  @Override\n  public void copyBlockdata(URI destination) throws IOException {\n    throw new UnsupportedOperationException(\n        \"ProvidedReplica does not yet support copy data\");\n  }\n\n  @VisibleForTesting\n  public void setPathHandle(PathHandle pathHandle) {\n    this.pathHandle = pathHandle;\n  }\n}\n","sourceCodeStart":324,"sourceCodeEnd":351,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ProvidedReplica.java#L324-L351","documentation":"copyBlockdata(URI destination) streams a replica's block bytes to a destination URI during FsDatasetImpl.copyBlock (replication target). ProvidedReplica throws UnsupportedOperationException because receiving and storing incoming block bytes into the external provided store is not supported - provided volumes only expose pre-existing aliased data.","triggerScenarios":"A replication or copy operation attempts to write incoming block bytes through a FinalizedProvidedReplica: copyBlockdata(destination) is invoked on a ProvidedReplica created on a PROVIDED volume.","commonSituations":"Mixed local+PROVIDED data dirs where the volume chooser or a test places new replicas on the provided volume; or custom FsDataset code that assumes every replica can receive a copy.","solutions":["Keep PROVIDED volumes out of write/replication volume selection (they are read-only serving tiers).","Pre-check the target volume/replica type before copyBlockdata and fail fast with a descriptive error.","Clean up any partially created ProvidedReplica in a finally/catch so the block map stays consistent.","Catch UnsupportedOperationException at the copy boundary, roll back the replica registration, and report to the NameNode."],"exampleFix":"// before\nreplica.copyBlockdata(destUri);\n\n// after\nif (replica instanceof ProvidedReplica) {\n  throw new IOException(\"PROVIDED volume cannot receive block copies\");\n}\nreplica.copyBlockdata(destUri);","handlingStrategy":"validation","validationCode":"if (replica instanceof ProvidedReplica) {\n  throw new IOException(\"PROVIDED volume cannot receive block copies\");\n}\nreplica.copyBlockdata(destUri);","typeGuard":"static boolean isProvided(ReplicaInfo r) {\n  return r instanceof ProvidedReplica;\n}","tryCatchPattern":"try {\n  replica.copyBlockdata(destUri);\n} catch (UnsupportedOperationException e) {\n  dataset.invalidate(bpid, replica.getBlock());\n  throw new IOException(\"PROVIDED volume cannot receive block data\", e);\n}","preventionTips":["Restrict replica placement to local writable volumes.","Treat provided volumes as serving-only tiers in placement logic.","Clean up partial state when a copy into a provided replica fails."],"tags":["hdfs","datanode","provided-storage","block-replication","read-only"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}