-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
move_files tasks depends on the Version from the db and fails #4803
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
Comments
@humitos Would it be okay if i take this issue? I think you want something like this try:
version = Version.objects.get(pk=version_pk)
except Version.DoesNotExist:
log.warning(f'Version with pk {version_pk} does not exist') |
I just realize that this also happens at probably for the same reason that the Version/Project is deleted manually by the user. We should think about a generic way of handling this from all the tasks that depend on objects being on the database. |
@humitos Probably we can implement custom in this, we can write our own from django.core.exceptions import ObjectDoesNotExist
def get(self, **kwargs):
try:
return super().get(**kwargs)
except ObjectDoesNotExist:
# warning or something else |
Sounds good to me. We may have to name it different, though. I'd like to be more explicit on the name for the use case: We will also need to handle when the query returns |
@app.task(queue='web')
def task_name(version_pk, *args, **kwargs):
# code
version = Version.objects.get_object_or_log(pk=version_pk)
if not version:
return None
# code |
@dojutsu-user yes, something like that is what I have in mind |
Similar to #4789, we pass the
Version.pk
to themove_files
task. If the version is removed before the task is executed, the task fails because the row is not in the database anymore.The problem is at this line,
https://github.com/rtfd/readthedocs.org/blob/3fbb0c1a7c94bcc979f54d67fad8dc94f74854c8/readthedocs/projects/tasks.py#L838
We should handle this exception properly and do not fail the task. We need to think this a little more, but I suppose that if there is no version in the database, there is nothing to move or do at that point. So, I think that just adding a
try/except
block with anlog.warning
will do the trick.This happens frequently: https://sentry.io/read-the-docs/readthedocs-org/issues/235379529/?query=is:unresolved
The text was updated successfully, but these errors were encountered: