@Override
    protected PrepareFlushResult internalPrepareFlushCache(WAL wal, long myseqid,
      Collection<HStore> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker,
      FlushLifeCycleTracker tracker) throws IOException {
      if (!startTest) {
        return super.internalPrepareFlushCache(wal, myseqid, storesToFlush, status,
          writeFlushWalMarker, tracker);
      }

      if (this.getRegionInfo().getReplicaId() != 0) {
        return super.internalPrepareFlushCache(wal, myseqid, storesToFlush, status,
          writeFlushWalMarker, tracker);
      }

      try {
        PrepareFlushResult result = super.internalPrepareFlushCache(wal, myseqid, storesToFlush,
          status, writeFlushWalMarker, tracker);
        this.prepareFlushCounter.incrementAndGet();
        /**
         * First flush is {@link FlushAction#START_FLUSH} marker and the second flush is
         * {@link FlushAction#CANNOT_FLUSH} marker because the memstore is empty.
         */
        if (
          this.prepareFlushCounter.get() == 2 && result.getResult() != null
            && result.getResult().getResult() == FlushResult.Result.CANNOT_FLUSH_MEMSTORE_EMPTY
        ) {

          cyclicBarrier.await();
        }
        return result;
      } catch (BrokenBarrierException | InterruptedException e) {
        throw new RuntimeException(e);
      }

    }
The {@link RegionReplicationSink#failedReplicas} is cleared by the
{@link FlushAction#CANNOT_FLUSH} marker.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForFlushMarker.java