-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
Better recovery when registry.json is corrupted #3351
Better recovery when registry.json is corrupted #3351
Conversation
It's been a while since it's happened, I wonder if #3250 helped. |
6a5be25
to
ae43435
Compare
Hm, could we set some sort of (unserialized) flag in the Registry object when it is detected as corrupted and moved, which we later check when the GUI is ready, and display a warning? |
ae43435
to
ebc9861
Compare
Done. I liked |
* Check for registry corruption after switching game instances * Clear corrupted registry message after displaying it * Print more detailed error message to help with recovery * German translation for error message
Pushed some small changes, now we also check if a corruption happened (or better: got detected) during instance switch. |
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.
Looks good. Probably a long overdue feature, saves some "complicated" manual steps that were inevitable anyways.
Could we automate the reinstallation of all the previously installed modules next...?
Problem
If your
CKAN/registry.json
file gets truncated somehow, CKAN won't start.Examples of this happening in the wild:
#1386, #1540, #1904, #1779, #2123, #2448, #2566, #2588, #2871, #3188, #3229, #3233
(Inspired by #3347.)
Cause
The deserialization call can throw
JsonSerializationException
orJsonReaderException
(both inherit fromJsonException
), and we don't handle it.We currently don't have any clues as to how or why the corruption happens, because the exception can be thrown long after the file is corrupted. By the time the user knows it happened, it's too late to investigate.
Changes
Now if our attempt to load
registry.json
throws aJsonException
,RegistryManager.LoadOrCreate
will catch it and move the file to a new location,CKAN/registry.json_CORRUPTED_20210417020300
, where that last part is the current date. Then a new registry will be created in its place, to be filled in as usual for a new registry. This way even though the user's data is lost, they will still have a working CKAN, and they may be able to recover some data from the corrupted file. Then the GUI notifies the user that this happened.