{"record":{"id":"6f3bf36ce7a62e4c","repo":"apache/hadoop","slug":"could-not-find-image-with-txid-txid","errorCode":null,"errorMessage":"Could not find image with txid \" + txid","messagePattern":"Could not find image with txid \" \\+ txid","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ImageServlet.java","lineNumber":158,"sourceCode":"      validateRequest(context, conf, request, response, nnImage,\n          parsedParams.getStorageInfoString());\n\n      UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction<Void>() {\n        @Override\n        public Void run() throws Exception {\n          if (parsedParams.isGetImage()) {\n            long txid = parsedParams.getTxId();\n            File imageFile = null;\n            String errorMessage = \"Could not find image\";\n            if (parsedParams.shouldFetchLatest()) {\n              imageFile = nnImage.getStorage().getHighestFsImageName();\n            } else {\n              errorMessage += \" with txid \" + txid;\n              imageFile = nnImage.getStorage().getFsImage(txid,\n                  EnumSet.of(NameNodeFile.IMAGE, NameNodeFile.IMAGE_ROLLBACK));\n            }\n            if (imageFile == null) {\n              throw new IOException(errorMessage);\n            }\n            CheckpointFaultInjector.getInstance().beforeGetImageSetsHeaders();\n            long start = monotonicNow();\n            serveFile(imageFile);\n\n            if (metrics != null) { // Metrics non-null only when used inside name node\n              long elapsed = monotonicNow() - start;\n              metrics.addGetImage(elapsed);\n            }\n          } else if (parsedParams.isGetEdit()) {\n            long startTxId = parsedParams.getStartTxId();\n            long endTxId = parsedParams.getEndTxId();\n            \n            File editFile = nnImage.getStorage()\n                .findFinalizedEditsFile(startTxId, endTxId);\n            long start = monotonicNow();\n            serveFile(editFile);\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ImageServlet.java#L140-L176","documentation":"ImageServlet's GETIMAGE handling throws IOException(\"Could not find image with txid N\") when the request asks for a specific transaction-id fsimage and NNStorage.getFsImage(txid, {IMAGE, IMAGE_ROLLBACK}) finds no matching fsimage_<txid> file in the NameNode's storage directories. The NameNode simply does not retain (or never had) an image at that txid.","triggerScenarios":"Requesting a checkpoint txid already purged by retention (dfs.namenode.num.checkpoints.retained); asking for an IMAGE_ROLLBACK file when no rollback checkpoint exists; SecondaryNameNode/Standby bootstrapping with a stale txid after the Active's storage changed (restart, fresh format, restored directory).","commonSituations":"SNN checkpoint failing right after NN storage was replaced or reformatted; too few retained checkpoints for a slow/down SNN; hand-crafted transfer URLs or scripts pinning an old txid.","solutions":["Request the latest image instead of a fixed txid (GetImageParams 'latest' flag, e.g. getimage?getimage=1&latest=1)","Verify which images exist: ls <dfs.namenode.name.dir>/current/fsimage_* or check NameNode JMX mostRecentCheckpointTxid","Re-run the checkpoint or bootstrap so the requester and the NameNode agree on the current txid","Increase dfs.namenode.num.checkpoints.retained if requesters legitimately need older checkpoints"],"exampleFix":"# before: pinned txid that was purged\ncurl -f 'http://nn:9870/getimage?getimage=1&txid=1234'\n# -> IOException: Could not find image with txid 1234\n\n# after: fetch latest\nTXID=$(curl -s http://nn:9870/jmx | jq -r '.beans[]|select(.name==\"Hadoop:service=NameNode,name=NameNodeInfo\").MostRecentCheckpointTxId')\ncurl -f \"http://nn:9870/getimage?getimage=1&txid=$TXID\"","handlingStrategy":"validation","validationCode":"// Before requesting a specific txid, confirm the NN retains it\nlong latest = jmxMostRecentCheckpointTxid(nnJmxUrl);   // NameNodeInfo bean\nif (requestedTxid > latest) {\n  requestedTxid = latest;   // or fail: request is for a purged checkpoint\n}\ncurl -f \"http://nn:9870/getimage?getimage=1&txid=$requestedTxid\"","typeGuard":null,"tryCatchPattern":"catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Could not find image with txid\")) {\n    imageFile = fetchLatest();   // fall back to latest=1 transfer\n    if (imageFile == null) { throw e; }  // NN storage genuinely inconsistent\n  } else { throw e; }\n}","preventionTips":["Prefer latest-image requests (latest=1) unless a specific txid is required","Keep dfs.namenode.num.checkpoints.retained large enough for the slowest checkpoint consumer","After NN storage replacement/format, restart SecondaryNameNode/Standby so txid expectations resync"],"tags":["hdfs","namenode","checkpoint","fsimage","image-transfer","txid"],"backgroundTag":"checkpoint-image-missing","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}