Skip to content
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

Fix a bug in sync caches where memory usage kept increasing when the eviction listener is set (v0.11.x) #295

Merged
merged 7 commits into from
Aug 4, 2023

Conversation

tatsuya6502
Copy link
Member

This PR fixes a bug in sync::Cache and sync::SegmentedCache, which causes eviction listener's key-level locks not to be removed after sending notifications. This happened only when the Immediate notification delivery mode is used for the eviction listener. (It is the default mode) Another mode, Queued mode, is unaffected as it does not use the key locks.

These key locks are stored in an internal moka::cht::SegmentedHashMap with Arc<K> as their keys. So this bug caused the SegmentedHashMap to hold all keys K that has been inserted to the cache. It will continuously increasing memory usage until the cache is dropped.

Tested the fix by adding a check to unit test if the SegmentedHashMap is empty after sending all notifications.

@tatsuya6502 tatsuya6502 self-assigned this Aug 3, 2023
@tatsuya6502 tatsuya6502 added the bug Something isn't working label Aug 3, 2023
@tatsuya6502 tatsuya6502 added this to the v0.11.3 milestone Aug 3, 2023
@tatsuya6502 tatsuya6502 changed the title Fix a bug that eviction listener key-level locks are not removed (v0.11.x) Fix a bug that eviction listener's key-level locks are not removed (v0.11.x) Aug 3, 2023
@tatsuya6502 tatsuya6502 changed the title Fix a bug that eviction listener's key-level locks are not removed (v0.11.x) Fix a bug in sync caches where memory usage kept increasing when the eviction listener is set (v0.11.x) Aug 4, 2023
Copy link
Member Author

@tatsuya6502 tatsuya6502 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging.

@tatsuya6502 tatsuya6502 added this pull request to the merge queue Aug 4, 2023
Merged via the queue into main with commit e9aa951 Aug 4, 2023
37 checks passed
@tatsuya6502 tatsuya6502 deleted the fix-eviction-listener-key-lock-v011 branch August 7, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant