{"record":{"id":"27f3350fc1ef2f24","repo":"apache/hadoop","slug":"cannot-start-a-new-log-segment-at-txid-since-on","errorCode":null,"errorMessage":"Cannot start a new log segment at txid {} since only up to txid {} have been written in the log segment starting at {}.","messagePattern":"Cannot start a new log segment at txid (.+?) since only up to txid (.+?) have been written in the log segment starting at (.+?)\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java","lineNumber":1401,"sourceCode":"  public synchronized void startLogSegment(long txid, \n      boolean abortCurrentLogSegment, int layoutVersion) throws IOException {\n    LOG.info(\"Started a new log segment at txid \" + txid);\n    if (isSegmentOpen()) {\n      if (getLastWrittenTxId() == txid - 1) {\n        //In sync with the NN, so end and finalize the current segment`\n        endCurrentLogSegment(false);\n      } else {\n        //Missed some transactions: probably lost contact with NN temporarily.\n        final String mess = \"Cannot start a new log segment at txid \" + txid\n            + \" since only up to txid \" + getLastWrittenTxId()\n            + \" have been written in the log segment starting at \"\n            + getCurSegmentTxId() + \".\";\n        if (abortCurrentLogSegment) {\n          //Mark the current segment as aborted.\n          LOG.warn(mess);\n          abortCurrentLogSegment();\n        } else {\n          throw new IOException(mess);\n        }\n      }\n    }\n    setNextTxId(txid);\n    startLogSegment(txid, layoutVersion);\n  }\n  \n  /**\n   * Start writing to the log segment with the given txid.\n   * Transitions from BETWEEN_LOG_SEGMENTS state to IN_LOG_SEGMENT state. \n   */\n  private void startLogSegment(final long segmentTxId, int layoutVersion)\n      throws IOException {\n    assert Thread.holdsLock(this);\n\n    LOG.info(\"Starting log segment at \" + segmentTxId);\n    Preconditions.checkArgument(segmentTxId > 0,\n        \"Bad txid: %s\", segmentTxId);","sourceCodeStart":1383,"sourceCodeEnd":1419,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java#L1383-L1419","documentation":"Error \"Cannot start a new log segment at txid {} since only up to txid {} have been written in the log segment starting at {}.\" thrown in apache/hadoop.","triggerScenarios":"Rolling the edit log (startLogSegment) to a txid beyond what the current in-progress segment has actually written, e.g. during shared-storage HA transition.","commonSituations":"See trigger scenarios.","solutions":["Let the current log segment finish writing up to the requested txid before rolling; check for stalled journal writes.","Investigate missing/corrupt edits in the current segment and recover from a healthy journal or checkpoint."],"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-22T20:17:22.307Z"}