-
Notifications
You must be signed in to change notification settings - Fork 0
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
Do not crash if results are read while cache does not exist #98
base: develop
Are you sure you want to change the base?
Conversation
backend/search/models.py
Outdated
# the cache file was deleted. Go on and return an empty set - | ||
# this is not problematic because an inconsistency between model | ||
# and cache will be detected by the code that performs the search. | ||
results = '' |
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.
might be nicer to return []
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.
Writing this here as well for reference: I think one of the problems we previously had is that in some cases running a query would give 0 results, and it wasn't clear to the user that an error had occurred (as opposed to the query really having no results)
Please verify that this change isn't reintroducing that behaviour.
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.
That behaviour was because we were not regenerating results at the time in case of errors. We would simply record that an error occurred and keep the cache empty. But the perform_search method now properly checks if there were errors for every CSR and redoes the search if so.
logger.warning( | ||
f"Cache size for {self} is {actual_size} while it is supposed to be {self.cache_size}" | ||
) | ||
return size_equal |
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.
So let's assume there's a cache file with the wrong size (for whatever reason) what happens next?
would it be regenerated on the next query? do we have to manually remove it?
nvm, it should be regenerated by the code on line 415
There was no exception handling when the cache was read in order to fetch the results of a
ComponentSearchResult
. The cache was apparently sometimes not present even though the object was created - not really clear why that happens but it does. If this happens, return an empty result set. To make sure that thecheck_results
method (renamed tocheck_cache
) still works (which was relying on an exception), I rewrote this method to check on its own if the cache is there.