-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add custom Examine FileSystemDirectoryFactory using Umbraco SiteName #15571
Conversation
So that the Umbraco SiteName property is used when generating the temp folder name hash
Hi there @Jeavon, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
Hi @Jeavon , Thanks for this update! Someone from the core collaborators team will have a look at it soon. This looks like an interesting one to test 😅 Cheers and Happy New Year! |
@mikecp reach out if you want to see how I'm testing it locally, it is quite fun 😉 |
Would be great to know how you are testing locally @Jeavon. I'd also been keen to understand more about how and why setting the site name is important on Azure App Service. |
Sure thing @nzdev , create 2 launch profiles such as SiteA and SiteB e.g
Run then both in different shells
Umbraco's temp files (NuCache etc) will be stored in different paths due to the SiteName being used to generate the temp path however the Examine Indexes will be in the same temp location and I generally find with a few edits and publishes one or both of the sites will start throwing exceptions due to index locks. We have seen this same exception with repeated slot swapping of Azure Apps (requiring App Restarts and tricky index rebuilds to resolve), however by adding the SiteName property as a sticky slot setting with different values between slots (and this PR modification) the issue doesn't seem to occur. Without SiteName being set at all we have seen issues with NuCache locking also with repeated slot swapping. We've only seen this with Windows Apps, I've not tried with Linux, might be interesting ;) |
Hey @Jeavon, this is fascinating... Slots can't be sharing the same temp directory otherwise Umbraco wouldn't work in slots at all, so there must be something else going on... Given that your fix improves things, this suggests to me that the issue is to do with the Umbraco site not shutting down properly/gracefully during the initial app pool recycle of a slot swap operation - leaving indexes locked. I think the reason this fix works is because on that recycle the appsettings are now pointing at a different temp location. I see a lot of anecdotal file locking issues in Azure pop up in Discord and on the forum, even with "correct" config in place, and the more I see, the more I'm convinced Umbraco (or perhaps asp.net itself) has a more general issue with shutting down, especially in Azure. I'll see if I can convince some lovely HQ & community members to help me investigate this separately. In the meantime, I'll give this a test and get back to you. I will say that I'm not a fan of having to add Azure specific config to make Umbraco run nicely on Azure - but as this matches the approach in use for nucache I guess we should roll with it. |
Yep, that's exactly my best guess @JasonElkin Slots certainly don't share temp but there something magically happening at very the final point of swapping whilst running with temp folders, @nzdev has looked at this in detail previously too. This change is also helpful for simulating load balancing locally using launch profiles too. |
Thanks @Jeavon, works a treat! |
Forigve a possible foolish question, I know too little about the underlying tech(nicals) but understand it in general. |
When Examine is set to use either SyncedTempFileSystemDirectoryFactory or TempFileSystemDirectoryFactory the SiteName property should be used in the hash for the folder name in the same way as LocalTempStorageLocation does (https://github.com/umbraco/Umbraco-CMS/blob/contrib/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs#L136).
This PR implements this change by creating a custom TempEnvFileSystemDirectoryFactory (https://github.com/Shazwazza/Examine/blob/release/3.0/src/Examine.Lucene/Directories/TempEnvFileSystemDirectoryFactory.cs).
This should help with Azure App Slot Swapping indexing locking as the SiteName property can be made sticky to each slot with a different value (as we can do for the published cache already). It also can be used when debugging locally with multiple launch profiles