Skip to content

Cache Set/Get __del__ only clears the last video namespace #2846

Description

@davidnichols-ops

Repro (current main)

cache_set/v1.py and cache_get/v1.py store a process-global map in WorkflowMemoryCache keyed by video_metadata.video_identifier. Cleanup is __del__ and only remembers self.namespace, which run() overwrites every call:

# cache_set/v1.py on main
def __del__(self):
    if self.namespace:
        WorkflowMemoryCache.clear_namespace(self.namespace)

# run():
self.namespace = namespace  # last video wins

Sequence: set on vidA, then vidB, then the block is destroyed → vidA stays in WorkflowMemoryCache.cache for the process lifetime.

Confirmed by reading origin/main (self.namespace = namespace + __del__ clears only that one).

Why it matters

Class-level dict, no bound. A long-running workflow that sees many video ids leaks one namespace per extra video. Not a crash on the first video; unbounded growth after that.

Fix

#2834 — retain every namespace the instance touched; release all on close/__del__; refcount so two instances sharing a video id do not smash each other.

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