@Test
  public void testGIIDuringDestroy() throws Exception {
    vm0.invoke(() -> createReplicateRegion(regionName, getDiskDirs(getVMId())));

    vm2.invoke(() -> LATCH.set(new CountDownLatch(1)));

    AsyncInvocation<Void> createPersistentRegionAsyncOnVM2 = vm2.invokeAsync(() -> {
      LATCH.get().await(TIMEOUT_MILLIS, MILLISECONDS);
      createReplicateRegion(regionName, getDiskDirs(getVMId()));
    });

    // Add a hook which will disconnect from the distributed
    // system when the initial image message shows up.
    vm1.invoke(() -> {
      SLEEP.set(new CountDownLatch(1));
      DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
        @Override
        public void beforeProcessMessage(ClusterDistributionManager dm,
            DistributionMessage message) {
          if (message instanceof DestroyRegionMessage) {
            vm2.invoke(() -> LATCH.get().countDown());
            try {
              SLEEP.get().await(TIMEOUT_MILLIS, MILLISECONDS);
            } catch (InterruptedException e) {
              errorCollector.addError(e);
            } finally {
              DistributionMessageObserver.setInstance(null);
            }
          }
        }
      });
    });

    vm1.invoke(() -> createReplicateRegion(regionName, getDiskDirs(getVMId())));

    AsyncInvocation<Void> destroyRegionInVM0 = vm0.invokeAsync(() -> {
      getCache().getRegion(regionName).destroyRegion();
    });

    vm1.invoke(() -> {
      SLEEP.get().countDown();
      await().ignoreException(RegionDestroyedException.class).untilAsserted(() -> {
        assertThat(getCache().getRegion(regionName)).isNull();
      });
    });

    createPersistentRegionAsyncOnVM2.await();
    destroyRegionInVM0.await();

    vm2.invoke(() -> {
      DistributedRegion region = (DistributedRegion) getCache().getRegion(regionName);
      PersistenceAdvisor persistAdvisor = region.getPersistenceAdvisor();
      assertThat(persistAdvisor.getMembershipView().getOfflineMembers()).isEmpty();
    });
  }
Test to make sure we don't leak any persistent ids if a member does GII while a distributed
destroy is in progress
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java