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 race condition in TestThinCache #3198

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

HoustonPutman
Copy link
Contributor

Basically onRemoval() has a much weaker guarantee than it is assuming right now.
This method can be called asynchronously, after the key is already gone locally.
Or even after the new cache is created, and it doesn't have the value that is being removed in it's local cache.

This is a way to solve most of the issues, but one race condition still remains. (Not sure it's possible to solve)
If the cache evicts a key, then the user puts that key with its original value right afterwards, this code will still assume it should be removed. Since we don't have access to timings for removal and addition, there is no way to fix this. (I think).

But for the sake of our small test failures, this should be sufficient.

Copy link
Contributor

@magibney magibney left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for fixing this.

I'll put some thought towards whether there's a way to fix it for the "same value" case.

@HoustonPutman
Copy link
Contributor Author

In the meantime I'll merge, since this is failing the tests occasionally.

@HoustonPutman HoustonPutman merged commit 85f50fa into apache:main Feb 21, 2025
2 of 3 checks passed
@HoustonPutman HoustonPutman deleted the thin-cache-test-fix branch February 21, 2025 15:58
HoustonPutman added a commit that referenced this pull request Feb 21, 2025
HoustonPutman added a commit that referenced this pull request Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants