Query does not terminate in Jena Driver but works fine (and fast) in isql

Hello,

I’m using the virtuoso.jena.driver to execute a query.

The very same query runs in isql in under a minute.
When I execute it with

        VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create (q, db);
        vqe.execSelect();

it does not terminate (in more than hours).

What am I doing wrong?
Is there a better way to query my Virtuoso with SPARQL via Java?

When connecting via the Virtuoso Jena Provider are you connecting as the same user as the when connecting via “isql” ?

What is the version of the Virtuoso server (virtuoso-t -? for opensoure or virtuoso-iodbc-t -? for commercial) and the Jena provider (java -jar virt_jena.jar) ?

The Virtuoso “trace_on()” command can be run to enable server side tracing to the virtuoso.log file and the query executed via Jena and isql and the log checked to see if Jena might be changing the query in anyway before passing to Virtuoso.

I am using virtuoso-opensource-7 via docker.
and using virtjdbc4 and virt_jena3

I am not sure I am using the same user. How does that make a difference?

I’ve tried running the same query using the HTTP endpoint via standard Jena RDFConnectionRemote and that works perfectly

I still would like to see the versions of the components being used ie by running the following commands on the binaries:

 virtuoso-t -?
 java -jar virt_jen3.jar
 java -jar virtjdbc4.jar

The user can make a difference especially if RDF graph groups/security is in place as different users have different access levels to graphs which can slow queries down.

via isql I presume you login as dba, via the /sparql endpoint queries run as the special internal SPARQL user and via Jena what user are you logging in as ?

 virtuoso-t -?

Virtuoso Open Source Edition (Column Store) (multi threaded)
Version 7.2.6-rc1.3230-pthreads as of Feb  4 2020 (a11a8e37b)
Compiled for Linux (x86_64-generic_glibc25-linux-gnu)
Copyright (C) 1998-2020 OpenLink Software
java -jar virtjdbc4.jar
OpenLink Virtuoso(TM) Driver with SSL support for JDBC(TM) Version 4.0 [Build 3.111]

java -jar virt_jena3.jar 
OpenLink Virtuoso(TM) Provider for Jena(TM) Version 3.0.0 [Build 1.31]

via Jena i use dba login

If you are connecting with isql and jena as the same user ie dba then this would not be the source of the problem.

I note you seem to have built Virtuoso from the git develop/7 tree back in Feb 2020, with the version of the Jena Provider being Version 3.0.0 [Build 1.31] whereas the version of the latest provider is Version 3.0.0 [Build 1.33], thus I would recommend updating you binary and Java components (jena & JDBC) to the latest from develop/7 and retest.

Should the problem persist as indicated previously, the Virtuoso “trace_on()” command can be run to enable server side tracing to the virtuoso.log file and the query executed via Jena and isql and the log checked to see if Jena might be changing the query in anyway before passing to Virtuoso.

I’ve checked the log.
It seems that when I send it out with Jena, the query is replicated at least 3 times. hence the same query is running in parallel multiple times.

This seems as a bug in the Jena driver. Can you reproduce it?

Did you update your Jena provider to the latest Version 3.0.0 [Build 1.33] build ?

Can you provide the output of the log showing the query execution occurring multiple time with the Jena provider ?

Can you provide a test program to recreate the issue ?

From this page:
http://vos.openlinksw.com/owiki/wiki/VOS/VOSDownload#Jena%20Provider

The latest is still build 1.31
Am I using the wrong page?

I am referring to the latest components available from the Virtuoso open source git repo:

https://github.com/openlink/virtuoso-opensource/blob/develop/7/binsrc/jena3/virt_jena3.jar
https://github.com/openlink/virtuoso-opensource/blob/develop/7/libsrc/JDBCDriverType4/virtjdbc4.jar