So, we need to decide what the appropriate behaviour will be for 3.2 and make it work properly.
I will get the testcase as it stands cleaned up and checked in tonight.
At the moment, if people try to migrate from 3.0.x to 3.2, their applications will break if using this construct.
Steve Coy
On Thursday, April 3, 2003, at 03:58 AM, Dain Sundstrom wrote:
I doubt that a CMR will work with the read-only flag. The problem is a read-only specifically does not associate the transaction with the invocation and does not enlist the entity in the tx synchronization. A CMR collection is dependent on a transaction and having tx synchronization. I bet Stephen can hack the code to get it to work, but should we fix it or just disallow it for CMRs?
I personally have never liked the read-only flag because it means so much in out system. It means no-lock, no-transaction, no-synchronization, and so on. What if I want the read in a transaction because I want consistent reads across several entities, but I want to avoid a sync lock? Because all of these option are tied up into a single flag we don't get flexibility.
In JB4 CMP the flag has little value because we will have notification from fields when something changes. In this case read-only would mean no-lock and no-transaction, but is that what the average user thinks read-only would mean. Even worse it ends up being a fairly small optimization. Since a local transaction has almost no overhead, and for JB4 we plan on making multi-instance the default you get 0 benefit from the flag, but a ton of headache from the code. I think for 4.0 we should not allow read-only for CMP. For BMP is makes since, but I think we should make it mean just no-store or change it to no-store. Additionally we I think we should add a no-lock flag for single-instance invocations. For no-transaction we have the standard EJB flags.
-dain
On Wednesday, April 2, 2003, at 10:18 AM, Stephen Coy wrote:
Ah ha!
It needs those "read-only" tags in jboss.xml in order to fail.
Previously, I had explicitly specified that "getChildren" was read-only. It needs to be "get*".
My test is failing now.
Steve Coy
On Thursday, April 3, 2003, at 01:30 AM, Andrew May wrote:
I've tried to do a bit of investigation of my own. I'm still trying to get my head around the code, but this is what I think is going >>> on.
The exception:
java.lang.IllegalStateException: The iterator of a CMR collection may only be used within the transction in which it was created
at org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet$1.verifyIteratorIsV alid(RelationSet.java:309)
gets throws when setHandle[0] is null. This reference to a set of ids is nullified by JDMCCMRFieldBridge$FieldState.invalidate().
When two threads (A & B) are using the Entity at the same time (which is allowed because the getPropertyMap method is read-only) it's possible for thread A to nullify setHandle[0] (at the end of it's transaction) whilst thread B is in the middle of iterating around the relationship. After that any call to the CMR iterator in thread B causes the exception - which is why it's sometimes from hasNext() and sometimes from next().
Here's a couple of Thead stacks I captured using the test case. The first thread is in the middle of iterating, and the second is finishing it's transaction:
System Thread [RMI TCP Connection(172)-192.168.5.20] (Suspended)
java.lang.StringBuffer.<init>(int) line: 114 [local variables unavailable]
java.lang.StringBuffer.<init>() line: 103
com.ingenta.acs.test.ejb.ParentBean$Proxy(com.ingenta.acs.test.ejb.Pa rentBean).getPropertyMap() line: 86
sun.reflect.GeneratedMethodAccessor87.invoke(java.lang.Object, java.lang.Object[]) line: not available [local variables >>> unavailable]
sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25 [local variables unavailable]
java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) line: 324
org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(org.jboss.i nvocation.Invocation) line: 1044
org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(org.jbo ss.invocation.Invocation) line: 95
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(org.jbo ss.invocation.Invocation) line: 295
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invo ke(org.jboss.invocation.Invocation) line: 186
org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(org.jboss.in vocation.Invocation) line: 82
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(org.jboss.invo cation.Invocation) line: 174
org.jboss.ejb.plugins.EntityLockInterceptor.invoke(org.jboss.invocati on.Invocation) line: 89
org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(org.jboss.invo cation.Invocation) line: 53
org.jboss.ejb.plugins.TxInterceptorCMT(org.jboss.ejb.plugins.Abstract TxInterceptor).invokeNext(org.jboss.invocation.Invocation, boolean) line: 84
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(org.jboss. invocation.Invocation) line: 243
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(org.jboss.invocation.In vocation) line: 104
org.jboss.ejb.plugins.SecurityInterceptor.invoke(org.jboss.invocation .Invocation) line: 117
org.jboss.ejb.plugins.LogInterceptor.invoke(org.jboss.invocation.Invo cation) line: 198
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(org.jboss. invocation.Invocation) line: 122
org.jboss.ejb.EntityContainer.internalInvoke(org.jboss.invocation.Inv ocation) line: 483
org.jboss.ejb.EntityContainer(org.jboss.ejb.Container).invoke(org.jbo ss.invocation.Invocation) line: 678
sun.reflect.GeneratedMethodAccessor85.invoke(java.lang.Object, java.lang.Object[]) line: not available
sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25
java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) line: 324
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(java.lang.Str ing, java.lang.Object[], java.lang.String[]) line: 284
org.jboss.mx.server.MBeanServerImpl.invoke(javax.management.ObjectNam e, java.lang.String, java.lang.Object[], java.lang.String[]) line: 549
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(org.jboss.invocat ion.Invocation) line: 358
sun.reflect.GeneratedMethodAccessor84.invoke(java.lang.Object, java.lang.Object[]) line: not available
sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25
java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) line: 324
sun.rmi.server.UnicastServerRef2(sun.rmi.server.UnicastServerRef).dis patch(java.rmi.Remote, java.rmi.server.RemoteCall) line: 261
sun.rmi.transport.Transport$1.run() line: 148
java.security.AccessController.doPrivileged(java.security.PrivilegedE xceptionAction, java.security.AccessControlContext) line: not available [native method]
sun.rmi.transport.tcp.TCPTransport(sun.rmi.transport.Transport).servi ceCall(java.rmi.server.RemoteCall) line: 144
sun.rmi.transport.tcp.TCPTransport.handleMessages(sun.rmi.transport.C onnection, boolean) line: 460
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run() line: 701
java.lang.Thread.run() line: 536
System Thread [RMI TCP Connection(175)-192.168.5.20] (Suspended (breakpoint at line 1611 in org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$FieldState))
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$FieldState.i nvalidate() line: 1611
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$TxSynchroniz ation.beforeCompletion() line: 1730
org.jboss.tm.TransactionImpl.doBeforeCompletion() line: 1297
org.jboss.tm.TransactionImpl.commit() line: 338
org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(org.jboss.invoc ation.Invocation, javax.transaction.Transaction, javax.transaction.Transaction) line: 367
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(org.jboss. invocation.Invocation) line: 253
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(org.jboss.invocation.In vocation) line: 104
[snip - as above]
I'm afraid some of the line numbers will be a bit different to CVS because I added some extra logging to JDBCCMRFIeldBridge and RelationSet.
Also I modified the ParentBean.getPropertyMap method so that I could see the individual steps (I used the System.out method of debugging to start :).
From PropertyBean:
76: public Map getPropertyMap() 77: { 78: String thread = Thread.currentThread().getName(); 79: Map result = new HashMap(); 80: Set children = getChildren(); 81: System.out.println(thread+": Got Children"); 82: Iterator i = children.iterator(); 83: System.out.println(thread+": Got Iterator"); 84: while (i.hasNext()) 85: { 86: System.out.println(thread+": hasNext"); 87: ChildLocal c = (ChildLocal) i.next(); 88: System.out.println(thread+": next"); 89: result.put(c.getName(), c.getValue()); 90: } 91: 92: return result; 93: }
The exception will happen when the first thread resumes and calls the next line (87) which gets from the iterator.
I think that's probably the cause of the error. I don't understand the code enough to suggest a solution.
Andrew
-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: Dedicated Hosting for just $79/mo with 500 GB of bandwidth! No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user
-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb:Dedicated Hosting for just $79/mo with 500 GB of bandwidth!No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user
-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb:Dedicated Hosting for just $79/mo with 500 GB of bandwidth!No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user
-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: Dedicated Hosting for just $79/mo with 500 GB of bandwidth! No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user
