App Service: File Lock Warnings in Web Log

I'm writing this post because of an open issue right now with writing certain files on App Service environments with more than one instance. This is not a critical issue and can be safely ignored until an update can be made to agility.web.dll to prevent this.

This is the error you might see:

*** Warning  *** RD0003FF9CDBF5 *** 2018-10-25 17:07:40
System.IO.IOException: The process cannot access the file 'D:\Home\AgilityLogs\TestWebsiteConfiguration.tmp' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
   at System.IO.File.WriteAllText(String path, String contents)
   at Agility.Web.AgilityWebsiteService.CheckDomainStatus()

I'll explain what is happening here.

The agility platform constantly contacts your syncing web servers to see if they are responsive, have any errors, can write content files, and can write log files. In order to test writing content files and log files, agility will actually attempt to save and read a file from the filesystem on the web server. Normally this isn't an issue.

However, in App Services, there's a shared filesystem between all your instances. This means that instance A and instance B might try to write/read the same file at the same time. This is the error that is shown in the error log.

Logic needs to be updated in the Agility.web.dll to prevent this conflict. This has already been resolved for syncing content and other critical things, however this is an open issue for our "Check Domain Status" process that pings your website and tests writing files.

This post will be updated when it is resolved in the latest release of the Agility.Web.dll nuget package.




Please sign in to leave a comment.

Didn't find what you were looking for?

New post