public void closeSelf(ConsensusPipeName consensusPipeName) {
      // close file writer
      if (writingFileWriter != null) {
        try {
          writingFileWriter.close();
          LOGGER.info(
              "PipeConsensus-PipeName-{}: TsFileWriter-{} exit: Writing file writer was closed.",
              consensusPipeName.toString(),
              index);
        } catch (Exception e) {
          LOGGER.warn(
              "PipeConsensus-PipeName-{}: TsFileWriter-{} exit: Close Writing file writer error.",
              consensusPipeName,
              index,
              e);
        }
        setWritingFileWriter(null);
      } else {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(
              "PipeConsensus-PipeName-{}: TsFileWriter-{} exit: Writing file writer is null. No need to close.",
              consensusPipeName.toString(),
              index);
        }
      }

      // close file
      if (writingFile != null) {
        deleteFileOrDirectoryIfExists(
            writingFile, String.format("TsFileWriter-%s exit: delete writing file", this.index));
        setWritingFile(null);
      } else {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(
              "PipeConsensus-PipeName-{}: TsFileWriter exit: Writing file is null. No need to delete.",
              consensusPipeName.toString());
        }
      }
    }
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