Skip to content

Potential concurrency issue in Recency::should_store #619

@cfchou

Description

@cfchou

let deleted = if let Some((last_gen, last_update)) = entries.get_mut(key) {
// If the value is the same as the latest value we have internally, and
// we're over the idle timeout period, then remove it and continue.
if *last_gen == gen {
// If the delete returns false, that means that our generation counter is
// out-of-date, and that the metric has been updated since, so we don't
// actually want to delete it yet.
(now - *last_update) > idle_timeout && delete_op(registry, key)

Would this piece of code run into race condition? Specifically, an update to the metric may happen before delete_op, but we proceed to delete it anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions