Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shadow copy up to date check on startup #52831

Merged
merged 2 commits into from
Dec 20, 2023
Merged

Fix shadow copy up to date check on startup #52831

merged 2 commits into from
Dec 20, 2023

Conversation

BrennanConroy
Copy link
Member

Fixes #48233

If using shadow copy in ANCM and you shutdown the app (e.g. app_offline.htm) then delete a subfolder (with a dll), starting up the app can cause a crash that can only be resolved by adding back the deleted folder. Or resolved by deleting the shadow copy folder (either manually or with cleanShadowCopyDirectory setting turned on).

The issue submitter helpfully pointed out the code that was problematic, we basically swapped which directory is the "main" directory every recursion of the up to date function. The fix is simple, keep the app directory as the main directory.

Test added that repros the scenario.

@BrennanConroy BrennanConroy added feature-iis Includes: IIS, ANCM area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions labels Dec 14, 2023
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos, @someguy20336!

@BrennanConroy BrennanConroy merged commit 496e975 into main Dec 20, 2023
@BrennanConroy BrennanConroy deleted the brecon/iter branch December 20, 2023 00:53
@ghost ghost added this to the 9.0-preview1 milestone Dec 20, 2023
@antmjones
Copy link

Is there any possibility of this fix being included in a 8.0.x point release? I was caught out by this today and it was far from immediately obvious what had gone wrong (thanks again to @someguy20336 for the detailed info in the original report!)

I now know there's a workaround with setting cleanShadowCopyDirectory to true, but presumably this is going to have an impact on application startup time (given it will prevent skipping copying of files where the last write time is unchanged - https://github.com/dotnet/dotnet/blob/v8.0.4/src/aspnetcore/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/Environment.cpp#L187).

@BrennanConroy
Copy link
Member Author

/backport to release/8.0

Copy link
Contributor

github-actions bot commented May 9, 2024

Started backporting to release/8.0: https://github.com/dotnet/aspnetcore/actions/runs/9025051117

Copy link
Contributor

github-actions bot commented May 9, 2024

@BrennanConroy backporting to release/8.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix shadow copy up to date check on startup
Using index info to reconstruct a base tree...
M	src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs
CONFLICT (content): Merge conflict in src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix shadow copy up to date check on startup
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Contributor

github-actions bot commented May 9, 2024

@BrennanConroy an error occurred while backporting to release/8.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-iis Includes: IIS, ANCM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ANCM crashes with shadow copy enabled and the new deployment deleted a directory
3 participants