Skip to content

Commit

Permalink
fix: gremlin exec timeout cause statement unclose (#1643)
Browse files Browse the repository at this point in the history
fix #1639
  • Loading branch information
z7658329 authored Nov 12, 2021
1 parent 299449b commit 2dcfbfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ private Set<Id> queryIds() {
}

public static <T> ListIterator<T> toList(Iterator<T> iterator) {
return new ListIterator<>(Query.DEFAULT_CAPACITY, iterator);
try {
return new ListIterator<>(Query.DEFAULT_CAPACITY, iterator);
} finally {
CloseableIterator.closeIterator(iterator);
}
}

public static <T> void fillList(Iterator<T> iterator, List<T> list) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
import com.baidu.hugegraph.exception.NotSupportException;
import com.baidu.hugegraph.iterator.CIter;
import com.baidu.hugegraph.util.E;
import com.baidu.hugegraph.util.Log;
import org.slf4j.Logger;

public abstract class BackendEntryIterator implements CIter<BackendEntry> {

private static final Logger LOG = Log.logger(BackendEntryIterator.class);
public static final long INLINE_BATCH_SIZE = Query.COMMIT_BATCH;

protected final Query query;
Expand Down Expand Up @@ -115,7 +118,16 @@ protected final boolean reachLimit() {
}

protected final boolean reachLimit(long count) {
checkInterrupted();
try {
checkInterrupted();
} catch (Throwable e) {
try {
this.close();
} catch (Throwable ex) {
LOG.warn("Failed to close backend entry iterator for interrupted query", ex);
}
throw e;
}
return this.query.reachLimit(count);
}

Expand Down

0 comments on commit 2dcfbfa

Please sign in to comment.