-
Notifications
You must be signed in to change notification settings - Fork 909
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
chocolatey.config gets corrupted when multiple processes access simultaneously #1047
Comments
The error seems to be in |
@mwallner note that this writes a file called chocolatey.config.update, then it compares this file versus the original to see if it has changed (line 86 in your image). Only then does it copy over the existing. I think possibly we need to read the file back in to see if it is valid prior to overwriting. What do you think? |
@ferventcoder as far as I've tracked the bug it seems to be a timing issue .. I think the file isn't really written synchronously with _fileSystem.copy_file - and _fileSytem.delete_file stops the copy-operation somewhere during it's runtime.. I'd suggest to only delete the .update file if the content of the .config file and the .update file match |
Rewrites the XML serialization service in a few specific ways: - Should update hash checks now builds the update file in memory rather than committing it the disk, and checks the hash in memory. - The ".update" file now using the slightly hardier File Replace to replace the undated file, and also generates a ".backup". - When desieralizing, we now check for a ".backup" if serialization fails and attempt that too. - Generally use streams and dispose where possible.
Rewrites the XML serialization service in a few specific ways: - Should update hash checks now builds the update file in memory rather than committing it the disk, and checks the hash in memory. - The ".update" file now using the slightly hardier File Replace to replace the undated file, and also generates a ".backup". - When desieralizing, we now check for a ".backup" if serialization fails and attempt that too. - Generally use streams and dispose where possible.
Allows for the more correct replacement and backup of files on the filesystem.
Allows for the more correct replacement and backup of files on the filesystem.
Allows for the more correct replacement and backup of files on the filesystem.
Allows for the more correct replacement and backup of files on the filesystem.
Previously, the xml file serialization could cause corruption when it did not properly replace the file or when multiple choco processes were running at the same time. Additionally, there was no backup of the original config, so the configuration would need to be reset back to the default configuration and then readjusted. Switch to evaluating differences in memory instead of an update file. If the upates are different, then write out the update file and use replace file to have it create a backup of the old file and replace the config with the updated version. When deserializing, if the file is corrupt, look to use the backup and put it back in place if it works. Handle cases where there is no original config file and the backup file doesn't exist. Another benefit of comparing in memory is that no errors are logged for non-admins when the config update file can't be written.
Fixed for 0.10.4 |
Please reopen, still an Issue in 0.10.5 here's a sample of
1 good thing though: now there's a |
Isnt it re-referenced here? oh nope nevermind. this ticket is linked to that, but closed. I do still have this issue in 10.5 as well. We just moved all our hosts back to 10.3 for the time being. |
The fixes that went into for this are supposed to look at the file after it saves it and determine if it is good - if not it should roll back old config. |
Let's open a new issue and reference this one. |
First of all, I do know this problem seems to be related to ChocolateyGUI (read on) - but I think the error is in chocolatey.dll - so I decided to post this Issue here.
chocolatey.config xml gets corrupted
When starting chocolateyGUI while another process uses choco (like choco.exe from command-line) - chocolatey.config will be corrupted and can't be read any longer. - invalid xml, the XML serializer just seems to stop writing the file.
example of .config before the issue occurs
example of .config afterwards
once this occurs, chocolatey can't be used anymore:
the output
choco list -lo -verbose -debug
:chocolatey.config should only be read, not written every time ChocolateySources are read via chocolatey.dll
Why does chocolatey.config need to be written every time ChocolateyGUI is opened?
steps to reproduce
C:\ProgramData\chocolatey\config\chocolatey.config
will be corruptedscreenshots
Having a look at the soures of chocolateyGUI reveals that this happens during initialization of

chocolatey.dll
The text was updated successfully, but these errors were encountered: