-
Notifications
You must be signed in to change notification settings - Fork 48
Installer upgrade behavior more resilient when files are in use and locked #4217
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
Conversation
johnsimons
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a few comments, but I was thinking that adding a retry with a delay would make things better.
From past experience Antivirus software can cause this kind of locking issues.
Something like https://stackoverflow.com/a/44324346 may be a good start, thoughts?
johnsimons
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ramonsmits LGTM, but I wonder now that you have added retries for the deletion, whether we even need to bother doing the move before hand, something to consider?
|
@johnsimons I've rewritten the installer logic as defined in: |
…uired for top directory of the path
…o the user what happened with the folder content
…es that are in use
… trying to move the folder away from /back to the original path
…ly when that complete the folders are swapped and the old version is deleted
…form user what steps failed and if manual steps are required
…ould be on another drive
Co-authored-by: Andreas Bednarz <110360248+abparticular@users.noreply.github.com>
Co-authored-by: Andreas Bednarz <110360248+abparticular@users.noreply.github.com>
Co-authored-by: Jo Palac <jpalac@users.noreply.github.com>
…the opposite of DeleteDirectory.
061593a to
7682ca0
Compare
johnsimons
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a few more comments for consideration
| } | ||
| catch (Exception ex) | ||
| { | ||
| Trace.WriteLine($"ServiceControlInstaller.Engine.Instances.BaseService::PurgeOld Unable to cleanup {oldPath}. Reason: {ex.Message} ({ex.GetType().FullName})"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't we using the Logging class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… does not see unhandled exception
It frequently happens that for unknown reasons files are still in use which result in errors like the following:
This change improves the installer logic when upgrading instances by first preparing the new version in a new folder and when that completes swap the folder of the current instance for the folder of the new instance. This resolves most if not all issues around files that are locked or in use.
It also makes the folder delete operation more resilient against very short lock that can be caused because the instance although reporting stopped in Windows Service Control Manager to still be running for a very little time or because a virusscanner locks a file or any other reason for a file to be in use.
Summarized:
IOException10x with a 100ms sleep to allow for short file locksThis is tested with all 3 monitor types by upgrading 5.2.4 to 5.3.0-alpha.0.30 from the build server.