dotnet / dotnet/aspnetcore

Issue with enableShadowCopy and shared shadowCopyDirectory in Multi-Environment Deployment

Open
#50,531 4 comments 0 reactions 1 assignee Claimed by @BrennanConroy View on GitHub
area-networking
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

While deploying an ASP.NET Core application, I encountered file locking issues. I discovered the enableShadowCopy parameter, which seemed to address these concerns.

However, the documentation around this feature is lacking, with no detailed information on its functionality, prerequisites, etc.

The reference I followed is [here](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced?view=aspnetcore-7.0#shadow-copy).

Configuration:

I have an application deployed across multiple pools on the same machine, simulating multi-environment deployment. All application folders are structured at the same level. I've set up shadow copying as shown in the documentation:




There's no indication in the documentation that the shadowCopyDirectory should be unique for each app, so I used a shared directory.

Issues Encountered:

Soon after, we started observing problems related to missing DLLs and received errors like:

```
Application '/LM/W3SVC/6/ROOT/Api' with physical root 'C:\Api\' failed to load coreclr. Exception message:
File changed between copy and start of application, restarting.
```

Upon investigation, I found a concerning code segment in the ASP.NET Core source. This segment deletes ALL subdirectories within the user-defined shadowCopyDirectory, which is risky. In our deployment, it led to shadow copy directories unintentionally deleting one another.

Here's the concerning code:
[ASP.NET Core Source](https://github.com/dotnet/aspnetcore/blob/c7650b02364d9481be21da95219fff8a4896ce6f/src/Servers/IIS/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.cpp#L182-L200).

Please consider revising this behavior or, at a minimum, provide clear documentation on the potential risks and the necessity of unique shadow copy directories for each application.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.