5 Replies Latest reply on Jul 9, 2012 8:35 PM by alwu-Oracle

    Canceling QueryExecution

      I have a question about the execution of a qexec.execSelect() statement running a select sparql query.

      I have found two functions 'close()' and 'abort()' however both of those do not cancel (and force) the query execution until the next ResultSet.hasNext() method is called. The query appears to be on the Database processing rows and hasn't returned the data back requestor.

      Is there a way to programmatically force the Sparql Execution of the query to die from a second thread?

        • 1. Re: Canceling QueryExecution

          Sorry for the late response (due to traveling).

          The time out in Jena Adapter for release has been designed to be able to cancel an execution even inside a hasNext() call.
          The way to use it is through the timeout= setting in the SPARQL query.

          Please search for Test10.java in the following document.


          Hope it helps,

          • 2. Re: Canceling QueryExecution

            We have a timeout in place, however we don't want to query to run all the way to the timeout length if our client has already canceled their request.

            That being said, in a second thread, is there a way to kill the execution of the sparql query. For a Statement i can call Statment.cancel(). I was hoping that QueryExecution.abort() or QueryExection.close() would work, i also tried to close the model (connection) [ModelOracleSem.close()] and nothing forced the process on the database to die.

            I also tried to load up the OracleQueryMgtServlet in my web.xml, however when I made the call to the URL with ?abortqid=<qid> it did nothing to the execution of the corresponding query. I found that's in the Joseki packaged with the Oracle Jena Adapater.

            I appreciate your help.
            • 3. Re: Canceling QueryExecution
              Hi Michael,

              I assume you have set qid in the sparql queries. e.g.

              PREFIX ORACLE_SEM_FS_NS: <http://example.com/semtech#qid=8761>

              ?abortqid should work as long as your query is still being executed. Behind
              the scenes, we invoke cancel on the JDBC statement object. The abort will
              have no effect if you have already started fetching answers. For your application, does it take
              a long time to complete fetching all answers?

              If I understand your situation correctly, the following are true:
              - Timeout works as expected
              - Your client wants to cancel the query before timeout

              Then can you shorten the timeout? Or maybe you can use add something like "limit 5 offset 10"
              to your queries?


              • 4. Re: Canceling QueryExecution

                I will put the service call to the servlet. To abort the qid specified

                How can I time the difference between query execution and fetching all answers? The first time .hasNext() is called is the longest wait.

                • 5. Re: Canceling QueryExecution
                  Hi Michael,

                  The best thing you can do is to note down the elapsed time between issuing the query execution and completing the first hasNext(),
                  and the elapsed time between the first hasNext() and iterating through all the answers.