You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Timay <to...@trustwave.com> on 2018/01/02 22:24:19 UTC
Cache.query with ScanQuery Hangs forever
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/
Re: Cache.query with ScanQuery Hangs forever
Posted by vkulichenko <va...@gmail.com>.
Tim,
Can you try replacing lambda with a static class? Does it help?
-Val
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Cache.query with ScanQuery Hangs forever
Posted by Timay <to...@trustwave.com>.
it looks like it was classpath loading issue with "Entry::getValue". Since
this is a lambda it will try to serialize the containing class which is not
expected at the cluster nor necessary. When i killed the process I got stack
trace(below) point to that. So i assume some issue with around the class
path loading.
/class org.apache.ignite.IgniteCheckedException: Query execution failed:
GridCacheQueryBean [qry=GridCacheQueryAdapter [type=SCAN, clsName=null,
clause=null, filter=ManagerServiceImpl$InactivePredicate@220fd437,
transform=*ManagerServiceImpl$$Lambda$32/1251084807@7b343e3*/
This is something i have seen before during a compute operation, during an
exception handling we had a library that was not supplied to the cluster get
referenced and it failed silently but would not release the thread. Are any
issues known around that? I may take a look if i can, but any info would me
begin.
Thanks.
Tim
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Cache.query with ScanQuery Hangs forever
Posted by vkulichenko <va...@gmail.com>.
I can't reproduce this behavior and actually it sounds very weird that scan
query can hang with empty cache. Do you have a complete test reproducing the
problem that you can share with us?
-Val
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/