-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix stale notification when eviction raced with an update
[SOLR-10141](https://issues.apache.org/jira/browse/SOLR-10141) (thanks Yonik!) As an optimization, an update is allowed to bypass the hash map and synchronize on the read entry directly. In this block it checks liveliness, performs the mutation, and notifies the writer. This avoids more expensive computations through the map. Previously, an eviction was performed in a computation to remove the entry and notify the writer, or resurrect. Inside the computation the entry was not synchronized on and that was done only after it was removed from the table. The removal listener was notified with the value initially read at the start of this method. This allowed an update to modify the value while (or after) the entry was being removed from the hash table. This led to notifying the writer and removal listener with the stale value. Because the writer must be called exclusively with the mutation, this computation must use a synchronized guard. Otherwise we might have preferred to re-read the value when notifying the listener. This adds a slight penalty on eviction (usually async) while allowing `put` to still be fast (but may block a little more often). `putSlow` was removed as it is no longer needed. It was a computation- based write that was safe from this issue. But it was only used when the new weight was zero, as that update race would cause an incorrect eviction. Now that the primary path is safe from this race, it is unnecessary.
- Loading branch information
Showing
9 changed files
with
195 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.