Uploaded image for project: 'Blazegraph (by SYSTAP)'
  1. Blazegraph (by SYSTAP)
  2. BLZG-1151

SPARQL UPDATE should have nice error messages when namespace does not support named graphs

    Details

      Description

      SPARQL UPDATE should handle UPDATE requests gracefully when the request makes use of named graph semantics but the database namespace is not provisioned for named graphs. For example, the following stack trace is generated by a simple WITH INSERT WHERE request. The request can not be executed as intended because it refers to a named graph, but the namespace is setup for triples not named graphs. Appropriate and informative messages should be generated instead.

      com.bigdata.rdf.sail.webapp.client.HttpException: Status Code=500, Status Line=Server Error, Response=SPARQL-UPDATE: updateStr=PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
      PREFIX dc: <http://purl.org/dc/elements/1.1/> 
      PREFIX foaf: <http://xmlns.com/foaf/0.1/> 
      PREFIX ex: <http://example.org/> 
      PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
      
      WITH ex:graph1 INSERT {?x rdfs:label ?y . } WHERE {?x foaf:name ?y }
      java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: org.openrdf.query.UpdateExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
      	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
      	at java.util.concurrent.FutureTask.get(FutureTask.java:188)
      	at com.bigdata.rdf.sail.webapp.QueryServlet.doSparqlUpdate(QueryServlet.java:355)
      	at com.bigdata.rdf.sail.webapp.QueryServlet.doPost(QueryServlet.java:167)
      	at com.bigdata.rdf.sail.webapp.RESTServlet.doPost(RESTServlet.java:237)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:769)
      	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
      	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
      	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
      	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
      	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
      	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
      	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
      	at org.eclipse.jetty.server.Server.handle(Server.java:497)
      	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
      	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
      	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:610)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:539)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: java.util.concurrent.ExecutionException: org.openrdf.query.UpdateExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
      	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
      	at java.util.concurrent.FutureTask.get(FutureTask.java:188)
      	at com.bigdata.rdf.sail.webapp.QueryServlet$SparqlUpdateTask.call(QueryServlet.java:454)
      	at com.bigdata.rdf.sail.webapp.QueryServlet$SparqlUpdateTask.call(QueryServlet.java:1)
      	at com.bigdata.rdf.task.ApiTaskForIndexManager.call(ApiTaskForIndexManager.java:67)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at com.bigdata.rdf.task.AbstractApiTask.submitApiTask(AbstractApiTask.java:315)
      	at com.bigdata.rdf.sail.webapp.BigdataServlet.submitApiTask(BigdataServlet.java:220)
      	at com.bigdata.rdf.sail.webapp.QueryServlet.doSparqlUpdate(QueryServlet.java:352)
      	... 24 more
      Caused by: org.openrdf.query.UpdateExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
      	at com.bigdata.rdf.sparql.ast.eval.ASTEvalHelper.executeUpdate(ASTEvalHelper.java:1303)
      	at com.bigdata.rdf.sail.BigdataSailUpdate.execute2(BigdataSailUpdate.java:152)
      	at com.bigdata.rdf.sail.webapp.BigdataRDFContext$UpdateTask.doQuery(BigdataRDFContext.java:1629)
      	at com.bigdata.rdf.sail.webapp.BigdataRDFContext$AbstractQueryTask.innerCall(BigdataRDFContext.java:1296)
      	at com.bigdata.rdf.sail.webapp.BigdataRDFContext$AbstractQueryTask.call(BigdataRDFContext.java:1261)
      	at com.bigdata.rdf.sail.webapp.BigdataRDFContext$AbstractQueryTask.call(BigdataRDFContext.java:1)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	... 1 more
      Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
      	at com.bigdata.rdf.sparql.ast.optimizers.ASTRangeCountOptimizer.attachRangeCounts(ASTRangeCountOptimizer.java:140)
      	at com.bigdata.rdf.sparql.ast.optimizers.ASTRangeCountOptimizer.optimizeJoinGroup(ASTRangeCountOptimizer.java:77)
      	at com.bigdata.rdf.sparql.ast.optimizers.AbstractJoinGroupOptimizer.optimize(AbstractJoinGroupOptimizer.java:157)
      	at com.bigdata.rdf.sparql.ast.optimizers.AbstractJoinGroupOptimizer.optimize(AbstractJoinGroupOptimizer.java:97)
      	at com.bigdata.rdf.sparql.ast.optimizers.ASTOptimizerList.optimize(ASTOptimizerList.java:104)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convert(AST2BOpUtility.java:222)
      	at com.bigdata.rdf.sparql.ast.eval.ASTEvalHelper.evaluateGraphQuery(ASTEvalHelper.java:536)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUpdate.convertDeleteInsert(AST2BOpUpdate.java:979)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUpdate.convertUpdateSwitch(AST2BOpUpdate.java:417)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUpdate.convertUpdate(AST2BOpUpdate.java:279)
      	at com.bigdata.rdf.sparql.ast.eval.ASTEvalHelper.executeUpdate(ASTEvalHelper.java:1295)
      	... 9 more
      Caused by: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
      	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
      	at java.util.concurrent.FutureTask.get(FutureTask.java:188)
      	at com.bigdata.rdf.sparql.ast.optimizers.ASTRangeCountOptimizer.attachRangeCounts(ASTRangeCountOptimizer.java:124)
      	... 19 more
      Caused by: java.lang.UnsupportedOperationException
      	at com.bigdata.rdf.spo.SPORelation.getPredicate(SPORelation.java:1212)
      	at com.bigdata.rdf.spo.SPORelation.getAccessPath(SPORelation.java:1123)
      	at com.bigdata.rdf.spo.SPORelation.getAccessPath(SPORelation.java:1079)
      	at com.bigdata.rdf.store.AbstractTripleStore.getAccessPath(AbstractTripleStore.java:3121)
      	at com.bigdata.rdf.sparql.ast.optimizers.ASTRangeCountOptimizer.estimateCardinalities(ASTRangeCountOptimizer.java:199)
      	at com.bigdata.rdf.sparql.ast.optimizers.ASTRangeCountOptimizer.estimateCardinality(ASTRangeCountOptimizer.java:191)
      	at com.bigdata.rdf.sparql.ast.optimizers.ASTRangeCountOptimizer$RangeCountTask.call(ASTRangeCountOptimizer.java:171)
      	at com.bigdata.rdf.sparql.ast.optimizers.ASTRangeCountOptimizer$RangeCountTask.call(ASTRangeCountOptimizer.java:1)
      	... 4 more
      
      	at com.bigdata.rdf.sail.webapp.client.RemoteRepository.checkResponseCode(RemoteRepository.java:1754)
      	at com.bigdata.rdf.sail.webapp.client.RemoteRepository$SparqlUpdate.evaluate(RemoteRepository.java:1339)
      	at com.bigdata.rdf.sail.webapp.client.RemoteRepository$SparqlUpdate.evaluate(RemoteRepository.java:1324)
      	at com.bigdata.rdf.sail.webapp.TestSparqlUpdate.testInsertWhereWith(TestSparqlUpdate.java:626)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at junit.framework.TestCase.runTest(TestCase.java:176)
      	at junit.framework.TestCase.runBare(TestCase.java:141)
      	at junit.framework.TestResult$1.protect(TestResult.java:122)
      	at junit.framework.TestResult.runProtected(TestResult.java:142)
      	at junit.framework.TestResult.run(TestResult.java:125)
      	at junit.framework.TestCase.run(TestCase.java:129)
      	at junit.framework.TestSuite.runTest(TestSuite.java:255)
      	at junit.framework.TestSuite.run(TestSuite.java:250)
      	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:23)
      	at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      	at junit.framework.TestResult.runProtected(TestResult.java:142)
      	at junit.extensions.TestSetup.run(TestSetup.java:27)
      	at junit.framework.TestSuite.runTest(TestSuite.java:255)
      	at junit.framework.TestSuite.run(TestSuite.java:250)
      	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
      	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      

        Activity

        Hide
        michaelschmidt michaelschmidt added a comment -

        Affecting named graphs, this fits my collection quite well, putting it in my backlog.

        Show
        michaelschmidt michaelschmidt added a comment - Affecting named graphs, this fits my collection quite well, putting it in my backlog.
        Hide
        michaelschmidt michaelschmidt added a comment -

        Added a human-readable error message to the underlying code in the SPORelation. Note that this code snippet is also called for queries such as SELECT { GRAPH <http://someConstantUri> { ? } }. It is hard to predict which other constructs may cause such problems, so I?d propose that the change is enough (we can still incrementally improve error messages when detecting other sources generating misleading errors) -- unless you have any concrete ideas, @Bryan?

        Fixed in branch ticket_1105, issuing pull request.

        Show
        michaelschmidt michaelschmidt added a comment - Added a human-readable error message to the underlying code in the SPORelation. Note that this code snippet is also called for queries such as SELECT { GRAPH < http://someConstantUri > { ? } }. It is hard to predict which other constructs may cause such problems, so I?d propose that the change is enough (we can still incrementally improve error messages when detecting other sources generating misleading errors) -- unless you have any concrete ideas, @Bryan? Fixed in branch ticket_1105, issuing pull request.
        Hide
        michaelschmidt michaelschmidt added a comment -

        Extended previous fix: named exception (QuadsOperationInTriplesModeException), plus some static checking for quads constructs at parsing time throwing the exception. Adjusted a couple of test cases to deal with the new behavior (namely, exceptions thrown at parsing time).

        Show
        michaelschmidt michaelschmidt added a comment - Extended previous fix: named exception (QuadsOperationInTriplesModeException), plus some static checking for quads constructs at parsing time throwing the exception. Adjusted a couple of test cases to deal with the new behavior (namely, exceptions thrown at parsing time).
        Hide
        michaelschmidt michaelschmidt added a comment -

        Merged branch into master upon CI success.

        Show
        michaelschmidt michaelschmidt added a comment - Merged branch into master upon CI success.

          People

          • Assignee:
            michaelschmidt michaelschmidt
            Reporter:
            bryanthompson bryanthompson
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: