{"record":{"id":"ecdbd4c6deecfd87","repo":"apache/hadoop","slug":"interrupted-waiting-for-discardsegments-response","errorCode":null,"errorMessage":"Interrupted waiting for discardSegments() response","messagePattern":"Interrupted waiting for discardSegments\\(\\) response","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/QuorumJournalManager.java","lineNumber":782,"sourceCode":"    } catch (InterruptedException e) {\n      throw new IOException(\"Interrupted waiting for doFinalize() response\");\n    } catch (TimeoutException e) {\n      throw new IOException(\"Timed out waiting for doFinalize() response\");\n    }\n  }\n  \n  @Override\n  public void discardSegments(long startTxId) throws IOException {\n    QuorumCall<AsyncLogger, Void> call = loggers.discardSegments(startTxId);\n    try {\n      call.waitFor(loggers.size(), loggers.size(), 0,\n          timeoutMs, \"discardSegments\");\n      if (call.countExceptions() > 0) {\n        call.rethrowException(\n            \"Could not perform discardSegments of one or more JournalNodes\");\n      }\n    } catch (InterruptedException e) {\n      throw new IOException(\n          \"Interrupted waiting for discardSegments() response\");\n    } catch (TimeoutException e) {\n      throw new IOException(\n          \"Timed out waiting for discardSegments() response\");\n    }\n  }\n  \n  @Override\n  public long getJournalCTime() throws IOException {\n    QuorumCall<AsyncLogger, Long> call = loggers.getJournalCTime();\n    try {\n      call.waitFor(loggers.size(), loggers.size(), 0,\n          timeoutMs, \"getJournalCTime\");\n      \n      if (call.countExceptions() > 0) {\n        call.rethrowException(\"Could not journal CTime for one \"\n            + \"more JournalNodes\");\n      }","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/QuorumJournalManager.java#L764-L800","documentation":"discardSegments(startTxId) — the QJM call that drops every edit segment from startTxId onward, used by the NameNode rollback procedure on shared edits — was interrupted while waiting for all JournalNodes to respond. InterruptedException is wrapped in this IOException.","triggerScenarios":"A thread interrupt lands while discardSegments is waiting on the quorum call: NN shutdown or HA transition during rollback, operator cancellation, or tooling interrupting the worker thread mid-procedure.","commonSituations":"Operator aborts 'hdfs namenode -rollback' while the NN is discarding newer segments; automated scripts interrupt on outer timeouts. Partial completion is possible: some JNs may have deleted segments while others have not, leaving the quorum inconsistent.","solutions":["Determine what interrupted the thread (shutdown, failover, operator) from surrounding logs and eliminate that trigger.","Audit each JN's current dir for which segments were actually deleted; reconcile by syncing from a healthy JN's directory.","Re-run the rollback/discard procedure once all JNs are consistent and no interrupt source remains.","If calling this API directly, structure cancellation to occur between quorum calls, never during one."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"static boolean isDiscardInterrupted(IOException ioe) {\n  return ioe.getMessage() != null\n      && ioe.getMessage().contains(\"Interrupted waiting for discardSegments\");\n}","tryCatchPattern":"try {\n  qjm.discardSegments(startTxId);\n} catch (IOException ioe) {\n  if (isDiscardInterrupted(ioe)) {\n    Thread.currentThread().interrupt();\n    auditWhichJnsDiscarded(); // deletion may be partial across the quorum\n    return;\n  }\n  throw ioe;\n}","preventionTips":["Treat discardSegments as non-interruptible: schedule it where shutdowns and cancellations cannot hit it.","After cancellation, compare segment listings across JN dirs before any retry.","Keep automation's outer timeout above dfs.qjm.operations.timeout plus margin."],"tags":["qjm","rollback","discard-segments","interrupt","edit-log"],"backgroundTag":"thread-interrupted","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}