@Override
    public void flattenOneSegment(long requesterVersion, Action action) {
      int currentCount = flattenOneSegmentCounter.incrementAndGet();
      if (currentCount <= 1) {
        try {
          /**
           * {@link CompactingMemStore#snapshot} could start.
           */
          snapShotStartCyclicCyclicBarrier.await();
          flattenOneSegmentPreCyclicBarrier.await();
        } catch (Throwable e) {
          throw new RuntimeException(e);
        }
      }
      super.flattenOneSegment(requesterVersion, action);
      if (currentCount <= 1) {
        try {
          flattenOneSegmentPostCyclicBarrier.await();
          /**
           * Only the writeAgain thread completes, in memory compact thread would exit,because we
           * expect that in memory compact executing only once.
           */
          writeMemStoreAgainEndCyclicBarrier.await();
        } catch (Throwable e) {
          throw new RuntimeException(e);
        }

      }
    }
Only the writeAgain thread completes, retry
{@link CompactingMemStore#swapPipelineWithNull} would execute.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java