@Test
  public void recoversRedundancyAfterRecreatingRegion() {
    vm0.invoke(() -> createPartitionedRegion(1, -1, 113, true));
    vm1.invoke(() -> createPartitionedRegion(1, -1, 113, true));

    vm0.invoke(() -> createData(0, 1, "a", partitionedRegionName));

    Set<Integer> bucketsOnVM0 = vm0.invoke(() -> getBucketList(partitionedRegionName));
    Set<Integer> bucketsOnVM1 = vm1.invoke(() -> getBucketList(partitionedRegionName));

    assertThat(bucketsOnVM0).containsOnly(0);
    assertThat(bucketsOnVM1).containsOnly(0);

    vm1.invoke(() -> getCache().close());

    // This shouldn't create any buckets, because we know there are offline copies
    vm2.invoke(() -> createPartitionedRegion(1, -1, 113, true));

    assertThat(vm0.invoke(() -> getOfflineMembers(0))).hasSize(1);
    // Note, vm2 will consider vm1 as "online" because vm2 doesn't host the bucket
    assertThat(vm2.invoke(() -> getOnlineMembers(0))).hasSize(2);

    Set<Integer> bucketsOnVM2 = vm2.invoke(() -> getBucketList(partitionedRegionName));
    assertThat(bucketsOnVM2).isEmpty();

    vm1.invoke(() -> createPartitionedRegion(1, -1, 113, true));

    // Make sure we restored the buckets in the right place
    assertThat(vm0.invoke(() -> getBucketList(partitionedRegionName))).isEqualTo(bucketsOnVM0);
    assertThat(vm1.invoke(() -> getBucketList(partitionedRegionName))).isEqualTo(bucketsOnVM1);
    assertThat(vm2.invoke(() -> getBucketList(partitionedRegionName))).isEmpty();

    assertThat(vm0.invoke(() -> getOfflineMembers(0))).isEmpty();
    assertThat(vm1.invoke(() -> getOfflineMembers(0))).isEmpty();

    InternalDistributedMember memberVM1 = vm1.invoke(this::getInternalDistributedMember);
    vm2.invoke(() -> {
      PartitionedRegion region = (PartitionedRegion) getCache().getRegion(partitionedRegionName);
      assertThat(region.getDataStore().moveBucket(0, memberVM1, false)).isTrue();
    });

    assertThat(vm0.invoke(() -> getOfflineMembers(0))).isEmpty();
    assertThat(vm1.invoke(() -> getOfflineMembers(0))).isEmpty();
    assertThat(vm2.invoke(() -> getOfflineMembers(0))).isEmpty();

    assertThat(vm0.invoke(() -> getBucketList(partitionedRegionName))).containsOnly(0);
    assertThat(vm1.invoke(() -> getBucketList(partitionedRegionName))).isEmpty();
    assertThat(vm2.invoke(() -> getBucketList(partitionedRegionName))).containsOnly(0);

    // Destroy VM2
    vm2.invoke(() -> getCache().getRegion(partitionedRegionName).localDestroyRegion());

    assertThat(vm0.invoke(() -> getOfflineMembers(0))).isEmpty();
    assertThat(vm1.invoke(() -> getOfflineMembers(0))).isEmpty();

    // Close down VM 1
    vm1.invoke(() -> getCache().close());

    assertThat(vm0.invoke(() -> getOfflineMembers(0))).isEmpty();

    // This should recover redundancy, because vm2 was destroyed
    vm1.invoke(() -> createPartitionedRegion(1, -1, 113, true));

    assertThat(vm0.invoke(() -> getBucketList(partitionedRegionName))).containsOnly(0);
    assertThat(vm1.invoke(() -> getBucketList(partitionedRegionName))).containsOnly(0);

    assertThat(vm0.invoke(() -> getOfflineMembers(0))).isEmpty();
    assertThat(vm1.invoke(() -> getOfflineMembers(0))).isEmpty();
  }
RegressionTest that we don't record our old member ID as offline, preventing redundancy
recovery in the future.

<p>
TRAC 41341: Redundancy not restored after reinitializing after locally destroying persistent PR
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionRegressionTest.java