Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

AttributeError: 'LruCache' object has no attribute '_on_resize' #8586

Closed
erikjohnston opened this issue Oct 19, 2020 · 2 comments · Fixed by #8591
Closed

AttributeError: 'LruCache' object has no attribute '_on_resize' #8586

erikjohnston opened this issue Oct 19, 2020 · 2 comments · Fixed by #8591

Comments

@erikjohnston
Copy link
Member

I'm getting the following after updating a9a8f2972..85c56445f

2020-10-19 13:52:34,985 - synapse.federation.federation_server - 927 - ERROR - PUT-181 - Failed to handle edu 'm.typing'
Traceback (most recent call last):
  File "/home/erikj/synapse/synapse/federation/federation_server.py", line 923, in on_edu
    await handler(origin, content)
  File "/home/erikj/synapse/synapse/handlers/typing.py", line 328, in _recv_edu
    users = await self.store.get_users_in_room(room_id)
  File "/home/erikj/synapse/synapse/util/caches/descriptors.py", line 153, in __get__
    if expected_thread is not threading.current_thread():
  File "/home/erikj/synapse/synapse/util/caches/deferred_cache.py", line 93, in __init__
  File "/home/erikj/synapse/synapse/util/caches/lrucache.py", line 128, in __init__
  File "/home/erikj/synapse/synapse/util/caches/__init__.py", line 120, in register_cache
    metric_name = "cache_%s_%s" % (cache_type, cache_name)
  File "/home/erikj/synapse/synapse/config/cache.py", line 83, in add_resizable_cache
    properties.resize_all_caches_func()
  File "/home/erikj/synapse/synapse/config/cache.py", line 208, in resize_all_caches
    callback(new_factor)
  File "/home/erikj/synapse/synapse/util/caches/lrucache.py", line 386, in set_cache_factor
AttributeError: 'LruCache' object has no attribute '_on_resize'
@erikjohnston
Copy link
Member Author

Looks like #8561 calls register_cache in LruCache.__init__ before we actually define the _on_resize callbacks. I think its just a case of moving it to the end of the function.

(How is CI happy with this?)

@richvdh
Copy link
Member

richvdh commented Oct 19, 2020

CI is happy with it because it doesn't have any per-cache cache-factor config, and set_cache_factor has:

        if new_size != self.max_size:

in other words, no resizing is necessary so it doesn't run _on_resize.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants