{"record":{"id":"311321a734ac541a","repo":"apache/hadoop","slug":"replica-of-type-getstate-does-not-support-get","errorCode":null,"errorMessage":"Replica of type ${getState()} does not support getOriginalReplica","messagePattern":"Replica of type (.+?) does not support getOriginalReplica","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/FinalizedProvidedReplica.java","lineNumber":101,"sourceCode":"\n  @Override  // Object\n  public boolean equals(Object o) {\n    return super.equals(o);\n  }\n\n  @Override  // Object\n  public int hashCode() {\n    return super.hashCode();\n  }\n\n  @Override\n  public String toString() {\n    return super.toString();\n  }\n\n  @Override\n  public ReplicaInfo getOriginalReplica() {\n    throw new UnsupportedOperationException(\"Replica of type \" + getState() +\n        \" does not support getOriginalReplica\");\n  }\n\n  @Override\n  public long getRecoveryID() {\n    throw new UnsupportedOperationException(\"Replica of type \" + getState() +\n        \" does not support getRecoveryID\");\n  }\n\n  @Override\n  public void setRecoveryID(long recoveryId) {\n    throw new UnsupportedOperationException(\"Replica of type \" + getState() +\n        \" does not support setRecoveryID\");\n  }\n\n  @Override\n  public ReplicaRecoveryInfo createInfo() {\n    throw new UnsupportedOperationException(\"Replica of type \" + getState() +","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/FinalizedProvidedReplica.java#L83-L119","documentation":"FinalizedProvidedReplica represents a FINALIZED replica whose bytes live in external PROVIDED storage (HDFS-9906), not in DataNode-local files. getOriginalReplica() is only implemented by replicas under reconstruction (ReplicaUnderReconstruction), so calling it on a provided replica throws UnsupportedOperationException — the object has no local original to return.","triggerScenarios":"Any code path that invokes ReplicaInfo.getOriginalReplica() on a provided replica: block-recovery flows (interDataNodeProtocol startBlockRecovery / commitBlockSynchronization) reaching a replica that is PROVIDED, or custom code walking the volume map and calling recovery APIs without a type check.","commonSituations":"Clusters with PROVIDED storage enabled where a recovery or truncate flow lands on a provided replica; newer call sites added to recovery code that predate provided-storage support; custom FsDatasetSpi extensions that route recovery calls to all replica types.","solutions":["Guard callers: check the replica type (instanceof ReplicaUnderReconstruction, or replica.isProvided()/getState()) before calling recovery APIs.","Avoid initiating block recovery against blocks whose local copy is PROVIDED — recover from another DataNode's replica instead.","Upgrade HDFS: provided-storage handling in recovery paths has been fixed incrementally; check release notes for your version.","If this surfaces from your own dataset code, do not forward these calls to FinalizedProvidedReplica."],"exampleFix":"// before\nReplicaInfo original = replica.getOriginalReplica();\n\n// after: only replicas under reconstruction support recovery APIs\nif (replica instanceof ReplicaUnderReconstruction) {\n  ReplicaInfo original = replica.getOriginalReplica();\n} else {\n  // PROVIDED / FINALIZED replica: not recoverable locally, skip or fail over\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean supportsGetOriginalReplica(ReplicaInfo r) {\n  return r instanceof ReplicaUnderReconstruction;\n}","tryCatchPattern":"try {\n  ReplicaInfo original = replica.getOriginalReplica();\n} catch (UnsupportedOperationException e) {\n  // replica is not under reconstruction (e.g., PROVIDED): skip local recovery handling\n}","preventionTips":["Filter replicas by type before recovery APIs; only ReplicaUnderReconstruction implements them","In PROVIDED-storage clusters, exclude provided replicas from local recovery candidates","Add finalized and provided replicas to recovery-path unit tests"],"tags":["provided-storage","replica","unsupported-operation","hdfs","datanode"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}