@Test
  public void testSimulatedDataLossBeforeQueryProcessor() throws Exception {
    numberOfBuckets = 11;

    datastore1.invoke(() -> {
      createPartitionedRegion();
    });
    datastore2.invoke(() -> {
      createPartitionedRegion();
    });

    accessor.invoke(() -> {
      createPartitionedRegionAccessor();
    });

    addIgnoredException("Data loss detected", accessor);

    accessor.invoke(() -> {
      Region<Integer, String> region = getCache().getRegion(regionName);

      // Create bucket one
      region.put(1, "one");

      DefaultQuery query = (DefaultQuery) getCache().getQueryService()
          .newQuery("select distinct * from " + SEPARATOR + regionName);
      final ExecutionContext executionContext = new QueryExecutionContext(null, getCache(), query);
      SelectResults results =
          query.getSimpleSelect().getEmptyResultSet(EMPTY_PARAMETERS, getCache(), query);

      // Fake data loss
      Set<Integer> buckets = new HashSet<>();
      for (int i = 0; i < 3; i++) {
        buckets.add(i);
      }

      PartitionedRegion partitionedRegion = (PartitionedRegion) region;
      PartitionedRegionQueryEvaluator queryEvaluator =
          new PartitionedRegionQueryEvaluator(partitionedRegion.getSystem(), partitionedRegion,
              query, executionContext, EMPTY_PARAMETERS, results, buckets);

      assertThatThrownBy(() -> queryEvaluator.queryBuckets(null))
          .isInstanceOf(QueryException.class);
    });
  }
Simulate a data loss (buckets 0 and 2) before the PRQueryEvaluator begins the query loop
geode-core/src/distributedTest/java/org/apache/geode/cache/query/partitioned/PRQueryDUnitTest.java