private boolean checkFile(File walFile) {
    try (DataInputStream logStream = new DataInputStream(new WALInputStream(walFile))) {
      while (logStream.available() > 0) {
        WALEntry walEntry = WALEntry.deserialize(logStream);
        if (walEntry.getType() == WALEntryType.WAL_FILE_INFO_END_MARKER) {
          return true;
        }
      }
    } catch (FileNotFoundException e) {
      logger.debug("Wal file doesn't exist, skipping");
      return true;
    } catch (IOException e) {
      logger.error("{} fails the check because", walFile, e);
      return false;
    }
    return true;
  }
check the root wal dir and find the damaged files

@return a list of damaged files.
@throws WALException if the root wal dir does not exist.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/WalChecker.java