@Override
    public void waitForNextReady() throws InterruptedException {
      boolean walFileRolled = false;
      long bufferLastSearchIndex = 0;
      while (!hasNext()) {
        if (!walFileRolled) {
          boolean timeout =
              !buffer.waitForFlush(WAIT_FOR_NEXT_WAL_ENTRY_TIMEOUT_IN_SEC, TimeUnit.SECONDS);
          if (timeout) {
            bufferLastSearchIndex = buffer.getCurrentSearchIndex();
            logger.info(
                "timeout when waiting for next WAL entry ready, execute rollWALFile. Current search index in wal buffer is {}, and next target index is {}",
                bufferLastSearchIndex,
                nextSearchIndex);
            rollWALFile();
            walFileRolled = true;
          }
        } else {
          // only wait when the search index of the buffer remains the same as the previous check
          long finalBufferLastSearchIndex = bufferLastSearchIndex;
          buffer.waitForFlush(buf -> buf.getCurrentSearchIndex() == finalBufferLastSearchIndex);
        }
      }
    }
last broken wal file's version id
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/node/WALNode.java