|
From: March, A. <am...@so...> - 2005-01-29 20:43:36
|
I understand that the lazy initializer is using the wrong session but all our objects are local variables. No object spans requests. So now I'm really confused. The LazyInitializer use the same session as the parent object was loaded in. What I guess I'm saying is that the parent object was also loaded by the wrong session. =20 This problem not only takes load to surface but also is completely random. Different pieces of data during the velocity merge end up failing. You will probably be able to see this by going to http://eq2players.station.sony.com <http://eq2players.station.sony.com/> . If you go to a page that has a lot of data and hit refresh a bunch, stuff will start vanishing. =20 What I can do is verify which session is created for thread 7, since I didn't put that in my trace. I will definitely triple check my code to make sure no object traverses requests. Thanks for your input but I'm still lost. =20 =20 ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf Of Guillaume Poirier Sent: Saturday, January 29, 2005 11:46 AM To: spr...@li... Subject: Re: [Springframework-developer] Non Thread-safe hibernate session =20 It could be possible if there a finally was missing or something like that, causing a Session to be kept in the ThreadLocal, but it wouldn't cause the Session to be used by a different Thread. Beside, the exception clearly happens with LazyInitialization which makes it doubtful to be related to ThreadLocal stuff, unless the JDK's ThreadLocal class had a concurrency bug that was somehow still unfound. Jurgen's analysis of the situation seems accurate to me. Guillaume Rob Harrop wrote:=20 It seems unlikely that this is a problem with Spring - those threads are created by Tomcat and not Spring. I am wondering however if at that level of load the ThreadLocal stuff isn't getting cleared somehow when a thread is put back in the pool? Is this possible?=20 Rob=20 March, Andres wrote:=20 Unfortunately, this is not the case here. We are using jmeter with unauthenticated requests and therefore put nothing in the httpsession. Additionally, your example should take place with as little as 2 requests: one fetching the object and sticking it into the HttpSession, the other trying to initialize its collections. In our case, we have to create a decent amount of load (~30 pages/sec) for the errors to occur. Any other ideas?=20 ------------------------------------------------------------------------ *From:* spr...@li... [mailto:spr...@li...] *On Behalf Of *Juergen Hoeller=20 *Sent:* Saturday, January 29, 2005 2:44 AM=20 *To:* spr...@li...=20 *Subject:* RE: [Springframework-developer] Non Thread-safe hibernate session=20 Actually, this can happen without either Spring or the ThreadLocal mechanism breaking: One of your persistent objects might hold a lazy persistent collection, which holds a reference to the Session that originally loaded it.=20 If you put such a persistent object into the HttpSession, for example, the original request that loaded the object (in thread TPProcessor1) will have completed and thus the Hibernate Session have been closed. Now, if you take your persistent object out of the HttpSession again in a new request (in thread TPProcessor7) and try to access it lazy collection, it's gonna fail because the original Session has been closed.=20 So the "leak" where a Session reference got out of its original request/thread context is your persistent object in the HttpSession here. This is a well-known problem: To make lazy loading work here, you need to attach the persistent object to the new Hibernate Session (via lock or saveOrUpdate).=20 Juergen=20 -----Original Message-----=20 *From:* spr...@li...=20 [mailto:spr...@li...]*On=20 Behalf Of *March, Andres=20 *Sent:* Friday, January 28, 2005 8:27 PM=20 *To:* spr...@li...=20 *Subject:* [Springframework-developer] Non Thread-safe hibernate=20 session=20 As you can see below, a thread, other than the one that had the=20 session created for it, tries to access a session but it has been=20 closed by the valid owner thread. This only occurs under decent=20 load. There must be some thread safety issue in Spring or the=20 whole ThreadLocal idea goes out the window. Does anybody have any=20 idea how this could occur? I don't see how I could be=20 misinterpreting this trace.=20 FATAL (SessionImpl.java:528) - Constructor for session:=20 net.sf.hibernate.impl.SessionImpl@b72884 on thread : TP-Processor1=20 FATAL (SessionFactoryImpl.java:342) - Session :=20 net.sf.hibernate.impl.SessionImpl@b72884 created for Thread :=20 TP-Processor1=20 ...later on...=20 closing session : net.sf.hibernate.impl.SessionImpl@b72884 and=20 conn: com.mchange.v2.c3p0.impl.NewProxyConnection@4ad009 on Thread=20 : TP-Processor1=20 ...later on...=20 net.sf.hibernate.HibernateException: Session is closed :=20 net.sf.hibernate.impl.SessionImpl@b72884 on thread : TP-Processor7=20 at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3313)=20 at=20 =20 net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:4 7)=20 at=20 =20 net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInit ializer.java:60)=20 at=20 =20 net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer .java:164)=20 at=20 =20 net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:108)=20 at=20 =20 com.sony.soe.guilds.model.GameCharacter$$EnhancerByCGLIB$$25b6cd13.getBi oImage(<generated>)=20 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)=20 at=20 =20 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39)=20 at=20 =20 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25)=20 at java.lang.reflect.Method.invoke(Method.java:324)=20 at=20 =20 org.apache.velocity.runtime.parser.node.PropertyExecutor.execute(Propert yExecutor.java:111)=20 at=20 =20 org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl.invok e(UberspectImpl.java:300)=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentif ier.java:157)=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReferenc e.java:175)=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTReference.evaluate(ASTReferen ce.java:307)=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTNotNode.evaluate(ASTNotNode.j ava:47)=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTExpression.evaluate(ASTExpres sion.java:46)=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfState ment.java:69)=20 at=20 =20 org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.jav a:231)=20 at org.apache.velocity.runtime.directive.Parse.render(Parse.java:181)=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective .java:116)=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:56 )=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfState ment.java:71)=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:56 )=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfState ment.java:71)=20 at=20 =20 org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.jav a:231)=20 at org.apache.velocity.runtime.directive.Parse.render(Parse.java:181)=20 at=20 =20 org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective .java:116)=20 at=20 =20 org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.jav a:231)=20 at org.apache.velocity.Template.merge(Template.java:256)=20 at com.sony.soe.web.mvc.VelocityView.go(VelocityView.java:181)=20 at com.sony.soe.guilds.view.VelocityLayout.go(VelocityLayout.java:135)=20 at org.infohazard.maverick.flow.CommandBase.go(CommandBase.java:79)=20 at org.infohazard.maverick.Dispatcher.service(Dispatcher.java:345)=20 at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)=20 at=20 =20 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.java:237)=20 at=20 =20 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:157)=20 at=20 =20 net.sf.acegisecurity.ui.AbstractIntegrationFilter.doFilter(AbstractInteg rationFilter.java:170)=20 at=20 =20 com.sony.soe.guilds.controller.SecurityFilter.doFilter(SecurityFilter.ja va:118)=20 at=20 =20 net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.j ava:88)=20 at=20 =20 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.java:186)=20 at=20 =20 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:157)=20 at=20 =20 org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilt erInternal(OpenSessionInViewFilter.java:17=20 1)=20 at=20 =20 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequ estFilter.java:76)=20 at=20 =20 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.java:186)=20 at=20 =20 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:157)=20 at=20 =20 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv e.java:214)=20 at=20 =20 org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo ntext.java:104)=20 at=20 =20 org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5 20)=20 at=20 =20 org.apache.catalina.core.StandardContextValve.invokeInternal(StandardCon textValve.java:198)=20 at=20 =20 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv e.java:152)=20 at=20 =20 org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo ntext.java:104)=20 at=20 =20 org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5 20)=20 at=20 =20 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :137)=20 at=20 =20 org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo ntext.java:104)=20 at=20 =20 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java :117)=20 at=20 =20 org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo ntext.java:102)=20 at=20 =20 org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5 20)=20 at=20 =20 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. java:109)=20 at=20 =20 org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo ntext.java:104)=20 at=20 =20 org.apache.catalina.valves.RequestDumperValve.invoke(RequestDumperValve. java:169)=20 at=20 =20 org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo ntext.java:102)=20 at=20 =20 org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5 20)=20 at=20 =20 org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)=20 at=20 =20 org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)=20 at=20 =20 org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:296)=20 at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:372)=20 at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:694) at=20 =20 org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java: 626)=20 at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:807)=20 at=20 =20 org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool .java:644)=20 at java.lang.Thread.run(Thread.java:534)=20 -----------------------------------------=20 Andres March=20 Platform - Apps Engineering=20 Sony Online Entertainment=20 desk: 858.577.3373=20 cell: 619.519.1519=20 -------------------------------------------------------=20 This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting=20 Tool for open source databases. Create drag-&-drop reports. Save time=20 by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.=20 Download a FREE copy at http://www.intelliview.com/go/osdn_nl=20 _______________________________________________=20 Springframework-developer mailing list=20 Spr...@li...=20 https://lists.sourceforge.net/lists/listinfo/springframework-developer=20 |