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: check if entry is in indexer first before remove for deposit #547

Merged
merged 3 commits into from
May 31, 2024

Conversation

MrCroxx
Copy link
Collaborator

@MrCroxx MrCroxx commented May 31, 2024

What's changed and what's your intention?

Please explain IN DETAIL what the changes are in this PR and why they are needed. :D

Previously, when a deposit entry is released after no external reference, it will remove the key from the indexer without checking if the entry is still in it. When there is another insertion with the same key between a deposit entry is inserted and released, this behavior will mistakenly delete the new version of the key from the indexer. Then the new entry is not in the indexer but maybe in the eviction container, which breaks the assumptions and cause panic.

- if handle.base().is_deposit() {
+ if handle.base().is_in_indexer() && handle.base().is_deposit() {

To reproduce:

    #[test]
    fn test_deposit_replace() {
        let cache = lru(100);
        let e1 = cache.deposit(42, "wrong answer".to_string());
        let e2 = cache.insert(42, "answer".to_string());
        drop(e1);
        drop(e2);
        assert_eq!(cache.get(&42).unwrap().value(), "answer");
        assert_eq!(cache.usage(), 6);
    }

Checklist

  • I have written the necessary rustdoc comments
  • I have added the necessary unit tests and integration tests
  • I have passed make all (or make fast instead if the old tests are not modified) in my local environment.

Related issues or PRs (optional)

fix #531
fix #525
risingwavelabs/risingwave#16869

@MrCroxx MrCroxx added the bug Something isn't working label May 31, 2024
@MrCroxx MrCroxx self-assigned this May 31, 2024
@MrCroxx MrCroxx added this to the v0.9 milestone May 31, 2024
Signed-off-by: MrCroxx <[email protected]>
@MrCroxx MrCroxx enabled auto-merge (squash) May 31, 2024 08:12
@MrCroxx MrCroxx merged commit d1c36fb into main May 31, 2024
13 checks passed
@MrCroxx MrCroxx deleted the xx/fix-deposit-release branch May 31, 2024 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

bug: panicked when evict, handle in eviction but not in indexer bug: dlist panicked
1 participant