{"record":{"id":"5acc79452e7df191","repo":"apache/hadoop","slug":"could-not-find-image-with-txid-txid-5acc79","errorCode":null,"errorMessage":"Could not find image with txid ${txId}","messagePattern":"Could not find image with txid (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java","lineNumber":274,"sourceCode":"      return result;\n    }\n    double xferSec = Math.max(\n        ((float) (Time.monotonicNow() - startTime)) / 1000.0, 0.001);\n    LOG.info(\"Uploaded image with txid \" + txid + \" to namenode at \" + fsName\n        + \" in \" + xferSec + \" seconds\");\n    return TransferResult.SUCCESS;\n  }\n\n  /*\n   * Uploads the imagefile using HTTP PUT method\n   */\n  private static void uploadImage(URL url, Configuration conf,\n      NNStorage storage, NameNodeFile nnf, long txId, Canceler canceler)\n      throws IOException {\n\n    File imageFile = storage.findImageFile(nnf, txId);\n    if (imageFile == null) {\n      throw new IOException(\"Could not find image with txid \" + txId);\n    }\n\n    HttpURLConnection connection = null;\n    try {\n      URIBuilder uriBuilder = new URIBuilder(url.toURI());\n\n      // write all params for image upload request as query itself.\n      // Request body contains the image to be uploaded.\n      Map<String, String> params = ImageServlet.getParamsForPutImage(storage,\n          txId, imageFile.length(), nnf);\n      for (Entry<String, String> entry : params.entrySet()) {\n        uriBuilder.addParameter(entry.getKey(), entry.getValue());\n      }\n\n      URL urlWithParams = uriBuilder.build().toURL();\n      connection = (HttpURLConnection) connectionFactory.openConnection(\n          urlWithParams, UserGroupInformation.isSecurityEnabled());\n      // Set the request to PUT","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java#L256-L292","documentation":"Before pushing a checkpoint image to a peer via HTTP PUT, TransferFsImage.uploadImage() locates the local file with storage.findImageFile(nnf, txId); if no fsimage_<txId> of the requested NameNodeFile type exists locally, it throws IOException. The uploader is asked to send an image it no longer has.","triggerScenarios":"uploadImage(url, conf, storage, nnf, txId, canceler) is called during checkpoint upload right after saving; findImageFile returns null when the image was deleted by retention/cleanup, renamed during a concurrent checkpoint, or when the requested txid never matched a saved file.","commonSituations":"Image retention purged the just-saved checkpoint between save and upload; an operator or script deleted fsimage files; two checkpointers racing on the same storage; txid arithmetic mismatch between what the peer requested and what was written.","solutions":["List fsimage_<txid> in <name.dir>/current and confirm the exact txid exists before retrying","Raise retention (dfs.image.transfer.timeout related checkpoint retention, NameNode 'dfs.namenode.num.checkpoints.retained') so files survive until upload","Ensure only one SecondaryNameNode/checkpointer uploads to this NN and no manual cleanup runs during checkpoints","Trigger a new checkpoint so a fresh image exists, then retry the transfer"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before initiating the PUT, confirm the source image still exists\nFile imageFile = storage.findImageFile(nnf, txId);\nif (imageFile == null || !imageFile.exists()) {\n  LOG.warn(\"Image fsimage_{} vanished; skipping upload this cycle\", txId);\n  return; // let the next checkpoint produce a fresh image\n}","typeGuard":null,"tryCatchPattern":"try {\n  TransferFsImage.uploadImage(url, conf, storage, nnf, txId, canceler);\n} catch (IOException e) { // \"Could not find image with txid N\"\n  // not retryable with the same txid — re-run a full checkpoint first\n  triggerCheckpoint();\n}","preventionTips":["Do not run manual fsimage cleanup jobs while checkpoints are in flight","Retain enough checkpoints (dfs.namenode.num.checkpoints.retained) that upload never races deletion","Run exactly one SecondaryNameNode per namespace to avoid concurrent checkpoint/retention churn"],"tags":["hdfs","namenode","transferfsimage","checkpoint","file-not-found","image-upload"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}