You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Matteo Busanelli (GMail)" <ma...@gmail.com> on 2012/01/12 10:39:31 UTC

SPARQL: Joseki and "Already in transaction" error for concurrent query context

Hi everyone,
  I'm tryng to use Joseki with SDB (on MySQL 5.1) for serving multithread application queries.
If all queries doesen't overlapp everything works well.
The problem comes wehn two different thread make concurrent queries that overlaps and I got this error:

======================= log Stacktrace =====================
2012-01-11 13:05:59 - log                       :: REQUEST /sparql on org.mortbay.jetty.HttpConnection@1181de1
2012-01-11 13:05:59 - log                       :: sessionManager=org.mortbay.jetty.servlet.HashSessionManager@f9f91d
2012-01-11 13:05:59 - log                       :: session=null
2012-01-11 13:05:59 - log                       :: servlet=SPARQL service processor
2012-01-11 13:05:59 - log                       :: chain=null
2012-01-11 13:05:59 - log                       :: servlet holder=SPARQL service processor
2012-01-11 13:05:59 - Servlet                   :: Request: http://localhost:2020/sparql
2012-01-11 13:05:59 - Servlet                   :: Service URI = <sparql>
2012-01-11 13:05:59 - SPARQL                    :: Query: PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX  owl: 
<http://www.w3.org/2002/07/owl#> PREFIX  rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>  SELECT DISTINCT  ?resourceURI ?resourceType 
?resourceLabel ?resourceComment WHERE   { GRAPH <http://www.imonlinfo.it/ontologie/grafi/test/bps-all>       { ?resourceURI rdfs:domain 
<http://www.imolinfo.it/ontologie/ea/v1.3/application-domain-model#Application> .         ?resourceURI rdf:type ?resourceType         OPTIONAL { 
?resourceURI rdfs:label ?resourceLabel             FILTER ( lang(?resourceLabel) = "en" )           }         OPTIONAL           { ?resourceURI 
rdfs:comment ?resourceComment             FILTER ( lang(?resourceComment) = "en" )           }         OPTIONAL           { ?resourceURI rdfs:label 
?resourceLabel             FILTER ( lang(?resourceLabel) = "it" )           }         OPTIONAL           { ?resourceURI rdfs:comment 
?resourceComment             FILTER ( lang(?resourceComment) = "it" )           }         OPTIONAL           { ?resourceURI rdfs:label 
?resourceLabel }         OPTIONAL           { ?resourceURI rdfs:comment ?resourceComment }       }   }
2012-01-11 13:05:59 - SPARQL                    :: OK/select: PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX  owl: 
<http://www.w3.org/2002/07/owl#> PREFIX  rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>  SELECT DISTINCT  ?resourceURI ?resourceType 
?resourceLabel ?resourceComment WHERE   { GRAPH <http://www.imonlinfo.it/ontologie/grafi/test/bps-all>       { ?resourceURI rdfs:domain 
<http://www.imolinfo.it/ontologie/ea/v1.3/application-domain-model#Application> .         ?resourceURI rdf:type ?resourceType         OPTIONAL { 
?resourceURI rdfs:label ?resourceLabel             FILTER ( lang(?resourceLabel) = "en" )           }         OPTIONAL           { ?resourceURI 
rdfs:comment ?resourceComment             FILTER ( lang(?resourceComment) = "en" )           }         OPTIONAL           { ?resourceURI rdfs:label 
?resourceLabel             FILTER ( lang(?resourceLabel) = "it" )           }         OPTIONAL           { ?resourceURI rdfs:comment 
?resourceComment             FILTER ( lang(?resourceComment) = "it" )           }         OPTIONAL           { ?resourceURI rdfs:label 
?resourceLabel }         OPTIONAL           { ?resourceURI rdfs:comment ?resourceComment }       }   }

