public void repair(WALMetaData metaData) throws IOException {
    // locate broken data
    long truncateSize;
    WALFileVersion version = WALFileVersion.getVersion(logFile);
    if (version.getVersionString().equals(readTailMagic(version))) { // complete file
      return;
    } else { // file with broken magic string
      truncateSize = metaData.getTruncateOffSet();
    }

    // truncate broken data
    try (FileChannel channel = FileChannel.open(logFile.toPath(), StandardOpenOption.APPEND)) {
      channel.truncate(truncateSize);
    }
    // flush metadata
    try (WALWriter walWriter = new WALWriter(logFile, version)) {
      walWriter.updateMetaData(metaData);
    }
  }
Check whether the wal file is broken and repair it.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/recover/WALRepairWriter.java