jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From KÖLL Claus <C.KO...@TIROL.GV.AT>
Subject LockProblem in XA Environment
Date Tue, 31 Mar 2009 13:35:12 GMT
Hi @ all,

i have a Problem with Lock/Unlock a Node in a XA Environment

The Test Case :
--------------------------------------------------------------
UserTransaction utx = new UserTransactionImpl(superuser);
utx.begin();

Node n1 = testRootNode.addNode(nodeName1);
n1.addMixin(mixLockable);
n1.addMixin(mixReferenceable);
testRootNode.save();
String uuid = n1.getUUID();
utx.commit();

Session other1 = helper.getSuperuserSession();
utx = new UserTransactionImpl(other1);
utx.begin();
n1 = other1.getNodeByUUID(uuid);
Lock lock = n1.lock(true, false);
String lockToken = lock.getLockToken();
//other1.removeLockToken(lockToken);
utx.commit();
//other1.logout();

Session other2 = helper.getSuperuserSession();
utx = new UserTransactionImpl(other2);
utx.begin();
other2.addLockToken(lockToken);
n1 = other2.getNodeByUUID(uuid);
n1.unlock(); -> Throws Exception -> Node not locked by this Session !
utx.commit();
------------------------------------------------------------

1. In the first Transaction i will create a node
2. In the second Transaction i will lock the node
3. and in the third Transaction i will remove the lock from the node

Info: we are using jackrabbit with the JCA Connector and so i will get a JCASessionHandle
to the underlying XASession.

Now i have some Problems :-) ... A Node is not unlockable while the Lock-Creating-Session
will be logged out
or the LockToken will be removed from the Lock-Creating-Session.

In a JCA Environment the session.logout() will be delayed till the JCAManagedConnection will
be
destroyed from the container so a logout could not be guaranteed.
Removing the LockToken from the Lock-Creating-Session in a XAEnvironment will end up in a
empty Method
XAEnvironment.removeLockToken() so in the referenced LockInfo Object is still the LockOwner
the
Lock-Creating-Session.

I don't know the best solution. We can set the LockHolder to null but then we must change
some code
in LockMangager.isLockHolder because this method checks if the given Session is equals the
LockHolder
and this is not the case with a non session scoped lock.

What do others think ?

greets
claus

Mime
View raw message