-
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.
Less aggressively discard refreshes due to possible conflicts
Linearization means that the refresh should be dropped if another write for that entry occurs, as we may populate the cache with stale data. The cache used a write timestamp to help detect this. However, when this could be too aggressive when a refresh runs concurrently with the async load completing. An inflight load is given an infinite timestamp so that it never expires. A whenComplete callback then updates the entry with its policy metadata, such as its expiration time. That changes the write timestamp and if a refresh runs concurrently with the callback then the refresh may see the infinite timestamp, the replace updates it, and the refresh drops the entry as a conflict. Instead, if the refresh is successfully unregistered within the entry's compute to swap the value, then it can be assumed to be valid. Any other write will discard the refresh under the entry's compute, so we retain linearizability. This requires that the load callback to update the metadata does not discard the refresh, since that is not needed for a psuedo write. The write timestamp trick for ABA detection is a layover from the previous implementation (2.x) which did not promise linearization. Note that a refresh is optimistic and races with other writes, so it may be discarded. As it relies on callbacks to write back into the cache, one cannot expect the entry to be updated after the reload completes (e.g. see #714).
- Loading branch information
Showing
17 changed files
with
157 additions
and
115 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
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
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.