safe-transaction-service icon indicating copy to clipboard operation
safe-transaction-service copied to clipboard

Cache MetadataRetrievalException for less than 24 hours

Open moisses89 opened this issue 2 years ago • 0 comments

Describe the bug I could check how when the tx-service cannot get the metadata from an ipfs, it is storing the exception on redis for 24hours. I think that is related with the following code:

@cache_memoize(
     60 * 60 * 24,
     prefix="collectibles-_retrieve_metadata_from_uri",
     cache_exceptions=(MetadataRetrievalException,),
 )  

The cache_memoize documentation says that cache_exceptions enables the function to store the exception and returns the exceptions in the subsequent function calls. Then the expected behaviour is return for 24hours an exception.

Exceptions. If the cached function raises any of these exceptions is the
    exception cached and raised as normal. Subsequent cached calls will
    immediately re-raise the exception and the function will not be executed.
    this tuple will be cached, all other will be propagated.

Expected behavior I would like to don't store this exceptions or at least store it for less time.

Additional context https://5afe.slack.com/archives/C01GL8X8L3H/p1660666286167059 Some issues are expected getting MetaData for a while (1 hour, 2...) then we should avoid consume requests trying it.

Proposed solution

  • [ ] Increase for success requests of MetaData to 2 Days.
  • [ ] Exception will be a variable time that is increasing with the retries, for example (1st 30m, 2nd 1 h, 3rd 3h)
  • [ ] Fix max time for exception to 24 hours.

moisses89 avatar Aug 17 '22 08:08 moisses89