{"record":{"id":"435a958bf542b0d7","repo":"apache/hadoop","slug":"user-requested-stop","errorCode":null,"errorMessage":"user requested stop","messagePattern":"user requested stop","errorType":"exception","errorClass":"RequestStopException","httpStatus":null,"severity":"info","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/MetaRecoveryContext.java","lineNumber":109,"sourceCode":"        MetaRecoveryContext recovery, String contStr)\n        throws IOException, RequestStopException\n  {\n    if (recovery == null) {\n      throw new IOException(prompt);\n    }\n    LOG.error(prompt);\n    String answer = recovery.ask(\"\\nEnter 'c' to continue, \" + contStr + \"\\n\" +\n      \"Enter 's' to stop reading the edit log here, abandoning any later \" +\n        \"edits\\n\" +\n      \"Enter 'q' to quit without saving\\n\" +\n      \"Enter 'a' to always select the first choice in the future \" +\n      \"without prompting. \" + \n      \"(c/s/q/a)\\n\", \"c\", \"s\", \"q\", \"a\");\n    if (answer.equals(\"c\")) {\n      LOG.info(\"Continuing\");\n      return;\n    } else if (answer.equals(\"s\")) {\n      throw new RequestStopException(\"user requested stop\");\n    } else if (answer.equals(\"q\")) {\n      recovery.quit();\n    } else {\n      recovery.setForce(FORCE_FIRST_CHOICE);\n      return;\n    }\n  }\n\n  /** Log a message and quit */\n  public void quit() {\n    LOG.error(\"Exiting on user request.\");\n    System.exit(0);\n  }\n\n  public int getForce() {\n    return this.force;\n  }\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/MetaRecoveryContext.java#L91-L127","documentation":"MetaRecoveryContext.prompt drives the interactive prompts of 'hdfs namenode -recover' over a damaged edit log; answering 's' (stop reading the edit log here, abandoning any later edits) throws RequestStopException with message 'user requested stop'. This is deliberate control flow, not a malfunction: callers such as the edit-log replay loop catch it to finish recovery cleanly at the chosen transaction. The image will simply end at that txid.","triggerScenarios":"An operator (or a script feeding stdin) runs 'hdfs namenode -recover' on a corrupted edit log, hits a corrupt-record prompt, and answers 's' to abandon all later edits.","commonSituations":"Operators deliberately truncating replay before a known-bad region; scripted recovery sessions piping 's'; operators surprised afterwards that writes after the stop txid are missing from the recovered namespace.","solutions":["If stopping was intended, nothing to fix: restart the NN and accept that transactions after the stop point are gone.","To keep later edits, re-run recovery and answer 'c' (continue) or 'a' (always first choice) instead.","If the corruption was only a bad segment tail, restore the later segments from JournalNodes or backups first, then re-run recovery past the stop point."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"long lastApplied = imageTxid;\ntry {\n  loader.loadFetchedEdits(...); // replay loop honoring MetaRecoveryContext prompts\n} catch (MetaRecoveryContext.RequestStopException stop) {\n  // operator chose to abandon later edits - persist cleanly at the stop point\n  LOG.warn(\"Edit replay stopped by operator at txid {}\", lastApplied);\n  saveNamespaceAt(lastApplied);\n}","preventionTips":["Before running -recover, copy the entire name and edits dirs so a wrong prompt choice is reversible.","Script recovery answers deliberately (c/s/q/a) and record the txid where you stop.","Remember 's' means later transactions are permanently absent from the recovered namespace - verify with clients afterwards."],"tags":["hdfs","recovery","editlog","cli","control-flow"],"backgroundTag":"user-initiated-abort","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}