Catch UnicodeDecodeError when opening corrupt beat-schedule.db#8806
Conversation
auvipy
left a comment
There was a problem hiding this comment.
interesting catch! can we add some unit test for it? although we can go without it as well for this case
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8806 +/- ##
==========================================
+ Coverage 81.19% 81.22% +0.03%
==========================================
Files 148 148
Lines 18523 18523
Branches 3165 3165
==========================================
+ Hits 15039 15045 +6
+ Misses 3196 3191 -5
+ Partials 288 287 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
Thanks for checking. I'll see if i can make a test. It doesn't look like there is one for |
There is existing code to detect if celerybeat-schedule.db is corrupted and recreate it, however sometimes a UnicodeDecodeError or TypeError is thrown in the process of throwing the KeyError. This catches that error and allows Beat to use the existing code to recreate the database. (Fixes celery#2907)
fb1951e to
2cebf34
Compare
|
CI approved to run - it will take time though. |
|
@Nusnus @auvipy I've added two tests that exercise how It seems a little smelly that we're catching a few different exception types, but I'm not sure of a better method. It feels like |
|
Hmm, i see that Lines 529 to 539 in 8f38999 Should I change |
would love to see how that works. but not fully sure now. may be in another PR? or you want that to try here? |
|
Let's go with what I've got here for now. I think i have everything covered and we can add more catches later if they appear. I don't want to catch an exception that can't actually be resolved by recreating the database, like an IO error or something. With that question resolved, I think this is good to merge. 🎉 |
LGTM, your call on the merge @auvipy |
|
thanks guys! |
There is existing code to detect if celerybeat-schedule.db is corrupted and recreate it, however sometimes a UnicodeDecodeError is thrown in the process of throwing the KeyError. This catches that error and allows Beat to use the existing code to recreate the database.
(Fixes #2907) This issue was closed because the workaround posted helped the user, but the underlying issue was not resolved.
Example of a stack trace this fixes: