Skip to main content
Known Participant
June 14, 2006
Question

Waiting for file lock release?

  • June 14, 2006
  • 2 replies
  • 769 views
I currently have a CF-enabled page running along with an administrative page which is used to manage files and directories being shown by the main page. Running latest version of CFMX on a Windows 2003 server. I've noticed, on occasion, when I try to delete a file using the admin app, I receive an error paraphrased as "You cannot delete file C:\myDirectory\myPicture.jpg for some unknown reason". A second later when I try again it works. I have come to the realization that the two apps are butting heads when it comes to system file locks. While the main page is serving a picture to be displayed, it understandably locks the file for a time (seems longer than it really needs to, though). The admin page comes along and wants to delete the same file and can't because the other page has it locked down in the system. Not using <CFLOCK> tag anywhere in the code.

My question is this: Is there a way that my admin page can wait in a loop until the file lock is released by the main page in order to delete the file without ever throwing an error?

I cannot seem to find anything on this but have noticed others mention this problem. Any assistance appreciated.
This topic has been closed for replies.

2 replies

June 16, 2006
if you're running Enterprise edition, the delete function sounds like a job that should be delegated to an Asynchronous Event Gateway.
June 14, 2006
You could place a read-only lock around the code that displays the image, and an exclusive lock around the code that does the delete. If the picture is being displayed, the deletion code will wait until the read-only lock is released.
Known Participant
June 15, 2006
I fear this may have a deleterious effect on performance. To do an extra lock on each file as it's being served, in addition to the system file lock, may slow performance to unacceptible levels. Particularly since there are a large number of thumbnails being loaded and displayed on the main page (apologies for not mentioning that in my initial post). I would think putting the admin app in a loop until the system file lock is released before doing anything to the file in question would be a much more efficient use of cycles in this particular scenario. Any other thoughts out there?
Participating Frequently
June 15, 2006
If you are sure that this is a file-sharing problem, something very basic could work. For example,

<cftry>
<!--- Attempt to delete file --->
<cfcatch>
<!--- Make a pause for N seconds and try again --->
</cfcatch>
</cftry>