Skip to content

Commit

Permalink
Fix segment pruning that can break server subquery (#9090)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackie-Jiang authored Jul 22, 2022
1 parent 7142efe commit f70c38b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ private DataTable processQueryInternal(ServerQueryRequest queryRequest, Executor
return dataTable;
}

// NOTE: This method might change indexSegments. Do not use it after calling this method.
private DataTable processQuery(List<IndexSegment> indexSegments, QueryContext queryContext, TimerContext timerContext,
ExecutorService executorService, @Nullable StreamObserver<Server.ServerResponse> responseObserver,
boolean enableStreaming)
Expand Down Expand Up @@ -568,7 +569,9 @@ private void handleSubquery(ExpressionContext expression, List<IndexSegment> ind
subqueryExpression.getLiteral());
// Execute the subquery
subquery.setEndTimeMs(endTimeMs);
DataTable dataTable = processQuery(indexSegments, subquery, timerContext, executorService, null, false);
// Make a clone of indexSegments because the method might modify the list
DataTable dataTable =
processQuery(new ArrayList<>(indexSegments), subquery, timerContext, executorService, null, false);
IdSet idSet = dataTable.getObject(0, 0);
String serializedIdSet = idSet.toBase64String();
// Rewrite the expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public interface SegmentPruner {
* <p>Override this method for the pruner logic.
*
* @param segments The list of segments to be pruned. Implementations must not modify the list.
* TODO: Revisit this because the caller doesn't require not changing the input segments
*/
List<IndexSegment> prune(List<IndexSegment> segments, QueryContext query);
}

0 comments on commit f70c38b

Please sign in to comment.