Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Ezra Parker / Ezra Parker (Ezra Parker)
Created: 03/24/2009
Components: Core Runtime, Session Management
Versions: 9.0
Failure Type: Unspecified
Found In Build/Fixed In Build: 0000 / 234219
Priority/Frequency: Major / Unknown
Locale/System: English / Platforms All
Vote Count: 2
Problem:
OnSessionStart does not single-thread requests. More specifically, if the session identifier cookie(s) are already present in a user's browser, then it is possible for a session variable created in a long-running onSessionStart method to result in an undefined variable error when references by a concurrent request.
Under these circumstances, only the first request will fire the onSessionStart method, and subsequent requests will be allowed to proceed without waiting for the method to complete.
Although the documentation does not explicitly state that all requests for a session will wait for the completion of this method, the language used ("You never need to lock the Session scope to set its variables using this method.") seems to imply this, as it is almost identical to the verbiage for the onApplicationStart method, where all pending requests will be queued until the method is complete.
Method:
1. Access the test case, and wait for the session to time out
2. Refresh the page twice in quick succession
The second request will error as it references a session variable that the first request has not yet set.
<!--- Application.cfc --->
<cfcomponent output="false">
<cfset this.name = "SessionTest" />
<cfset this.applicationTimeout = CreateTimeSpan( 0, 0, 1, 0 ) />
<cfset this.sessionManagement = true />
<cfset this.sessionTimeout = CreateTimeSpan( 0, 0, 0, 10 ) />
<cffunction name="onSessionStart" output="false" returntype="void">
<!--- Delay session startup for 5 seconds --->
<cfset Sleep(5000) />
<!--- Set a test session variable to the value of the session's unique identifier --->
<cfset session.test = session.sessionID />
</cffunction>
</cfcomponent>
<!--- index.cfm --->
<cfoutput><p>SessionID: #session.test#</p></cfoutput>
Result:
SessionID:
The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.
The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
Element TEST is undefined in SESSION.
The error occurred in C:\work\depot\ColdFusion\cf_main\cfusion\wwwroot\bugs\76135\bug76135.cfm: line 1
1 : <cfoutput><p>SessionID: #session.test#</p></cfoutput>
Resources:
* Check the ColdFusion documentation to verify that you are using the correct syntax.
* Search the Knowledge Base to find a solution to your problem.
Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7
Remote Address 127.0.0.1
Referrer http://localhost:8500/bugs/76135/
Date/Time 24-Mar-09 11:40 PM
Stack Trace
at cfbug761352ecfm25925933.runPage(C:\work\depot\ColdFusion\cf_main\cfusion\wwwroot\bugs\76135\bug76135.cfm:1)
coldfusion.runtime.UndefinedElementException: Element TEST is undefined in SESSION.
at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1713)
at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1666)
at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1801)
at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1794)
at cfbug761352ecfm25925933.runPage(C:\work\depot\ColdFusion\cf_main\cfusion\wwwroot\bugs\76135\bug76135.cfm:1)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:216)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:416)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:338)
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:87)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:53)
at coldfusion.CfmServlet.service(CfmServlet.java:177)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at jrun.servlet.FilterChain.service(FilterChain.java:101)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3037983
External Customer Info:
External Company:
External Customer Name: Ezra Parker
External Customer Email: 36A12A6148ED0BE899201587
External Test Config: 03/24/2009
Attachments:
Comments: