Skip to content

Add ThreadSafeEntityCache::snapshot() for consistent multi-query reads #273

@bburda

Description

@bburda

Multiple independent cache reads in CapabilityGenerator can mix data from different generations. Add a snapshot() method that returns an immutable copy under a single lock for use cases that need consistency across multiple queries.

Problem:
CapabilityGenerator::generate_resource_collection() and generate_specific_entity() make multiple calls to node_.get_thread_safe_cache() for different query types (get_entity_data, get_app_operations, etc.). Between these calls, the cache could be updated by the discovery manager, resulting in a spec that mixes data from different entity cache generations.

Proposed fix:
Add a ThreadSafeEntityCache::snapshot() method that returns a lightweight immutable copy of the cache data under a single read lock. The CapabilityGenerator would use this snapshot for all queries within a single spec generation, ensuring consistency.

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