You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Willie Vu <ct...@ust.hk> on 2004/03/05 10:52:59 UTC

Deadlock when 2 node stores point to the same resource

I have the following configuration:

<store name="mssql">
  <!-- using JDBCStore with SQLServer adapter -->
  ...
</store>

<store name="users">
  <!-- stores using the same configuration as the mssql store -->
  ...
</store>

<scope match="/users" store="users" />
<scope match="/" store="mssql"/>


Correct me if I'm wrong.  Currently, Slide will start a new transaction when it
encounters a new node store.  So, when Slide initializes the Domain and starts
loading data definition from Domain.xml, it creates object nodes from "/" using
transaction #1.  When subject nodes are read, Slide sees that the "users" store
is currently from the current "mssql" store, it starts another transaction #2.
Deadlock occurs because transaction #1 locks many database objects that
transaction #2 needs to access.

The above sample Domain.xml is to reproduce the problem.

My real life example is below.  I have good reason for the 2 stores having the
same rdbms resource.  I just want the nodes coming from LDAP while others coming
from database.

<store name="useres">
  <nodestore>
     <!-- connect to LDAP -->
  </nodestore>
  <!-- other stores using the same configuration as the mssql store -->
  ...
</store>



--
Willie Vu
Center for Enhanced Learning and Teaching
Hong Kong University of Science and Technology
(O) +852 2358 8926
(F) +852 2358 2201
mailto:ctwillie@ust.hk


---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org


Re: Deadlock when 2 node stores point to the same resource

Posted by Martin Holz <ho...@fiz-chemie.de>.
Hi,

"Willie Vu" <ct...@ust.hk> writes:

> > However since 
> > ever J2EE store has its own connections, there are separate 
> > SQL transactions started for each store. If the stores share 
> > the same tables, there could be deadlocks, if the complete 
> > table is locked. However I would expect, that 
> > two stores would never access the same rows. So a database, 
> > which locks only at row level should work fine.
> > 
> > So far I did not find any deadlocks using 
> > Postgres/OldJDBCAdapter and separate stores for / and /history.
> > 
> 
> I can reproduce the problem with MySQL 4.x using Slide 2.0 Beta 1.  The
> configuration is simple:
> 
> <scope match="/users" store="mysql-users" />
> <scope match="/" store="mysql"/>
> 
> It will cause the following exception:
> 
> 09 Mar 2004 11:47:54 - org.apache.slide.store.impl.rdbms.JDBCStore - DEBUG -
> Getting current connection for thread Thread[main,5,main]
> 09 Mar 2004 11:48:45 - org.apache.slide.store.impl.rdbms.MySqlRDBMSAdapter -
> ERROR - SQL error 1205 on /: General error: Lock wait timeout exceeded; Try
> restarting transaction
> 09 Mar 2004 11:48:45 - org.apache.slide.common.SlideException - DEBUG -
> org.apache.slide.common.ServiceAccessException: Service
> org.apache.slide.store.impl.rdbms.JDBCStore@6545d2 access error : General error:
> Lock wait timeout exceeded; Try restarting transaction
> 	at
> org.apache.slide.store.impl.rdbms.MySqlRDBMSAdapter.createException(MySqlRDBMSAd
> apter.java:60)
> 	at

do you know, how MySQL locks a database? Does it lock the complete table
or just rows or is using some other mechanism to handle concurrent access?

Martin


---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org


RE: Deadlock when 2 node stores point to the same resource

Posted by Willie Vu <ct...@ust.hk>.
> However since 
> ever J2EE store has its own connections, there are separate 
> SQL transactions started for each store. If the stores share 
> the same tables, there could be deadlocks, if the complete 
> table is locked. However I would expect, that 
> two stores would never access the same rows. So a database, 
> which locks only at row level should work fine.
> 
> So far I did not find any deadlocks using 
> Postgres/OldJDBCAdapter and separate stores for / and /history.
> 

I can reproduce the problem with MySQL 4.x using Slide 2.0 Beta 1.  The
configuration is simple:

<scope match="/users" store="mysql-users" />
<scope match="/" store="mysql"/>

It will cause the following exception:

09 Mar 2004 11:47:54 - org.apache.slide.store.impl.rdbms.JDBCStore - DEBUG -
Getting current connection for thread Thread[main,5,main]
09 Mar 2004 11:48:45 - org.apache.slide.store.impl.rdbms.MySqlRDBMSAdapter -
ERROR - SQL error 1205 on /: General error: Lock wait timeout exceeded; Try
restarting transaction
09 Mar 2004 11:48:45 - org.apache.slide.common.SlideException - DEBUG -
org.apache.slide.common.ServiceAccessException: Service
org.apache.slide.store.impl.rdbms.JDBCStore@6545d2 access error : General error:
Lock wait timeout exceeded; Try restarting transaction
	at
org.apache.slide.store.impl.rdbms.MySqlRDBMSAdapter.createException(MySqlRDBMSAd
apter.java:60)
	at
org.apache.slide.store.impl.rdbms.StandardRDBMSAdapter.storeObject(StandardRDBMS
Adapter.java:197)
	at
org.apache.slide.store.impl.rdbms.StandardRDBMSAdapter.storeObject(StandardRDBMS
Adapter.java:95)
	at
org.apache.slide.store.impl.rdbms.AbstractRDBMSStore.storeObject(AbstractRDBMSSt
ore.java:462)
	at
org.apache.slide.store.AbstractStore.storeObject(AbstractStore.java:526)
	at
org.apache.slide.store.ExtendedStore.storeObject(ExtendedStore.java:424)
	at
org.apache.slide.structure.StructureImpl.store(StructureImpl.java:452)
	at
org.apache.slide.structure.StructureImpl.create(StructureImpl.java:347)
	at
org.apache.slide.common.XMLUnmarshaller.loadObjectNode(XMLUnmarshaller.java:164)
	at
org.apache.slide.common.XMLUnmarshaller.loadObjectNode(XMLUnmarshaller.java:301)
	at
org.apache.slide.common.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:96)
	at
org.apache.slide.common.NamespaceAccessTokenImpl.importData(NamespaceAccessToken
Impl.java:267)
	at org.apache.slide.common.Namespace.loadBaseData(Namespace.java:775)
	at org.apache.slide.common.Domain.initNamespace(Domain.java:814)
	at org.apache.slide.common.Domain.init(Domain.java:433)
	at org.apache.slide.common.Domain.selfInit(Domain.java:747)
	at org.apache.slide.common.Domain.accessNamespace(Domain.java:235)


---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org


Re: Deadlock when 2 node stores point to the same resource

Posted by Martin Holz <ho...@fiz-chemie.de>.
"Willie Vu" <ct...@ust.hk> writes:
 
> Correct me if I'm wrong.  Currently, Slide will start a new transaction when it
> encounters a new node store.  So, when Slide initializes the Domain and starts
> loading data definition from Domain.xml, it creates object nodes from "/" using
> transaction #1.  When subject nodes are read, Slide sees that the "users" store
> is currently from the current "mssql" store, it starts another transaction #2.
> Deadlock occurs because transaction #1 locks many database objects that
> transaction #2 needs to access.

AFAIK no new Slide transaction is started for a new store. Slide transactions 
are only created at a high level, e.g AbstractWebdavMethod. However since 
ever J2EE store has its own connections, there are separate SQL transactions
started for each store. If the stores share the same tables, there could
be deadlocks, if the complete table is locked. However I would expect, that 
two stores would never access the same rows. So a database, which locks only at
row level should work fine.

So far I did not find any deadlocks using Postgres/OldJDBCAdapter and separate
stores for / and /history.

Martin



---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org