public synchronized CompletableFuture<Void> scheduleFlushAll() {
    List<Map.Entry<Integer, CachedMTreeStore>> flushEngineList = new ArrayList<>();
    for (Map.Entry<Integer, CachedMTreeStore> entry : regionToStore.entrySet()) {
      if (flushingRegionSet.contains(entry.getKey())) {
        continue;
      }
      flushingRegionSet.add(entry.getKey());
      flushEngineList.add(entry);
    }
    return CompletableFuture.allOf(
        flushEngineList.stream()
            .map(
                entry ->
                    CompletableFuture.runAsync(
                        () -> {
                          int regionId = entry.getKey();
                          CachedMTreeStore store = entry.getValue();
                          if (store == null) {
                            // store has been closed
                            return;
                          }
                          LockManager lockManager = store.getLockManager();
                          lockManager.globalReadLock();
                          if (!regionToStore.containsKey(regionId)) {
                            // double check store have not been closed
                            return;
                          }
                          try {
                            executeFlush(store, regionId, null);
                            executeRelease(store, false);
                          } finally {
                            lockManager.globalReadUnlock();
                          }
                        },
                        workerPool))
            .toArray(CompletableFuture[]::new));
  }
Force flush all volatile subtrees and updated database MNodes to disk. After flushing, the
MNodes will be placed into node cache. This method will return synchronously after all stores
are successfully flushed.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/flush/Scheduler.java