[ 
https://issues.apache.org/jira/browse/JENA-2285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17495036#comment-17495036
 ] 

Andy Seaborne commented on JENA-2285:
-------------------------------------

{{VALUES}}, {{BIND}}, any pattern that sets variables used in the SERVICE. 
Makes no difference. The OPTIONAL

Either move the VALUES inside SERVICE or find a way not use the OPTIONAL.  A 
plain triple pattern is handled with constants passing down.

As you have it, ARQ is executing
{code}SELECT * { OPTIONAL { ?wikidata_city_iri wdt:P856 ?website.}{code}

i.e. all {{wdt:P856}}.

You can try increasing the heap size - on Linux set environment variable 
JVM_ARGS.  Java runs out of space, it gets very slow so it might even executed 
faster than 154,663 (which is I presume 2mins 34seconds).

{{qparse --print=opt --file=<TheQuery>}} can be used to show what the execution 
is.

{{(sequence)}} is the operator to pass prebound variables. {{(join)}} does not.


> Java Heap error when there is an optional in service block
> ----------------------------------------------------------
>
>                 Key: JENA-2285
>                 URL: https://issues.apache.org/jira/browse/JENA-2285
>             Project: Apache Jena
>          Issue Type: Bug
>    Affects Versions: Jena 4.4.0
>            Reporter: Dmitry Zhelobanov
>            Priority: Major
>
> Here is the query:
> {code:java}
> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX wdt: <http://www.wikidata.org/prop/direct/>
> PREFIX p: <http://www.wikidata.org/prop/>
> PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
> PREFIX ps: <http://www.wikidata.org/prop/statement/>
> PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
> PREFIX wikibase: <http://wikiba.se/ontology#>
> SELECT ?wikidata_city_iri ?website
> WHERE {
>   BIND(IRI("http://www.wikidata.org/entity/Q15757";) as ?id)
>   BIND(IRI(?id) AS ?wikidata_city_iri) .  
>   SERVICE <https://query.wikidata.org/sparql> {
> #Querying website   
>     OPTIONAL {
>       ?wikidata_city_iri wdt:P856 ?website.
>     } . 
>   }.
> } {code}
> When the query is executed I get"Java Heap Error" after, as I guess, Java 
> runs out of memory in the pool. The trace of the error is below.
> When OPTIONAL is commented out, then I get "no data" as expected.
> {code:java}
>  09:16:08 INFO  Fuseki          :: [5] POST 
> http://127.0.0.1:3030/WattTour/sparql
> 09:16:08 INFO  Fuseki          :: [5] Query = PREFIX owl: 
> <http://www.w3.org/2002/07/owl#> PREFIX rdf: 
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: 
> <http://www.w3.org/2000/01/rdf-schema#> PREFIX wdt: 
> <http://www.wikidata.org/prop/direct/> PREFIX p: 
> <http://www.wikidata.org/prop/> PREFIX pq: 
> <http://www.wikidata.org/prop/qualifier/> PREFIX ps: 
> <http://www.wikidata.org/prop/statement/> PREFIX psv: 
> <http://www.wikidata.org/prop/statement/value/> PREFIX wikibase: 
> <http://wikiba.se/ontology#> SELECT ?wikidata_city_iri ?website WHERE {   
> BIND(IRI("http://www.wikidata.org/entity/Q15757";) as ?id)   BIND(IRI(?id) AS 
> ?wikidata_city_iri) .    SERVICE <https://query.wikidata.org/sparql> { 
> #Querying website    OPTIONAL {       ?wikidata_city_iri wdt:P856 ?website.   
>   } .    }. }
> 09:18:43 WARN  HttpChannel     :: /$/ping
> javax.servlet.ServletException: Filtered request failed.
>         at 
> org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:384)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.apache.jena.fuseki.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:284)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.apache.jena.fuseki.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:247)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:210) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:506) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:223)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1571)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1378)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:463) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1544)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1300)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:711)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
>  ~[fuseki-server.jar:4.4.0]
>         at org.eclipse.jetty.server.Server.handle(Server.java:562) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:418) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:675) 
> ~[fuseki-server.jar:4.4.0]
>         at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:410) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319)
>  ~[fuseki-server.jar:4.4.0]
>         at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100) 
> ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:101)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:412)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:381)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:268)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.lambda$new$0(AdaptiveExecutionStrategy.java:138)
>  ~[fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:407)
>  [fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:894)
>  [fuseki-server.jar:4.4.0]
>         at 
> org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1038)
>  [fuseki-server.jar:4.4.0]
>         at java.lang.Thread.run(Thread.java:829) [?:?]
> Caused by: java.lang.OutOfMemoryError: Java heap space
> 09:18:43 WARN  Fuseki          :: [5] RC = 500 : Java heap space
> java.lang.OutOfMemoryError: Java heap space
> 09:18:43 INFO  Fuseki          :: [5] 500 Server Error (154,663 s){code}
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to