I am using ColdFusion 8 and jQuery.
I am working on a page that does several ajax calls via jQuery. Quite frequently, I see an application timeout error on one of the pages that is called via ajax. I do not get the error on every ajax call. I do not get the error on the same call each time.
From what I understand the error is caused by the different pages each trying to access the same application variable at the the same time. I am not sure what is the best approach to resolve the issue.
The code seems to be setting a two second timeout. This seems excessive. Should the cflock be set to readonly? Any other advice?
A timeout occurred while attempting to lock the Application scope.
The error occurred in E:/INETPUB/WWWROOT/DEV/AVCAT/Application.cfm: line 53
Called from E:/INETPUB/WWWROOT/DEV/Application.cfm: line 1
Called from E:/INETPUB/WWWROOT/DEV/Application.cfm: line 53
Called from E:/INETPUB/WWWROOT/DEV/Application.cfm: line 1
51 :
52 : <!---<cfif NOT IsDefined("application.datasource")>--->
53 : <cflock timeout="#CreateTimeSpan(0,0,2,0)#" SCOPE="Application">
The
timeoutattribute of thecflocktag is expecting seconds. So if you want a two minute timeout period than thetimeoutattribute should be set to 120. Like this (and I agree that seems excessive):The
CreateTimeSpan()function returns a date/time object. I’m not sure how yourcflockis interpreting that value for the timeout.As far as using an
exclusivelock versus areadonlylock. If your code is only reading the application scope variables than use areadonlylock. If your code is setting the application scope variables than use anexclusivelock. Using anexclusivelock, which you are using by not specifying thetypeattribute, will cause that code to be single threaded. That may be your issue there.