How to: Identify which file is getting locked or is not accessible

How to: Identify which file is getting locked or is not accessible

  

Hi

 

One of the most common deployment and runtime errors that pop-up from time to time is an Access Denied exception, or file in use by other process, while a disk operation is being done over a file or folder. We can find this type of errors in several stages of an application life-cycle using the Agile Platform. In more detail:

  • during the 1-Click Publish (1-CP) process of an espace or extension
  • during the Run or Debug of an eSpace
  • during a publication of a Solution
  • during runtime on the first access to an application
  • right after a worker process recycle
  • and during any other custom access to the filesystem

Some of the typical exception messages we can get are like:

 

Internal Error
The process cannot access the file '_delivery.aspx.cs' because it is being used by another process.
Details : System.IO.IOException: The process cannot access the file '_delivery.aspx.cs' because it is being used by another process
.

 

Or like:

 

Type: Error
Message: System.UnauthorizedAccessException: Access to the path 'D:\Program Files\OutSystems\Platform Server\OMLProcessor.xif' is denied.

 

The variations are many, but usually the error message is always explicit to the point of indicating that either a specific file is not accessible due to being locked by another process, or lack of security priviledges to access that file.

 

The best way to troubleshoot this type of problems is to identify the exactly which file is being accessed that generates the exception, and if there's other processes accessing it to. To do this, there's a very simple toll named Filemon, now owned by Microsoft, which will allow you to see all filesystem accesses, and identify the processes/files that are causing the exceptions, as shown in the image in attachment.

 

With Filemon you can start a capture of filesystem accesses, and filter by file extensions, file path, processes, and types of access results (Success, Failure, etc).

 

To use it,

 

  1. Run the FileMon application
  2. Perform the action that's causing the filesystem exception (1-CP, run, debug, access to the applciation) and replicate the exception
  3. Stop the capture and analyze the list of accesses and which generate errors

Hope this is useful in troubleshooting filesystem locks and denied accesses on our systems.

 

Cheers

 

Miguel

HI All

 

Unfortunately, Microsoft removed the Filemon utility from availability, because it recommends the Process Monitor tool, which provides more information about a process accesses, instead of just File System accesses.

 

Thus, I would like to complement this topic with the recommendation to also use the Process Monitor in troubleshooting errors during file system accesses, and how to do it.

 

How to use Process Monitor to find file system locks or access denied errors

 

Just download the Process Monitor tool from the link above, decompress the zip archive, and run the ProcMon.exe executable.

 

This tool monitors several types of accesses by a process (registry, file system, network and process activity and threads).

 

To get only the file system accesses, unselect the Show Registry Activity, Show Network Activity and Show Process and Thread Activity from the upper tool bar. This will get you only the file system accesses.

 

If your troubleshooting an Access Denied, check for file system accesses with result ACCESS DENIED.

 

Hope this helps you troubleshooting file system locks and permissions issues while using the Agile Platform and it's applications.

 

Cheers

 

Miguel Simões João

Just a note if someone stumbles across this trying to find help with the FileSystem component.
I was getting an Access Denied error when trying to write an uploaded file.  Using Process Monitor I discovered that the w3wp.exe process was using the NETWORK SERVICE user to access the folder so I gave that user Modify priviledges on that folder and got it working.

David
Hi,

I just encountered the below error on publishing the eSpace:

Internal Error

The process cannot access the file 'ReferenceThemeImport.Blue.css' because it is being used by another process.
Details : System.IO.IOException: The process cannot access the file 'ReferenceThemeImport.Blue.css' because it is being used by another process.
   at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive)
   at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive)
   at #8Yd.#u3.#p2d(#Z6d callType, String eSpaceName, String& espaceTemporaryPath, String& espacePublicationPath, String testAreaName, Boolean partial, Boolean cleanCode, String uniqueId)
   at #8Yd.#u3.#91d(Byte[] oml, Boolean debugMode, String eSpaceName, Int32 eSpaceVersionId, String userName, Boolean partial, Boolean forceDontReuseTables, Boolean eSpaceAlreadyLocked, String uniqueId, Boolean fromSS)


I tried installing the Process Monitoring and tried a few filtering as you suggested but still I can't find the source of this error. I also tried to make the Outsystems folder as an exception to the anti-virus installed in the machine (as another thread suggested) but still didn't work.

Any other hints?