Status/Resolution/Reason: Closed/Withdrawn/NotABug
Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood (Bradley Wood)
Created: 11/11/2013
Components: Core Runtime
Versions: 10.0
Failure Type: Crash
Found In Build/Fixed In Build: Final /
Priority/Frequency: Critical / All users will encounter
Locale/System: English / Windows 7 SP1 64-bit
Vote Count: 1
Problem Description: My understanding is that ColdFusion supports a style of reentrant locks where the same request can reacquire the same lock again. I've had a very hard time confirming in the docs, please correct me if I am wrong with a link to documentation. The issue is that if a request has obtained a named readonly lock, it will not be able to acquire an exclusive lock of the same name. There is no meaningful error, the cflock tag just times out. It appears that the exclusive lock is timing out because it's being blocked by the readonly lock even though it's held by the SAME request.
Steps to Reproduce:
<cflock name="myLock" type="readonly" timeout="1">
<cflock name="myLock" type="exclusive" timeout="1"></cflock>
</cflock>
Actual Result:
A timeout occurred while attempting to lock myLock.
Expected Result:
It is expected that myLock will be successfully escalated to an exclusive lock. The readonly lock should not block since it's owned by the same thread.
Any Workarounds:
None that I know of.
It's worth nothing that if both locks are readonly it works.
If both locks are exclusive it works.
And, if the outer lock is exclusive and the inner lock is readonly it works.
The only scenario where ColdFusion fails to obtain the inner lock is when the outer lock is readonly and the inner lock is exclusive.
The code to reproduce above is very minimalistic. In case anyone wants a good use case, consider a shared resource with a getter that acquires readonly access and a setter that requires exclusive access. (I'm using the server scope, but pretend it's some outside caching mechanism)
<cffunction name="get">
<cflock name="foo_access" type="readonly" timeout="1">
<cfif !isdefined("server.foo")>
<cfset set()>
</cfif>
<cfreturn server.foo>
</cflock>
</cffunction>
<cffunction name="set">
<cflock name="foo_access" type="exclusive" timeout="1">
<cfif !isdefined("server.foo")>
<cfset server.foo = "bar">
</cfif>
</cflock>
</cffunction>
<cfoutput>
#get()#
</cfoutput>
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3662524
External Customer Info:
External Company:
External Customer Name: bradwood.com
External Customer Email:
External Test Config: My Hardware and Environment details:
Server Product ColdFusion
Version 10,0,11,285437
Tomcat Version 7.0.23.0
Edition Developer
Serial Number Developer
Operating System Windows 7
OS Version 6.1
Update Level /C:/ColdFusion10/cfusion/lib/updates/chf10000011.jar
Adobe Driver Version 4.1 (Build 0001)
Java Version 1.7.0_15
Java Vendor Oracle Corporation
Attachments:
Comments: