You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by KÖLL Claus <C....@TIROL.GV.AT> on 2008/07/30 09:46:29 UTC
lock problem in xa transaction
if i try a testcase like this ...
public void testAddNodeAndLock() throws Exception {
UserTransaction utx = new UserTransactionImpl(superuser);
// start transaction
utx.begin();
// add node and save
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixLockable);
n.addMixin(mixReferenceable);
testRootNode.save();
n.lock(true, false);
// verify node is locked in first session only
assertTrue("Node locked in session 1", n.isLocked());
// commit
utx.commit();
// logout
otherSuperuser.logout();
}
i get a exception while commit()
javax.transaction.RollbackException: Transaction rolled back: XA_ERR=104
at org.apache.jackrabbit.core.UserTransactionImpl.commit(UserTransactionImpl.java:118)
at org.apache.jackrabbit.core.XATest.testAddNodeAndLock(XATest.java:198)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at org.apache.jackrabbit.core.XATest.runTest(XATest.java:97)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.apache.jackrabbit.test.AbstractJCRTest.run(AbstractJCRTest.java:406)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.apache.jackrabbit.core.TransactionException: Unable to update.
at org.apache.jackrabbit.core.lock.XAEnvironment.prepare(XAEnvironment.java:275)
at org.apache.jackrabbit.core.lock.XALockManager.prepare(XALockManager.java:245)
at org.apache.jackrabbit.core.TransactionContext.prepare(TransactionContext.java:138)
at org.apache.jackrabbit.core.XASessionImpl.prepare(XASessionImpl.java:324)
at org.apache.jackrabbit.core.UserTransactionImpl.commit(UserTransactionImpl.java:107)
... 21 more
Caused by: javax.jcr.ItemNotFoundException: failed to build path of 9cd88737-ecfa-49ba-8c30-1e98adf201e9: 9cd88737-ecfa-49ba-8c30-1e98adf201e9: 9cd88737-ecfa-49ba-8c30-1e98adf201e9
at org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:407)
at org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:272)
at org.apache.jackrabbit.core.lock.LockManagerImpl.getPath(LockManagerImpl.java:651)
at org.apache.jackrabbit.core.lock.LockManagerImpl.internalLock(LockManagerImpl.java:276)
at org.apache.jackrabbit.core.lock.XAEnvironment$LockInfo.update(XAEnvironment.java:409)
at org.apache.jackrabbit.core.lock.XAEnvironment.prepare(XAEnvironment.java:273)
... 25 more
Caused by: org.apache.jackrabbit.core.state.NoSuchItemStateException: 9cd88737-ecfa-49ba-8c30-1e98adf201e9
at org.apache.jackrabbit.core.state.SessionItemStateManager.getItemState(SessionItemStateManager.java:189)
at org.apache.jackrabbit.core.HierarchyManagerImpl.getItemState(HierarchyManagerImpl.java:188)
at org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:402)
... 30 more
thanks for help
claus
AW: lock problem in xa transaction
Posted by KÖLL Claus <C....@TIROL.GV.AT>.
hi jukka thanks for your comments.
we have jackrabbit configured as a jca adapter so we have transactions at all.
my use case is to add a node and create a non-session scoped lock on it
and i think this is a legitimate usecase ...
but somebody had the idea to test it because in the current XATest.class
is already such a testcase but it will not be invoked ??
i don't know exactly but can it be that Marcel Reutegger is the xa implementor ?
i have some time ago created a issue JCR-1334 where i found some problems with
locking in transactions. there the lock will be bind to the current thread but
in a xa environment you can not bind a lock to a thread because you can not guarantee
that a application server give you for a commit() the same thread as for prepare(). in the testcases for the current
implementation we should test such things ...
from my point of view we should think about transactions in jackrabbit again
to find solutions for that problems. in JCR-1702 the problem is the mix of sessions
thanks
claus
-----Ursprüngliche Nachricht-----
Von: Jukka Zitting [mailto:jukka.zitting@gmail.com]
Gesendet: Mittwoch, 06. August 2008 10:43
An: dev@jackrabbit.apache.org
Betreff: Re: lock problem in xa transaction
Hi,
On Wed, Aug 6, 2008 at 9:39 AM, KÖLL Claus <C....@tirol.gv.at> wrote:
> sorry for my hardheadedness
> but is there nobody out who can give some statement to that problem ?
> i have created a jira issues JCR-1702 for that problem
I'm not sure what the right answer here would be.
Ideally a session inside a transaction should behave as close as
possible to a session outside one, but in this case it doesn't. One
reason for this behaviour is that until the transaction is committed
the created node is only visible within the transaction, so locking it
doesn't really achieve much. I'm not sure how things end up looking
internally in Jackrabbit for such a case, it seems like in JCR-1702
you've already dug deeper than what I can tell from the top of my
head.
More generally the effect of locking within a transaction is a tricky
subject, e.g. should a lock within a transaction affect clients
outside the transaction?
In any case the behaviour you are seeing is confusing. If such locking
is not supported, then already the lock() method should throw an
exception instead of the failure being manifest as an
ItemNotFoundException that causes commit() to fail.
BR,
Jukka Zitting
Re: lock problem in xa transaction
Posted by Jukka Zitting <ju...@gmail.com>.
Hi,
On Wed, Aug 6, 2008 at 9:39 AM, KÖLL Claus <C....@tirol.gv.at> wrote:
> sorry for my hardheadedness
> but is there nobody out who can give some statement to that problem ?
> i have created a jira issues JCR-1702 for that problem
I'm not sure what the right answer here would be.
Ideally a session inside a transaction should behave as close as
possible to a session outside one, but in this case it doesn't. One
reason for this behaviour is that until the transaction is committed
the created node is only visible within the transaction, so locking it
doesn't really achieve much. I'm not sure how things end up looking
internally in Jackrabbit for such a case, it seems like in JCR-1702
you've already dug deeper than what I can tell from the top of my
head.
More generally the effect of locking within a transaction is a tricky
subject, e.g. should a lock within a transaction affect clients
outside the transaction?
In any case the behaviour you are seeing is confusing. If such locking
is not supported, then already the lock() method should throw an
exception instead of the failure being manifest as an
ItemNotFoundException that causes commit() to fail.
BR,
Jukka Zitting
AW: lock problem in xa transaction
Posted by KÖLL Claus <C....@TIROL.GV.AT>.
sorry for my hardheadedness
but is there nobody out who can give some statement to that problem ?
i have created a jira issues JCR-1702 for that problem
hope for response
claus
-----Ursprüngliche Nachricht-----
Von: KÖLL Claus [mailto:C.KOELL@TIROL.GV.AT]
Gesendet: Donnerstag, 31. Juli 2008 08:46
An: dev@jackrabbit.apache.org
Betreff: AW: lock problem in xa transaction
should it be possible to create a node and after save to set a non session scoped lock
inside one transaction ?
As i can see the HierarchyManager does not know the before created node
should i open a jira issue ?
thanks
claus
-----Ursprüngliche Nachricht-----
Von: KÖLL Claus [mailto:C.KOELL@TIROL.GV.AT]
Gesendet: Mittwoch, 30. Juli 2008 09:46
An: dev@jackrabbit.apache.org
Betreff: lock problem in xa transaction
if i try a testcase like this ...
public void testAddNodeAndLock() throws Exception {
UserTransaction utx = new UserTransactionImpl(superuser);
// start transaction
utx.begin();
// add node and save
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixLockable);
n.addMixin(mixReferenceable);
testRootNode.save();
n.lock(true, false);
// verify node is locked in first session only
assertTrue("Node locked in session 1", n.isLocked());
// commit
utx.commit();
// logout
otherSuperuser.logout();
}
i get a exception while commit()
javax.transaction.RollbackException: Transaction rolled back: XA_ERR=104
at org.apache.jackrabbit.core.UserTransactionImpl.commit(UserTransactionImpl.java:118)
at org.apache.jackrabbit.core.XATest.testAddNodeAndLock(XATest.java:198)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at org.apache.jackrabbit.core.XATest.runTest(XATest.java:97)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.apache.jackrabbit.test.AbstractJCRTest.run(AbstractJCRTest.java:406)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.apache.jackrabbit.core.TransactionException: Unable to update.
at org.apache.jackrabbit.core.lock.XAEnvironment.prepare(XAEnvironment.java:275)
at org.apache.jackrabbit.core.lock.XALockManager.prepare(XALockManager.java:245)
at org.apache.jackrabbit.core.TransactionContext.prepare(TransactionContext.java:138)
at org.apache.jackrabbit.core.XASessionImpl.prepare(XASessionImpl.java:324)
at org.apache.jackrabbit.core.UserTransactionImpl.commit(UserTransactionImpl.java:107)
... 21 more
Caused by: javax.jcr.ItemNotFoundException: failed to build path of 9cd88737-ecfa-49ba-8c30-1e98adf201e9: 9cd88737-ecfa-49ba-8c30-1e98adf201e9: 9cd88737-ecfa-49ba-8c30-1e98adf201e9
at org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:407)
at org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:272)
at org.apache.jackrabbit.core.lock.LockManagerImpl.getPath(LockManagerImpl.java:651)
at org.apache.jackrabbit.core.lock.LockManagerImpl.internalLock(LockManagerImpl.java:276)
at org.apache.jackrabbit.core.lock.XAEnvironment$LockInfo.update(XAEnvironment.java:409)
at org.apache.jackrabbit.core.lock.XAEnvironment.prepare(XAEnvironment.java:273)
... 25 more
Caused by: org.apache.jackrabbit.core.state.NoSuchItemStateException: 9cd88737-ecfa-49ba-8c30-1e98adf201e9
at org.apache.jackrabbit.core.state.SessionItemStateManager.getItemState(SessionItemStateManager.java:189)
at org.apache.jackrabbit.core.HierarchyManagerImpl.getItemState(HierarchyManagerImpl.java:188)
at org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:402)
... 30 more
thanks for help
claus
AW: lock problem in xa transaction
Posted by KÖLL Claus <C....@TIROL.GV.AT>.
should it be possible to create a node and after save to set a non session scoped lock
inside one transaction ?
As i can see the HierarchyManager does not know the before created node
should i open a jira issue ?
thanks
claus
-----Ursprüngliche Nachricht-----
Von: KÖLL Claus [mailto:C.KOELL@TIROL.GV.AT]
Gesendet: Mittwoch, 30. Juli 2008 09:46
An: dev@jackrabbit.apache.org
Betreff: lock problem in xa transaction
if i try a testcase like this ...
public void testAddNodeAndLock() throws Exception {
UserTransaction utx = new UserTransactionImpl(superuser);
// start transaction
utx.begin();
// add node and save
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixLockable);
n.addMixin(mixReferenceable);
testRootNode.save();
n.lock(true, false);
// verify node is locked in first session only
assertTrue("Node locked in session 1", n.isLocked());
// commit
utx.commit();
// logout
otherSuperuser.logout();
}
i get a exception while commit()
javax.transaction.RollbackException: Transaction rolled back: XA_ERR=104
at org.apache.jackrabbit.core.UserTransactionImpl.commit(UserTransactionImpl.java:118)
at org.apache.jackrabbit.core.XATest.testAddNodeAndLock(XATest.java:198)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at org.apache.jackrabbit.core.XATest.runTest(XATest.java:97)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.apache.jackrabbit.test.AbstractJCRTest.run(AbstractJCRTest.java:406)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.apache.jackrabbit.core.TransactionException: Unable to update.
at org.apache.jackrabbit.core.lock.XAEnvironment.prepare(XAEnvironment.java:275)
at org.apache.jackrabbit.core.lock.XALockManager.prepare(XALockManager.java:245)
at org.apache.jackrabbit.core.TransactionContext.prepare(TransactionContext.java:138)
at org.apache.jackrabbit.core.XASessionImpl.prepare(XASessionImpl.java:324)
at org.apache.jackrabbit.core.UserTransactionImpl.commit(UserTransactionImpl.java:107)
... 21 more
Caused by: javax.jcr.ItemNotFoundException: failed to build path of 9cd88737-ecfa-49ba-8c30-1e98adf201e9: 9cd88737-ecfa-49ba-8c30-1e98adf201e9: 9cd88737-ecfa-49ba-8c30-1e98adf201e9
at org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:407)
at org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:272)
at org.apache.jackrabbit.core.lock.LockManagerImpl.getPath(LockManagerImpl.java:651)
at org.apache.jackrabbit.core.lock.LockManagerImpl.internalLock(LockManagerImpl.java:276)
at org.apache.jackrabbit.core.lock.XAEnvironment$LockInfo.update(XAEnvironment.java:409)
at org.apache.jackrabbit.core.lock.XAEnvironment.prepare(XAEnvironment.java:273)
... 25 more
Caused by: org.apache.jackrabbit.core.state.NoSuchItemStateException: 9cd88737-ecfa-49ba-8c30-1e98adf201e9
at org.apache.jackrabbit.core.state.SessionItemStateManager.getItemState(SessionItemStateManager.java:189)
at org.apache.jackrabbit.core.HierarchyManagerImpl.getItemState(HierarchyManagerImpl.java:188)
at org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:402)
... 30 more
thanks for help
claus