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
Prevent DoesNotExist failure on activity API (fix #2227) #2268
Prevent DoesNotExist failure on activity API (fix #2227) #2268
Conversation
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.
Have you done a quick performance assessment? From what I understand, we're switching from a QuerySet to a list and this can be less efficient.
item.related_to | ||
except DoesNotExist as e: | ||
log.error(e, exc_info=True) | ||
else: |
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.
❤️
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 remembered 😉
Yep, done on my environment, might need some proper testing on preprod. |
OK. For reference, it's not glorious as it is:
|
Yes, activity has not evolved since the first release when there was less than 1000 users.
but (because there is one), it requires a lot of storage. |
This PR prevent the
DoesNotExist
exception from breaking the Activity API.Under the hood, the problem occurs when some data is manually deleted without a proper purge. It would need a data migration to cleanup the existing data.
NB: tested but not included in this PR: to reduce the size of the activity collection it's possible to use TTL index and let mongo do its job in the background (possibly configurable with a
ACTIVITY_RETENTION_DAYS
settings). See for details;