public void setDataRegion(DataRegionId regionId, DataRegion newRegion) {
    if (dataRegionMap.containsKey(regionId)) {
      DataRegion oldRegion = dataRegionMap.get(regionId);
      oldRegion.markDeleted();
      oldRegion.abortCompaction();
      oldRegion.syncCloseAllWorkingTsFileProcessors();
    }
    WRITING_METRICS.createFlushingMemTableStatusMetrics(regionId);
    WRITING_METRICS.createDataRegionMemoryCostMetrics(newRegion);
    WRITING_METRICS.createActiveMemtableCounterMetrics(regionId);
    dataRegionMap.put(regionId, newRegion);
  }
This method is not thread-safe
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/StorageEngine.java