@Test
  public void testQueryResultsFromMembers() throws Exception {
    numberOfBuckets = 10;

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

    datastore3.invoke(() -> {
      Region<Integer, Portfolio> region = createPartitionedRegion();

      for (int i = 1; i <= NUMBER_OF_PUTS; i++) {
        region.put(i, new Portfolio(i));
      }

      Set<Integer> bucketsToQuery = new HashSet<>();
      for (int i = 0; i < numberOfBuckets; i++) {
        bucketsToQuery.add(i);
      }

      String[] queries =
          new String[] {"select * from " + SEPARATOR + regionName + " LIMIT " + LIMIT[0],
              "select * from " + SEPARATOR + regionName + " LIMIT " + LIMIT[1],
              "select * from " + SEPARATOR + regionName + " LIMIT " + LIMIT[2],
              "select * from " + SEPARATOR + regionName + " LIMIT " + LIMIT[3],
              "select * from " + SEPARATOR + regionName + " LIMIT " + LIMIT[4],
              "select * from " + SEPARATOR + regionName + " where ID > 10 LIMIT " + LIMIT[5],};

      for (int i = 0; i < queries.length; i++) {
        DefaultQuery query = (DefaultQuery) getCache().getQueryService().newQuery(queries[i]);
        final ExecutionContext executionContext =
            new QueryExecutionContext(null, getCache(), query);
        SelectResults results =
            query.getSimpleSelect().getEmptyResultSet(EMPTY_PARAMETERS, getCache(), query);

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

        CollatingTestHook testHook = new CollatingTestHook(queryEvaluator);
        queryEvaluator.queryBuckets(testHook);

        for (Map.Entry<Object, Integer> mapEntry : testHook.getResultsPerMember().entrySet()) {
          Integer resultsCount = mapEntry.getValue();
          assertThat(resultsCount.intValue()).isEqualTo(LIMIT[i]);
        }
      }
    });
  }
Test data loss (bucket 0) while the PRQueryEvaluator is processing the query loop
geode-core/src/distributedTest/java/org/apache/geode/cache/query/partitioned/PRQueryDUnitTest.java