@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
          && Thread.currentThread().getName().equals(USER_THREAD_NAME)
      ) {
        this.prepareFlush = true;
      }
      try {
        PrepareFlushResult result = super.internalPrepareFlushCache(wal, myseqid, storesToFlush,
          status, writeFlushWalMarker, tracker);

        return result;
      } finally {
        if (
          this.getRegionInfo().getReplicaId() == 0
            && Thread.currentThread().getName().equals(USER_THREAD_NAME)
        ) {
          this.prepareFlush = false;
        }
      }

    }
Write First cell,replicating to secondary replica is error.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationSinkCallbackAndFlushConcurrently.java