@Override
    public void postPut(final ObserverContext<? extends RegionCoprocessorEnvironment> c,
      final Put put, final WALEdit edit, final Durability durability) throws IOException {
      HRegion region = (HRegion) c.getEnvironment().getRegion();
      super.postPut(c, put, edit, durability);

      if (Bytes.equals(put.getRow(), Bytes.toBytes("row2"))) {
        region.flush(false);
        Assert.assertTrue(region.getMemStoreDataSize() >= 0);
      }
    }
Test that verifies we do not have memstore size negative when a postPut/Delete hook is
slow/expensive and a flush is triggered at the same time the coprocessow is doing its work. To
simulate this we call flush from the coprocessor itself
hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestNegativeMemStoreSizeWithSlowCoprocessor.java