|
From: Guillaume P. <gpo...@sy...> - 2005-01-29 19:45:49
|
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: > 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? > > Rob > > March, Andres wrote: > >> 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? >> >> ------------------------------------------------------------------------ >> >> *From:* spr...@li... >> [mailto:spr...@li...] *On >> Behalf Of *Juergen Hoeller >> *Sent:* Saturday, January 29, 2005 2:44 AM >> *To:* spr...@li... >> *Subject:* RE: [Springframework-developer] Non Thread-safe hibernate >> session >> >> 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. >> >> 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. >> >> 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). >> >> Juergen >> >> -----Original Message----- >> *From:* spr...@li... >> [mailto:spr...@li...]*On >> Behalf Of *March, Andres >> *Sent:* Friday, January 28, 2005 8:27 PM >> *To:* spr...@li... >> *Subject:* [Springframework-developer] Non Thread-safe hibernate >> session >> >> As you can see below, a thread, other than the one that had the >> session created for it, tries to access a session but it has been >> closed by the valid owner thread. This only occurs under decent >> load. There must be some thread safety issue in Spring or the >> whole ThreadLocal idea goes out the window. Does anybody have any >> idea how this could occur? I don’t see how I could be >> misinterpreting this trace. >> >> FATAL (SessionImpl.java:528) - Constructor for session: >> net.sf.hibernate.impl.SessionImpl@b72884 on thread : TP-Processor1 >> >> FATAL (SessionFactoryImpl.java:342) - Session : >> net.sf.hibernate.impl.SessionImpl@b72884 created for Thread : >> TP-Processor1 >> >> …later on… >> >> closing session : net.sf.hibernate.impl.SessionImpl@b72884 and >> conn: com.mchange.v2.c3p0.impl.NewProxyConnection@4ad009 on Thread >> : TP-Processor1 >> >> …later on… >> >> net.sf.hibernate.HibernateException: Session is closed : >> net.sf.hibernate.impl.SessionImpl@b72884 on thread : TP-Processor7 >> >> at >> net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3313) >> >> at >> >> net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:47) >> >> >> at >> >> net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:60) >> >> >> at >> >> net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:164) >> >> >> at >> >> net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:108) >> >> >> at >> >> com.sony.soe.guilds.model.GameCharacter$$EnhancerByCGLIB$$25b6cd13.getBioImage(<generated>) >> >> >> 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:324) >> >> at >> >> org.apache.velocity.runtime.parser.node.PropertyExecutor.execute(PropertyExecutor.java:111) >> >> >> at >> >> org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl.invoke(UberspectImpl.java:300) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:157) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:175) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTReference.evaluate(ASTReference.java:307) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTNotNode.evaluate(ASTNotNode.java:47) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTExpression.evaluate(ASTExpression.java:46) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:69) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:231) >> >> >> at >> org.apache.velocity.runtime.directive.Parse.render(Parse.java:181) >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:116) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:56) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:71) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:56) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:71) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:231) >> >> >> at >> org.apache.velocity.runtime.directive.Parse.render(Parse.java:181) >> >> at >> >> org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:116) >> >> >> at >> >> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:231) >> >> >> at org.apache.velocity.Template.merge(Template.java:256) >> >> at com.sony.soe.web.mvc.VelocityView.go(VelocityView.java:181) >> >> at >> com.sony.soe.guilds.view.VelocityLayout.go(VelocityLayout.java:135) >> >> at org.infohazard.maverick.flow.CommandBase.go(CommandBase.java:79) >> >> at org.infohazard.maverick.Dispatcher.service(Dispatcher.java:345) >> >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) >> >> at >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) >> >> >> at >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) >> >> >> at >> >> net.sf.acegisecurity.ui.AbstractIntegrationFilter.doFilter(AbstractIntegrationFilter.java:170) >> >> >> at >> >> com.sony.soe.guilds.controller.SecurityFilter.doFilter(SecurityFilter.java:118) >> >> >> at >> >> net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:88) >> >> >> at >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) >> >> >> at >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) >> >> >> at >> >> org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:17 >> >> >> 1) >> >> at >> >> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) >> >> >> at >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) >> >> >> at >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) >> >> >> at >> >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) >> >> >> at >> >> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) >> >> >> at >> >> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) >> >> >> at >> >> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) >> >> >> at >> >> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) >> >> >> at >> >> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) >> >> >> at >> >> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) >> >> >> at >> >> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) >> >> >> at >> >> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) >> >> >> at >> >> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) >> >> >> at >> >> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) >> >> >> at >> >> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) >> >> >> at >> >> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >> >> >> at >> >> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) >> >> >> at >> >> org.apache.catalina.valves.RequestDumperValve.invoke(RequestDumperValve.java:169) >> >> >> at >> >> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) >> >> >> at >> >> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) >> >> >> at >> >> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) >> >> at >> >> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) >> >> at >> >> org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:296) >> >> at >> org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:372) >> >> at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:694) >> >> at >> >> org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:626) >> >> >> at >> org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:807) >> >> at >> >> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644) >> >> >> at java.lang.Thread.run(Thread.java:534) >> >> ----------------------------------------- >> >> Andres March >> >> Platform - Apps Engineering >> >> Sony Online Entertainment >> >> desk: 858.577.3373 >> >> cell: 619.519.1519 >> > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting > Tool for open source databases. Create drag-&-drop reports. Save time > by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. > Download a FREE copy at http://www.intelliview.com/go/osdn_nl > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |