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 the damage to the eviction policy if the order of events is incorrect. #59

Closed
maypok86 opened this issue Mar 2, 2024 · 0 comments · Fixed by #60
Closed

Fix the damage to the eviction policy if the order of events is incorrect. #59

maypok86 opened this issue Mar 2, 2024 · 0 comments · Fixed by #60
Labels
enhancement New feature or request

Comments

@maypok86
Copy link
Owner

maypok86 commented Mar 2, 2024

Clarification and motivation

Description

All implementations of caches in Go that are trying to be contention-free (ristretto, theine, otter, ccache) currently have problems with maintaining correct operation in the eventual consistency mode.

  1. The most common problem (and the simplest) is the race condition with simultaneous Set operations and removal from the eviction policy, followed by removal from the hash table. This leads to zombie entries in the eviction policy and the absence of the desired entry in the hash table. This is a problem in ristretto and ccache. In theine and otter it is solved.
  2. A much more terrible problem is the incorrect synchronization of the cost of each entry with the eviction policy. For example, theine updates the cost on the spot and then sends an update event, this can lead to a complete failure of the eviction policy when this entry is competitively transferred from one lru queue to another. This problem exists in theine and ristretto (complete loss of the event).
  3. When sending events, they may get mixed up, Delete and Add operations to the eviction policy will be applied in the wrong order and as a result, the eviction policy will be corrupted by the zombie entry. This problem exists in all the mentioned caches.

Goal

We need to get rid of this problem in otter. Most likely, the best solution is to use a finite state machine of two states, live and dead.

Acceptance criteria

  1. Fixed damage to the eviction policy in case of incorrect order of events.
@maypok86 maypok86 added the enhancement New feature or request label Mar 2, 2024
maypok86 added a commit that referenced this issue Mar 2, 2024
@maypok86 maypok86 mentioned this issue Mar 2, 2024
7 tasks
maypok86 added a commit that referenced this issue Mar 2, 2024
maypok86 added a commit that referenced this issue Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant