Skip to content

Conversation

@ihtefyw
Copy link

@ihtefyw ihtefyw commented Oct 14, 2025

In advance_hot, if an element is concurrently marked as pinned right after the is_pinned function return false (line 738), the function will loop forever if every element is pinned as unpinned cannot decrement, i.e. the function doesn't detect that the element was pinned in the meantime.
This can happen if the element pinning logic is independent of the cache data structure.

This PR fixes this by storing which key is marked as unpinned, and clearing it if it gets pinned in the meantime.

@ihtefyw ihtefyw changed the title Fix undetected unpinned element in advance_hot Fix undetected pinned element in advance_hot Oct 14, 2025
@arthurprs
Copy link
Owner

Thanks for the PR. We probably want to think of a cheaper way, as building a hashset on that code path is very costly. I'll give this a think

@arthurprs
Copy link
Owner

Superseded by #98

@arthurprs arthurprs closed this Oct 19, 2025
arthurprs added a commit that referenced this pull request Oct 19, 2025
…pins (#98)

ixes a rare edge case reported in #96 where advance_hot can loop forever, as it couldn't detect that previously unpinned items got pinned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants