influxdb/cache_system
Marco Neumann 3969b40925
fix: avoid recursive locking during LRU shutdown (#8395)
* test: regression test for #8378

* fix: avoid recursive locking during LRU shutdown

Fixes the following construct during shutdown:

1. `clean_up_loop` holds `members` lock
2. calls `member.remove_keys`
3. `CallbackHandle::execute_requests` requests upgrades weak ref and gets lock
4. other thread drops last external reference to pool member, the
   upgraded weak ref from (3) is now the last strong ref
5. `CallbackHandle::execute_requests` finishes, drops pool member
6. dropping that pool member calls `ResourcePool::unregister_member`
   which is the same lock as we got in (1) => deadlock

We now just avoid modifying `members` during shutdown and just hold a
weak ref there. As a side effect, the `last_used` addressable heap moves
around a bit an is no longer `Arc`ed (see updated diagram).

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-02 14:42:33 +00:00
..
benches refactor: avoid double-hash when updating addressable heap orders (#5577) 2022-09-08 11:50:55 +00:00
src fix: avoid recursive locking during LRU shutdown (#8395) 2023-08-02 14:42:33 +00:00
Cargo.toml fix: re-design LRU cache to be deadlock-free (#8345) 2023-07-31 13:04:34 +00:00