{"record":{"id":"2921bbabca2e4aa3","repo":"apache/hadoop","slug":"found-replica-s-for-block-but-none-is-in-rw","errorCode":null,"errorMessage":"Found {} replica(s) for block {} but none is in RWR or better state. datanodeids={}","messagePattern":"Found (.+?) replica\\(s\\) for block (.+?) but none is in RWR or better state\\. datanodeids=(.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockRecoveryWorker.java","lineNumber":177,"sourceCode":"              \"Recovery for replica {} on data-node {} is already in progress. \" +\n                  \"Recovery id = {} is aborted.\", block, id, rBlock.getNewGenerationStamp(), ripE);\n          return;\n        } catch (IOException e) {\n          ++errorCount;\n          InterDatanodeProtocol.LOG.warn(\"Failed to recover block (block={}, datanode={})\",\n              block, id, e);\n        }\n      }\n\n      if (errorCount == locs.length) {\n        throw new IOException(\"All datanodes failed: block=\" + block\n            + \", datanodeids=\" + Arrays.asList(locs));\n      }\n\n      // None of the replicas reported by DataNodes has the required original\n      // state, report the error.\n      if (candidateReplicaCnt > 0 && syncList.isEmpty()) {\n        throw new IOException(\"Found \" + candidateReplicaCnt +\n            \" replica(s) for block \" + block + \" but none is in \" +\n            ReplicaState.RWR.name() + \" or better state. datanodeids=\" +\n            Arrays.asList(locs));\n      }\n\n      syncBlock(syncList);\n    }\n\n    /** Block synchronization. */\n    void syncBlock(List<BlockRecord> syncList) throws IOException {\n      DatanodeProtocolClientSideTranslatorPB nn =\n          getActiveNamenodeForBP(block.getBlockPoolId());\n\n      boolean isTruncateRecovery = rBlock.getNewBlock() != null;\n      long blockId = (isTruncateRecovery) ?\n          rBlock.getNewBlock().getBlockId() : block.getBlockId();\n\n      LOG.info(\"BlockRecoveryWorker: block={} (length={}),\"","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockRecoveryWorker.java#L159-L195","documentation":"Error \"Found {} replica(s) for block {} but none is in RWR or better state. datanodeids={}\" thrown in apache/hadoop.","triggerScenarios":"During block recovery, replicas of the block exist but none is in RECOVERY_WAITING_BETTER (RWR) or a better state to serve as the recovery source.","commonSituations":"Replicas exist for the block but none is in a recoverable RWR-or-better state. Triggered by crashes mid-write; check replica states with fsck before retrying recovery.","solutions":["Wait for in-progress writes to complete or restart stalled writers so replicas reach RWR/FINALIZED state, then retry recovery.","Check the state of each replica (via fsck or DataNode logs); if replicas are stuck in RBW/RUR, resolve the underlying writer failures."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}