public void clear() {
    if (releaseMonitor != null) {
      releaseMonitor.shutdownNow();
      while (true) {
        if (releaseMonitor.isTerminated()) break;
      }
      releaseMonitor = null;
    }
    if (flushMonitor != null) {
      flushMonitor.shutdownNow();
      while (true) {
        if (flushMonitor.isTerminated()) break;
      }
      flushMonitor = null;
    }
    if (scheduler != null) {
      scheduler.clear();
      while (true) {
        if (scheduler.isTerminated()) break;
      }
      scheduler = null;
    }
    regionToStoreMap.clear();
    flushingRegionSet.clear();
    regionToTraverserTime.clear();
    releaseFlushStrategy = null;
    engineStatistics = null;
    releaseSemaphore = null;
    engineMetric = null;
  }
If there is a ReleaseTask or FlushTask, block the current thread to wait up to
MAX_WAITING_TIME_WHEN_RELEASING. The thread will be woken up if the ReleaseTask or FlushTask
ends or the wait time exceeds MAX_WAITING_TIME_WHEN_RELEASING.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/memory/ReleaseFlushMonitor.java