private void recoverTsFiles() {
    if (memTableId2RecoverPerformer.isEmpty()) {
      return;
    }
    // make preparation for recovery
    for (UnsealedTsFileRecoverPerformer recoverPerformer : memTableId2RecoverPerformer.values()) {
      try {
        recoverPerformer.startRecovery();
      } catch (Exception e) {
        recoverPerformer.getRecoverListener().fail(e);
      }
    }
    // find all valid .wal files
    File[] walFiles =
        logDirectory.listFiles(
            (dir, name) ->
                WALFileUtils.walFilenameFilter(dir, name)
                    && WALFileUtils.parseVersionId(name) >= firstValidVersionId);
    if (walFiles == null) {
      endRecovery();
      return;
    }
    // asc sort by version id
    WALFileUtils.ascSortByVersionId(walFiles);
    // read .wal files and redo logs
    for (int i = 0; i < walFiles.length; ++i) {
      File walFile = walFiles[i];
      try (WALByteBufReader reader = new WALByteBufReader(walFile)) {
        if (Collections.disjoint(memTableId2Info.keySet(), reader.getMetaData().getMemTablesId())) {
          continue;
        }
        while (reader.hasNext()) {
          ByteBuffer buffer = reader.next();
          // see WALInfoEntry#serialize, entry type
          buffer.position(Byte.BYTES);
          long memTableId = buffer.getLong();
          if (!memTableId2Info.containsKey(memTableId)) {
            continue;
          }
          buffer.clear();
          WALEntry walEntry =
              WALEntry.deserialize(new DataInputStream(new ByteArrayInputStream(buffer.array())));
          UnsealedTsFileRecoverPerformer recoverPerformer =
              memTableId2RecoverPerformer.get(walEntry.getMemTableId());
          if (recoverPerformer != null) {
            recoverPerformer.redoLog(walEntry);
          } else {
            logger.debug(
                "Fail to find TsFile recover performer for wal entry in TsFile {}", walFile);
          }
        }
      } catch (BrokenWALFileException e) {
        logger.warn(
            "Fail to read memTable ids from the wal file {} of wal node: {}",
            walFile.getAbsoluteFile(),
            e.getMessage());
      } catch (IOException e) {
        logger.warn(
            "Fail to read memTable ids from the wal file {} of wal node.",
            walFile.getAbsoluteFile(),
            e);
      } catch (Exception e) {
        logger.warn("Fail to read wal logs from {}, skip them", walFile, e);
      }
    }
    endRecovery();
  }
This task is responsible for the recovery of one wal node.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/recover/WALNodeRecoverTask.java