private void deleteFileOrDirectoryIfExists(File file, String reason) {
    if (file.exists()) {
      try {
        if (file.isDirectory()) {
          RetryUtils.retryOnException(
              () -> {
                FileUtils.deleteDirectory(file);
                return null;
              });
        } else {
          RetryUtils.retryOnException(() -> FileUtils.delete(file));
        }
        LOGGER.info(
            "PipeConsensus-PipeName-{}: {} {} was deleted.",
            consensusPipeName,
            reason,
            file.getPath());
      } catch (IOException e) {
        LOGGER.warn(
            "PipeConsensus-PipeName-{}: {} Failed to delete {}, because {}.",
            consensusPipeName,
            reason,
            file.getPath(),
            e.getMessage(),
            e);
      }
    } else {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(
            "PipeConsensus-PipeName-{}: {} {} is not existed. No need to delete.",
            consensusPipeName,
            reason,
            file.getPath());
      }
    }
  }
This method cannot be set to synchronize. Receive events can be concurrent since reqBuffer but
load event must be synchronized.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/pipeconsensus/PipeConsensusReceiver.java