• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Waiting for file lock release?

New Here ,
Jun 14, 2006 Jun 14, 2006

Copy link to clipboard

Copied

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.
TOPICS
Advanced techniques

Views

555

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 14, 2006 Jun 14, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 15, 2006 Jun 15, 2006

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 15, 2006 Jun 15, 2006

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 16, 2006 Jun 16, 2006

Copy link to clipboard

Copied

I'd go with Mr. Black.

You could also try to rename the fale ( rename it back) to test if the file is locked.

If waiting for the file to become unlocked is slowing down performance, you could outsource the delete-file operation into a separate file, call that by cfhttp with a low cfhttp-timeout but a high request-timeout.
That way your application does not have to wait since the delete-file process (with waiting, etc.) is running in separate request on the server. Of course you would not know when the file is actually being deleted, but you don't have to wait for it either.
p.s. "Separate file called by cfHTTP" could be a webservice nowadays.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 16, 2006 Jun 16, 2006

Copy link to clipboard

Copied

LATEST
if you're running Enterprise edition, the delete function sounds like a job that should be delegated to an Asynchronous Event Gateway.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation