Skip to content

Stale entries in cache after upgrade to 0.12.13 #575

Description

@blind-oracle

After an upgrade to 0.12.13 from 0.12.12 we started seeing stale entries returned from the cache, that should already be evicted.

We're using sync Cache and a custom Expiry implementation with only expire_after_create overridden:

/// Extracts TTL from the Entry
struct Expirer;

impl Expiry<Key, Arc<Entry>> for Expirer {
    fn expire_after_create(
        &self,
        _key: &Key,
        value: &Arc<Entry>,
        created_at: Instant,
    ) -> Option<Duration> {
        Some(value.expires - created_at)
    }
}

value.expires is filled as current Instant plus some TTL when an entry is inserted into a cache:

        self.cache.insert(
            key,
            Arc::new(Entry {
                ...
                expires: now + ttl,
            }),
        );

From the docs on the Expiry trait I see that this method is only called when the key wasn't found in the cache, as it should be I guess.

It all worked fine, but after a crate upgrade I'm getting Entry-ies from the cache where expires is earlier than current time. When I pin the crate to 0.12.12 the problem goes away.

I couldn't find the exact commit which introduced it and I don't have a concise repro yet, will add it if I can manage.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions