fix: add timeout check in next query page fetching
@@ -1391,9 +1391,10 @@ public final class OConnectionBinaryExecutor implements OBinaryRequestExecutor {
@Override
public OBinaryResponse executeQueryNextPage(OQueryNextPageRequest request) {
+ ODatabaseDocumentInternal database = connection.getDatabase();
+ OrientDBInternal orientDB = database.getSharedContext().getOrientDB();
OLocalResultSetLifecycleDecorator rs =
- (OLocalResultSetLifecycleDecorator)
- connection.getDatabase().getActiveQuery(request.getQueryId());
+ (OLocalResultSetLifecycleDecorator) database.getActiveQuery(request.getQueryId());
if (rs == null) {
throw new ODatabaseException(
@@ -1401,10 +1402,13 @@ public final class OConnectionBinaryExecutor implements OBinaryRequestExecutor {
"No query with id '%s' found probably expired session", request.getQueryId()));
}
+ try {
+ orientDB.startCommand(Optional.empty());
// copy the result-set to make sure that the execution is successful
List<OResultInternal> rsCopy = new ArrayList<>(request.getRecordsPerPage());
int i = 0;
- // if it's OInternalResultSet it means that it's a Command, not a Query, so the result has to be
+ // if it's OInternalResultSet it means that it's a Command, not a Query, so the result has to
+ // be
// sent as it is, not streamed
while (rs.hasNext() && (rs.isDetached() || i < request.getRecordsPerPage())) {
rsCopy.add((OResultInternal) rs.next());
@@ -1412,7 +1416,16 @@ public final class OConnectionBinaryExecutor implements OBinaryRequestExecutor {
}
boolean hasNext = rs.hasNext();
return new OQueryResponse(
- rs.getQueryId(), false, rsCopy, rs.getExecutionPlan(), hasNext, rs.getQueryStats(), false);
+ rs.getQueryId(),
+ false,
+ rsCopy,
+ rs.getExecutionPlan(),
+ hasNext,
+ rs.getQueryStats(),
+ false);
+ } finally {
+ orientDB.endCommand();
+ }
}
@Override