2012-01-11 13:05:59 - log                       :: REQUEST /sparql on org.mortbay.jetty.HttpConnection@ddc728
2012-01-11 13:05:59 - log                       :: sessionManager=org.mortbay.jetty.servlet.HashSessionManager@f9f91d
2012-01-11 13:05:59 - log                       :: session=null
2012-01-11 13:05:59 - log                       :: servlet=SPARQL service processor
2012-01-11 13:05:59 - log                       :: chain=null
2012-01-11 13:05:59 - log                       :: servlet holder=SPARQL service processor
2012-01-11 13:05:59 - Servlet                   :: Request: http://localhost:2020/sparql
2012-01-11 13:05:59 - Servlet                   :: Service URI = <sparql>
2012-01-11 13:05:59 - TransactionHandlerSDB     :: beginTransaction: Already in a transaction
2012-01-11 13:05:59 - Servlet                   :: Internal server error
com.hp.hpl.jena.sdb.SDBException: Already in transaction
     at com.hp.hpl.jena.sdb.graph.TransactionHandlerSDB.begin(TransactionHandlerSDB.java:45)
     at com.hp.hpl.jena.rdf.model.impl.ModelCom.begin(ModelCom.java:1083)
     at org.joseki.processors.ProcessorBase.exec(ProcessorBase.java:80)
     at org.joseki.ServiceRequest.exec(ServiceRequest.java:36)
     at org.joseki.Dispatcher.dispatch(Dispatcher.java:59)
     at org.joseki.http.Servlet.doCommon(Servlet.java:178)
     at org.joseki.http.Servlet.doGet(Servlet.java:138)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
     at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
     at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
     at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
     at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
     at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
     at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
     at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
     at org.mortbay.jetty.Server.handle(Server.java:322)
     at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
     at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
     at org.mortbay.jetty.nio.BlockingChannelConnector$Connection.run(BlockingChannelConnector.java:164)
     at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
2012-01-11 13:05:59 - log                       :: RESPONSE /sparql  500
2012-01-11 13:05:59 - log                       :: RESPONSE /sparql  200
==========================================================================================

As you can see here I have the first REQUEST and the second one that come before RESPONSE of the first one. As a result The first ends correctly 
(RESPONSE /sparql  200) whereas the second one recieve a :: RESPONSE /sparql  500 (so that I get an Http 500 error: Internal Server Error:... from 
Joseki).

I already tried to configure "joseki:lockingPolicy" parameter but whatever value I specify (joseki:lockingPolicyMutex, 
joseki:lockingPolicyMRSW,joseki:lockingPolicyNone ) the result doesn't change. I also have tried to increase the the "joseki:poolSize" parameter but 
nothing.

What can I do to let Joseki manage correctly the concurrent queries trough SDB?

I'm working with:
- Joseki 3.4.4
- SDB-1.3.4
- Jena-2.6.4
- MySql 5.1

If it may be useful I can attach the joseki config file used.

Thanx in advance,
Matteo.

Re: Fwd: Re: SPARQL: Joseki and "Already in transaction" error for concurrent query context

Posted by Andy Seaborne <an...@apache.org>.
On 13/01/12 13:51, Matteo Busanelli (GMail) wrote:
> Hi Andy,
>      it seems that I resolved the problem using a different (and more
> simple) configuration for Joseki and SDB.
> The trick seems to be to have only one sdb:DatasetStore (sdb complete)
> without specifying a sdb-part with any named-graph declared and mapped
> on SDB.
> I attached the new config file more detail.
>
> Thanx again for support,
> Matteo.

Thanks for the update - one store is going to be easier.

	Andy

Fwd: Re: SPARQL: Joseki and "Already in transaction" error for concurrent query context

Posted by "Matteo Busanelli (GMail)" <ma...@gmail.com>.
Hi Andy,
     it seems that I resolved the problem using a different (and more simple) configuration for Joseki and SDB.
The trick seems to be to have only one sdb:DatasetStore (sdb complete)  without specifying a sdb-part with any named-graph declared and mapped on SDB.
I attached the new config file more detail.

Thanx again for support,
Matteo.

-------- Messaggio originale --------
Oggetto: 	Re: SPARQL: Joseki and "Already in transaction" error for concurrent query context
Data: 	Fri, 13 Jan 2012 10:34:42 +0100
Mittente: 	Matteo Busanelli (GMail) <ma...@gmail.com>
A: 	jena-users@incubator.apache.org



Hi Andy,
  first of all thanx for the quick response and support.

I've tried your suggested solution but nothing happened.

I've also tried from two tab of browser running the queries (both on the same graph or on two different graphs) and the second made query recieve:

"HTTP ERROR 500
Problem accessing /sparql. Reason:
INTERNAL_SERVER_ERROR"

...until the first made query doesn't terminate returning "RESPONSE /sparql  200".


It seems that Joseki doesen't handle the "Already in transaction" exception of com.hp.hpl.jena.sdb.graph.TransactionHandlerSDB.

