IndexConnection must be open

Sometimes whenever I am trying to find out the count of predicates in my data using group by and count operator. It is giving me "IndexConnection must be open." error.
What is that error is about?
Please help me to remove this error.

server status:
Connection Timeout : 10m
Export Storage Directory : .exports
Memory Heap : 3.3G (Max: 11G)
Memory Mode : DEFAULT
Memory Query Blocks : 0B (Max: 4.6G)
Memory RSS : 18G
Platform Arch : amd64
Platform OS : Linux 3.10.0-693.5.2.el7.x86_64, Java 1.8.0_151
Query All Graphs : false
Query Timeout : 30m
Security Disabled : false

Hi! Can you please share the query you are running, explain out (query plan) and the stack trace for the server log? Which version of Stardog and roughly how large your database is?

Hi,
prefix : http://rdf.freebase.com/ns/
prefix key: http://rdf.freebase.com/key/en

Query:
select ?p (count(*) as ?count){
?s ?p ?o .
} group by(?p) order by desc(?count)
limit 10
I am using freebase(3.2 billion triples)
stack trace:
ERROR 2019-10-15 17:22:44,012 [stardog-user-14] com.complexible.stardog.protocols.http.server.StardogHttpServiceLoader:accept(231): An unexpected exception was handled by the server
com.stardog.stark.query.QueryExecutionFailure: IndexConnection must be open.
at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:82) ~[stardog-utils-rdf-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.TransactionManagedQueryResult.hasNext(TransactionManagedQueryResult.java:61) ~[stardog-7.0.2.jar:?]
at com.stardog.stark.query.ClosingSpliterator.forEachRemaining(ClosingSpliterator.java:37) ~[stardog-stark-query-api-7.0.2.jar:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) ~[?:1.8.0_151]
at com.stardog.stark.query.io.QueryResultWriters.write(QueryResultWriters.java:142) ~[stardog-stark-query-io-7.0.2.jar:?]
at com.stardog.stark.query.io.QueryResultWriters.write(QueryResultWriters.java:127) ~[stardog-stark-query-io-7.0.2.jar:?]
at com.complexible.stardog.protocols.http.server.ProtocolUtils.writeTupleResponse(ProtocolUtils.java:570) ~[stardog-protocols-http-server-7.0.2.jar:?]
at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:480) ~[stardog-protocols-http-server-7.0.2.jar:?]
at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:464) ~[stardog-protocols-http-server-7.0.2.jar:?]
at com.complexible.stardog.protocols.http.server.SPARQLProtocol.executeQuery(SPARQLProtocol.java:127) ~[stardog-protocols-http-server-7.0.2.jar:?]
at com.complexible.stardog.protocols.http.server.SPARQLProtocol.get(SPARQLProtocol.java:83) ~[stardog-protocols-http-server-7.0.2.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:192) ~[stardog-protocols-http-server-7.0.2.jar:?]
at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) [shiro-core-1.3.0.jar:1.3.0]
at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) [shiro-core-1.3.0.jar:1.3.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_151]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
Caused by: java.lang.IllegalStateException: IndexConnection must be open.
at com.google.common.base.Preconditions.checkState(Preconditions.java:507) ~[guava-26.0-jre.jar:?]
at com.complexible.stardog.index.BaseIndexConnection.assertOpen(BaseIndexConnection.java:132) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.index.BaseIndexConnection.getIndex(BaseIndexConnection.java:49) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.index.mvcc.MvccIndexConnection.begin(MvccIndexConnection.java:125) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.index.impl.DelegatingIndexConnection.begin(DelegatingIndexConnection.java:85) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.index.impl.DelegatingIndexConnection.begin(DelegatingIndexConnection.java:85) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.index.IndexUtils.initTx(IndexUtils.java:91) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.ExecutionContext.getReader(ExecutionContext.java:249) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.ExecutionContext.getMappings(ExecutionContext.java:266) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.AbstractOperator.getMappings(AbstractOperator.java:76) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.project(SingleProjectionOp.java:112) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:88) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:29) ~[stardog-7.0.2.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:147) ~[stardog-utils-common-7.0.2.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:134) ~[stardog-utils-common-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.SliceOp._hasNext(SliceOp.java:87) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.SliceOp.computeNext(SliceOp.java:95) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.SliceOp.computeNext(SliceOp.java:26) ~[stardog-7.0.2.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:147) ~[stardog-utils-common-7.0.2.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:134) ~[stardog-utils-common-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:114) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:26) ~[stardog-7.0.2.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:147) ~[stardog-utils-common-7.0.2.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:134) ~[stardog-utils-common-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:119) ~[stardog-7.0.2.jar:?]
at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:40) ~[stardog-7.0.2.jar:?]
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) ~[guava-26.0-jre.jar:?]
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) ~[guava-26.0-jre.jar:?]
at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:78) ~[stardog-utils-rdf-7.0.2.jar:?]
... 16 more

We will need to improve the error message but the likely reason is that the database connection was closed on timeout while the query was running. This is a very expensive query since it needs to count triples for every predicate before returning the most frequently occurring ones. Try to set database.connection.timeout to something very high, like 1h, in stardog.properties before restarting the server.

Cheers,
Pavel

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.