Hey all, using Ignite 2.1 we are trying to use an IgniteCache.query to
retrieve records that match our query. We attempt this query on a timed
basis and it gets executed when their may be no records on the cache.
Example below.
ScanQuery<String,SessionData> query = new ScanQuery<>(new
MatchingPredicate(name));
List<Data> matches = _cache.query(query, Entry::getValue).getAll();
>From the thread dump (below) it looks like in
GridCacheQueryFutureAdapter.internalIterator we get put into a
wait(Long.MAX_VAL). Which will just hang until i am long gone. I am
guessing, since i am not sure of all the uses cases, that their is a bug
when a cache is empty and a query is run we may end up in the wait. So my
questions are:
1) Whats the point of such a long wait?
2) Can we adjust the timeout on a ScanQuery basis?
"Thread-15" - Thread t@79
java.lang.Thread.State: TIMED_WAITING
at java.lang.Object.wait(Native Method)
- waiting on <46b8b561> (a
org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryFuture)
at
org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter.internalIterator(GridCacheQueryFutureAdapter.java:304)
at
org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter.next(GridCacheQueryFutureAdapter.java:161)
at
org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager$5.onHasNext(GridCacheDistributedQueryManager.java:635)
at
org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy$1$1.onHasNext(IgniteCacheProxy.java:579)
at
org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
at
org.apache.ignite.internal.util.lang.GridIteratorAdapter.hasNext(GridIteratorAdapter.java:45)
at
org.apache.ignite.internal.processors.cache.QueryCursorImpl.getAll(QueryCursorImpl.java:114)
Ease of viewing code
GridCacheQueryFutureAdapter.java
private Iterator<R> internalIterator() throws IgniteCheckedException {
checkError();
Iterator<R> it = null;
while (it == null || !it.hasNext()) {
Collection<R> c;
synchronized (this) {
it = iter;
if (it != null && it.hasNext())
break;
c = queue.poll();
if (c != null)
it = iter = c.iterator();
if (isDone() && queue.peek() == null)
break;
}
if (c == null && !isDone()) {
loadPage();
long timeout = qry.query().timeout();
long waitTime = timeout == 0 ? Long.MAX_VALUE : timeout -
(U.currentTimeMillis() - startTime);
if (waitTime <= 0) {
it = Collections.<R>emptyList().iterator();
break;
}
synchronized (this) {
try {
if (queue.isEmpty() && !isDone())
* wait(waitTime); *
//line 304
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IgniteCheckedException("Query was interrupted: " + qry,
e);
}
}
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/