@Test
  public void testClearSnapshotGetScannerConcurrently() throws Exception {
    Configuration conf = HBaseConfiguration.create();

    byte[] smallValue = new byte[3];
    byte[] largeValue = new byte[9];
    final long timestamp = EnvironmentEdgeManager.currentTime();
    final long seqId = 100;
    final ExtendedCell smallCell = createCell(qf1, timestamp, seqId, smallValue);
    final ExtendedCell largeCell = createCell(qf2, timestamp, seqId, largeValue);
    TreeSet<byte[]> quals = new TreeSet<>(Bytes.BYTES_COMPARATOR);
    quals.add(qf1);
    quals.add(qf2);

    conf.set(HStore.MEMSTORE_CLASS_NAME, MyDefaultMemStore.class.getName());
    conf.setBoolean(WALFactory.WAL_ENABLED, false);

    init(name.getMethodName(), conf, ColumnFamilyDescriptorBuilder.newBuilder(family).build());
    MyDefaultMemStore myDefaultMemStore = (MyDefaultMemStore) (store.memstore);
    myDefaultMemStore.store = store;

    MemStoreSizing memStoreSizing = new NonThreadSafeMemStoreSizing();
    store.add(smallCell, memStoreSizing);
    store.add(largeCell, memStoreSizing);

    final AtomicReference<Throwable> exceptionRef = new AtomicReference<Throwable>();
    final Thread flushThread = new Thread(() -> {
      try {
        flushStore(store, id++);
      } catch (Throwable exception) {
        exceptionRef.set(exception);
      }
    });
    flushThread.setName(MyDefaultMemStore.FLUSH_THREAD_NAME);
    flushThread.start();

    String oldThreadName = Thread.currentThread().getName();
    StoreScanner storeScanner = null;
    try {
      Thread.currentThread().setName(MyDefaultMemStore.GET_SCANNER_THREAD_NAME);

      /**
       * Wait flush thread stopping before {@link DefaultMemStore#doClearSnapshot}
       */
      myDefaultMemStore.getScannerCyclicBarrier.await();

      storeScanner = (StoreScanner) store.getScanner(new Scan(new Get(row)), quals, seqId + 1);
      flushThread.join();

      if (myDefaultMemStore.shouldWait) {
        SegmentScanner segmentScanner = getTypeKeyValueScanner(storeScanner, SegmentScanner.class);
        MemStoreLABImpl memStoreLAB = (MemStoreLABImpl) (segmentScanner.segment.getMemStoreLAB());
        assertTrue(memStoreLAB.isClosed());
        assertTrue(!memStoreLAB.chunks.isEmpty());
        assertTrue(!memStoreLAB.isReclaimed());

        ExtendedCell cell1 = segmentScanner.next();
        PrivateCellUtil.equals(smallCell, cell1);
        ExtendedCell cell2 = segmentScanner.next();
        PrivateCellUtil.equals(largeCell, cell2);
        assertNull(segmentScanner.next());
      } else {
        List<ExtendedCell> results = new ArrayList<>();
        storeScanner.next(results);
        assertEquals(2, results.size());
        PrivateCellUtil.equals(smallCell, results.get(0));
        PrivateCellUtil.equals(largeCell, results.get(1));
      }
      assertTrue(exceptionRef.get() == null);
    } finally {
      if (storeScanner != null) {
        storeScanner.close();
      }
      Thread.currentThread().setName(oldThreadName);
    }
  }
<pre>
This test is for HBASE-26465,
test {@link DefaultMemStore#clearSnapshot} and {@link DefaultMemStore#getScanners} execute
concurrently. The threads sequence before HBASE-26465 is:
1.The flush thread starts {@link DefaultMemStore} flushing after some cells have be added to
 {@link DefaultMemStore}.
2.The flush thread stopping before {@link DefaultMemStore#clearSnapshot} in
  {@link HStore#updateStorefiles} after completed flushing memStore to hfile.
3.The scan thread starts and stopping after {@link DefaultMemStore#getSnapshotSegments} in
  {@link DefaultMemStore#getScanners},here the scan thread gets the
  {@link DefaultMemStore#snapshot} which is created by the flush thread.
4.The flush thread continues {@link DefaultMemStore#clearSnapshot} and close
  {@link DefaultMemStore#snapshot},because the reference count of the corresponding
  {@link MemStoreLABImpl} is 0, the {@link Chunk}s in corresponding {@link MemStoreLABImpl}
  are recycled.
5.The scan thread continues {@link DefaultMemStore#getScanners},and create a
  {@link SegmentScanner} for this {@link DefaultMemStore#snapshot}, and increase the
  reference count of the corresponding {@link MemStoreLABImpl}, but {@link Chunk}s in
  corresponding {@link MemStoreLABImpl} are recycled by step 4, and these {@link Chunk}s may
  be overwritten by other write threads,which may cause serious problem.
After HBASE-26465,{@link DefaultMemStore#getScanners} and
{@link DefaultMemStore#clearSnapshot} could not execute concurrently.
</pre>
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java