...
2012-01-13 10:31:32 - TransactionHandlerSDB     :: beginTransaction: Already in a transaction
2012-01-13 10:31:32 - Servlet                   :: Internal server error
com.hp.hpl.jena.sdb.SDBException: Already in transaction
     at com.hp.hpl.jena.sdb.graph.TransactionHandlerSDB.begin(TransactionHandlerSDB.java:45)
...

I would have expected that Joseki handled this exception at list creating and managing a sort of waiting queue of queries (for example for the Mutex 
locking policy).

Maybe was a problem the fact that I run Joseki from command line (using bundled Jetty)?
Could you eventually be able to replicate the error?

I've attached the config file with the solutions that you suggested so you can see if I've understood what u have said.
(I also tried to create different store and different connection for each graph but nothing...)

Thanx again for the support,
Matteo.


Il 12/01/2012 20:59, Andy Seaborne ha scritto:
> Matteo,
>
> What I think is the problem is that you are using a general dataset for service <sparql> but it has several ways to get to the same SDB database 
> client instance <#sdb_busa> via the different graphs in <#sdb-part>.
>
> It should work if you create different instances of the rdf:type sdb:DatasetStore, one for each named graph (I haven't tried).  Each one is a JDBC 
> connection.
>
> If they are all the same you get the situation of calling a new transaction for the various graphs inside one query but with JDBC you only have 
> one transaction at a time.
>
> Do you really need the dataset structured like that?
>
> Maybe TDB and dynamic datasets would work better for you.
>
>     Andy
>
>
> On 12/01/12 17:01, Matteo Busanelli (GMail) wrote:
>> This is my configuration file (attached).
>>
>>
>> Il 12/01/2012 17:58, Andy Seaborne ha scritto:
>>> On 12/01/12 09:39, Matteo Busanelli (GMail) wrote:
>>>> Hi everyone,
>>>> I'm tryng to use Joseki with SDB (on MySQL 5.1) for serving multithread
>>>> application queries.
>>>> If all queries doesen't overlapp everything works well.
>>>> The problem comes wehn two different thread make concurrent queries that
>>>> overlaps and I got this error:
>>>>
>>>> ======================= log Stacktrace =====================
>>> ...
>>>>
>>>> As you can see here I have the first REQUEST and the second one that
>>>> come before RESPONSE of the first one. As a result The first ends
>>>> correctly (RESPONSE /sparql 200) whereas the second one recieve a ::
>>>> RESPONSE /sparql 500 (so that I get an Http 500 error: Internal Server
>>>> Error:... from Joseki).
>>>>
>>>> I already tried to configure "joseki:lockingPolicy" parameter but
>>>> whatever value I specify (joseki:lockingPolicyMutex,
>>>> joseki:lockingPolicyMRSW,joseki:lockingPolicyNone ) the result doesn't
>>>> change. I also have tried to increase the the "joseki:poolSize"
>>>> parameter but nothing.
>>>>
>>>> What can I do to let Joseki manage correctly the concurrent queries
>>>> trough SDB?
>>>>
>>>> I'm working with:
>>>> - Joseki 3.4.4
>>>> - SDB-1.3.4
>>>> - Jena-2.6.4
>>>> - MySql 5.1
>>>>
>>>> If it may be useful I can attach the joseki config file used.
>>>
>>> It would be useful to see it.
>>>
>>> Andy
>>>
>>>>
>>>> Thanx in advance,
>>>> Matteo.
>>>
>>>
>
>

Re: SPARQL: Joseki and "Already in transaction" error for concurrent query context

Posted by "Matteo Busanelli (GMail)" <ma...@gmail.com>.
Hi Andy,
  first of all thanx for the quick response and support.

I've tried your suggested solution but nothing happened.

I've also tried from two tab of browser running the queries (both on the same graph or on two different graphs) and the second made query recieve:

"HTTP ERROR 500
Problem accessing /sparql. Reason:
INTERNAL_SERVER_ERROR"

...until the first made query doesn't terminate returning "RESPONSE /sparql  200".


It seems that Joseki doesen't handle the "Already in transaction" exception of com.hp.hpl.jena.sdb.graph.TransactionHandlerSDB.

...
2012-01-13 10:31:32 - TransactionHandlerSDB     :: beginTransaction: Already in a transaction
2012-01-13 10:31:32 - Servlet                   :: Internal server error
com.hp.hpl.jena.sdb.SDBException: Already in transaction
     at com.hp.hpl.jena.sdb.graph.TransactionHandlerSDB.begin(TransactionHandlerSDB.java:45)
...

I would have expected that Joseki handled this exception at list creating and managing a sort of waiting queue of queries (for example for the Mutex 
locking policy).

Maybe was a problem the fact that I run Joseki from command line (using bundled Jetty)?
Could you eventually be able to replicate the error?

I've attached the config file with the solutions that you suggested so you can see if I've understood what u have said.
(I also tried to create different store and different connection for each graph but nothing...)

Thanx again for the support,
Matteo.


Il 12/01/2012 20:59, Andy Seaborne ha scritto:
> Matteo,
>
> What I think is the problem is that you are using a general dataset for service <sparql> but it has several ways to get to the same SDB database 
> client instance <#sdb_busa> via the different graphs in <#sdb-part>.
>
> It should work if you create different instances of the rdf:type sdb:DatasetStore, one for each named graph (I haven't tried).  Each one is a JDBC 
> connection.
>
> If they are all the same you get the situation of calling a new transaction for the various graphs inside one query but with JDBC you only have 
> one transaction at a time.
>
> Do you really need the dataset structured like that?
>
> Maybe TDB and dynamic datasets would work better for you.
>
>     Andy
>
>
> On 12/01/12 17:01, Matteo Busanelli (GMail) wrote:
>> This is my configuration file (attached).
>>
>>
>> Il 12/01/2012 17:58, Andy Seaborne ha scritto:
>>> On 12/01/12 09:39, Matteo Busanelli (GMail) wrote:
>>>> Hi everyone,
>>>> I'm tryng to use Joseki with SDB (on MySQL 5.1) for serving multithread
>>>> application queries.
>>>> If all queries doesen't overlapp everything works well.
>>>> The problem comes wehn two different thread make concurrent queries that
>>>> overlaps and I got this error:
>>>>
>>>> ======================= log Stacktrace =====================
>>> ...
>>>>
>>>> As you can see here I have the first REQUEST and the second one that
>>>> come before RESPONSE of the first one. As a result The first ends
>>>> correctly (RESPONSE /sparql 200) whereas the second one recieve a ::
>>>> RESPONSE /sparql 500 (so that I get an Http 500 error: Internal Server
>>>> Error:... from Joseki).
>>>>
>>>> I already tried to configure "joseki:lockingPolicy" parameter but
>>>> whatever value I specify (joseki:lockingPolicyMutex,
>>>> joseki:lockingPolicyMRSW,joseki:lockingPolicyNone ) the result doesn't
>>>> change. I also have tried to increase the the "joseki:poolSize"
>>>> parameter but nothing.
>>>>
>>>> What can I do to let Joseki manage correctly the concurrent queries
>>>> trough SDB?
>>>>
>>>> I'm working with:
>>>> - Joseki 3.4.4
>>>> - SDB-1.3.4
>>>> - Jena-2.6.4
>>>> - MySql 5.1
>>>>
>>>> If it may be useful I can attach the joseki config file used.
>>>
>>> It would be useful to see it.
>>>
>>> Andy
>>>
>>>>
>>>> Thanx in advance,
>>>> Matteo.
>>>
>>>
>
>

Re: SPARQL: Joseki and "Already in transaction" error for concurrent query context

Posted by Andy Seaborne <an...@apache.org>.
Matteo,

What I think is the problem is that you are using a general dataset for 
service <sparql> but it has several ways to get to the same SDB database 
client instance <#sdb_busa> via the different graphs in <#sdb-part>.

It should work if you create different instances of the rdf:type 
sdb:DatasetStore, one for each named graph (I haven't tried).  Each one 
is a JDBC connection.

If they are all the same you get the situation of calling a new 
transaction for the various graphs inside one query but with JDBC you 
only have one transaction at a time.

Do you really need the dataset structured like that?

Maybe TDB and dynamic datasets would work better for you.

	Andy


On 12/01/12 17:01, Matteo Busanelli (GMail) wrote:
> This is my configuration file (attached).
>
>
> Il 12/01/2012 17:58, Andy Seaborne ha scritto:
>> On 12/01/12 09:39, Matteo Busanelli (GMail) wrote:
>>> Hi everyone,
>>> I'm tryng to use Joseki with SDB (on MySQL 5.1) for serving multithread
>>> application queries.
>>> If all queries doesen't overlapp everything works well.
>>> The problem comes wehn two different thread make concurrent queries that
>>> overlaps and I got this error:
>>>
>>> ======================= log Stacktrace =====================
>> ...
>>>
>>> As you can see here I have the first REQUEST and the second one that
>>> come before RESPONSE of the first one. As a result The first ends
>>> correctly (RESPONSE /sparql 200) whereas the second one recieve a ::
>>> RESPONSE /sparql 500 (so that I get an Http 500 error: Internal Server
>>> Error:... from Joseki).
>>>
>>> I already tried to configure "joseki:lockingPolicy" parameter but
>>> whatever value I specify (joseki:lockingPolicyMutex,
>>> joseki:lockingPolicyMRSW,joseki:lockingPolicyNone ) the result doesn't
>>> change. I also have tried to increase the the "joseki:poolSize"
>>> parameter but nothing.
>>>
>>> What can I do to let Joseki manage correctly the concurrent queries
>>> trough SDB?
>>>
>>> I'm working with:
>>> - Joseki 3.4.4
>>> - SDB-1.3.4
>>> - Jena-2.6.4
>>> - MySql 5.1
>>>
>>> If it may be useful I can attach the joseki config file used.
>>
>> It would be useful to see it.
>>
>> Andy
>>
>>>
>>> Thanx in advance,
>>> Matteo.
>>
>>


Re: SPARQL: Joseki and "Already in transaction" error for concurrent query context

Posted by "Matteo Busanelli (GMail)" <ma...@gmail.com>.
This is my configuration file (attached).


Il 12/01/2012 17:58, Andy Seaborne ha scritto:
> On 12/01/12 09:39, Matteo Busanelli (GMail) wrote:
>> Hi everyone,
>> I'm tryng to use Joseki with SDB (on MySQL 5.1) for serving multithread
>> application queries.
>> If all queries doesen't overlapp everything works well.
>> The problem comes wehn two different thread make concurrent queries that
>> overlaps and I got this error:
>>
>> ======================= log Stacktrace =====================
> ...
>>
>> As you can see here I have the first REQUEST and the second one that
>> come before RESPONSE of the first one. As a result The first ends
>> correctly (RESPONSE /sparql 200) whereas the second one recieve a ::
>> RESPONSE /sparql 500 (so that I get an Http 500 error: Internal Server
>> Error:... from Joseki).
>>
>> I already tried to configure "joseki:lockingPolicy" parameter but
>> whatever value I specify (joseki:lockingPolicyMutex,
>> joseki:lockingPolicyMRSW,joseki:lockingPolicyNone ) the result doesn't
>> change. I also have tried to increase the the "joseki:poolSize"
>> parameter but nothing.
>>
>> What can I do to let Joseki manage correctly the concurrent queries
>> trough SDB?
>>
>> I'm working with:
>> - Joseki 3.4.4
>> - SDB-1.3.4
>> - Jena-2.6.4
>> - MySql 5.1
>>
>> If it may be useful I can attach the joseki config file used.
>
> It would be useful to see it.
>
>     Andy
>
>>
>> Thanx in advance,
>> Matteo.
>
>

Re: SPARQL: Joseki and "Already in transaction" error for concurrent query context

Posted by Andy Seaborne <an...@apache.org>.
On 12/01/12 09:39, Matteo Busanelli (GMail) wrote:
> Hi everyone,
> I'm tryng to use Joseki with SDB (on MySQL 5.1) for serving multithread
> application queries.
> If all queries doesen't overlapp everything works well.
> The problem comes wehn two different thread make concurrent queries that
> overlaps and I got this error:
>
> ======================= log Stacktrace =====================
...
>
> As you can see here I have the first REQUEST and the second one that
> come before RESPONSE of the first one. As a result The first ends
> correctly (RESPONSE /sparql 200) whereas the second one recieve a ::
> RESPONSE /sparql 500 (so that I get an Http 500 error: Internal Server
> Error:... from Joseki).
>
> I already tried to configure "joseki:lockingPolicy" parameter but
> whatever value I specify (joseki:lockingPolicyMutex,
> joseki:lockingPolicyMRSW,joseki:lockingPolicyNone ) the result doesn't
> change. I also have tried to increase the the "joseki:poolSize"
> parameter but nothing.
>
> What can I do to let Joseki manage correctly the concurrent queries
> trough SDB?
>
> I'm working with:
> - Joseki 3.4.4
> - SDB-1.3.4
> - Jena-2.6.4
> - MySql 5.1
>
> If it may be useful I can attach the joseki config file used.

It would be useful to see it.

	Andy

>
> Thanx in advance,
> Matteo.