private void triggerFlushInPrimaryRegion(final HRegion region) {
    if (ServerRegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) {
      return;
    }
    TableName tn = region.getTableDescriptor().getTableName();
    if (
      !ServerRegionReplicaUtil.isRegionReplicaReplicationEnabled(region.conf, tn)
        || !ServerRegionReplicaUtil.isRegionReplicaWaitForPrimaryFlushEnabled(region.conf) ||
        // If the memstore replication not setup, we do not have to wait for observing a flush event
        // from primary before starting to serve reads, because gaps from replication is not
        // applicable,this logic is from
        // TableDescriptorBuilder.ModifyableTableDescriptor.setRegionMemStoreReplication by
        // HBASE-13063
        !region.getTableDescriptor().hasRegionMemStoreReplication()
    ) {
      region.setReadsEnabled(true);
      return;
    }

    region.setReadsEnabled(false); // disable reads before marking the region as opened.
    // RegionReplicaFlushHandler might reset this.

    // Submit it to be handled by one of the handlers so that we do not block OpenRegionHandler
    if (this.executorService != null) {
      this.executorService.submit(new RegionReplicaFlushHandler(this, region));
    } else {
      LOG.info("Executor is null; not running flush of primary region replica for {}",
        region.getRegionInfo());
    }
  }
Trigger a flush in the primary region replica if this region is a secondary replica. Does not
block this thread. See RegionReplicaFlushHandler for details.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java