Skip to content

Commit

Permalink
Ensure cached query results are discarded
Browse files Browse the repository at this point in the history
Send next token one more time to make the client acknowledge results to
discard cached query results
  • Loading branch information
arhimondr authored and martint committed Nov 4, 2021
1 parent 12b3efc commit da2cd0a
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ private synchronized QueryResults getNextResult(long token, UriInfo uriInfo, Dat
QueryInfo queryInfo = queryManager.getFullQueryInfo(queryId);
queryManager.recordHeartbeat(queryId);

closeExchangeClientIfNecessary(queryInfo);

// fetch result data from exchange
QueryResultRows resultRows = removePagesFromExchange(queryInfo, targetResultSize.toBytes());

Expand All @@ -426,14 +428,12 @@ private synchronized QueryResults getNextResult(long token, UriInfo uriInfo, Dat
updateCount = updatedRowsCount.orElse(null);
}

closeExchangeClientIfNecessary(queryInfo);

// advance next token
// only return a next if
// (1) the query is not done AND the query state is not FAILED
// OR
// (2)there is more data to send (due to buffering)
if ((!queryInfo.isFinalQueryInfo() && queryInfo.getState() != FAILED) || !exchangeClient.isClosed()) {
if (queryInfo.getState() != FAILED && (!queryInfo.isFinalQueryInfo() || !exchangeClient.isClosed() || (lastResult != null && lastResult.getData() != null))) {
nextToken = OptionalLong.of(token + 1);
}
else {
Expand Down

0 comments on commit da2cd0a

Please sign in to comment.