{"record":{"id":"35960abbdf4f04ac","repo":"apache/hadoop","slug":"replica-of-type-getstate-does-not-support-set","errorCode":null,"errorMessage":"Replica of type ${getState()} does not support setRecoveryID","messagePattern":"Replica of type (.+?) does not support setRecoveryID","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":113,"sourceCode":"  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() +\n        \" does not support createInfo\");\n  }\n}\n","sourceCodeStart":95,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/FinalizedProvidedReplica.java#L95-L123","documentation":"setRecoveryID() assigns the per-recovery ID used during block synchronization; it is meaningful only for replicas under recovery. FinalizedProvidedReplica is FINALIZED and provided (bytes in external storage), so it has no recovery state to mutate and throws UnsupportedOperationException.","triggerScenarios":"A recovery flow calling setRecoveryID(recoveryId) on a replica that is a FinalizedProvidedReplica — typically when the replica chosen for recovery on this DataNode is PROVIDED rather than a local RBW/RWR/RUR replica.","commonSituations":"PROVIDED-storage deployments where recovery logic does not filter replica types; custom truncate/append implementations that set recovery IDs on every replica they find; test harnesses exercising all replicas uniformly.","solutions":["Filter to recovery-state replicas (RBW/RWR/RUR) before assigning recovery IDs.","Recovery should target a replica that actually tracks recovery state; exclude provided replicas from the candidate set.","Upgrade HDFS if the call site is framework code — check the version's provided-storage fixes.","In custom code paths, assert the replica state before mutating recovery bookkeeping."],"exampleFix":"// before\nreplica.setRecoveryID(recoveryId);\n\n// after: only mutate replicas that track recovery\nif (replica instanceof ReplicaUnderReconstruction) {\n  replica.setRecoveryID(recoveryId);\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean canSetRecoveryId(ReplicaInfo r) {\n  return r instanceof ReplicaUnderReconstruction;\n}","tryCatchPattern":"try {\n  replica.setRecoveryID(recoveryId);\n} catch (UnsupportedOperationException e) {\n  // replica cannot join a recovery session: exclude it from the flow\n}","preventionTips":["Assert replica state before mutating recovery bookkeeping","Select recovery participants from replicasUnderReconstruction maps, not raw volume scans","Cover provided/finalized replicas in recovery-flow tests"],"tags":["provided-storage","replica","recovery","unsupported-operation","hdfs"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}