Skip to content

Fix hold_lock() method name mismatch in CacheDBInterface #2304

@Vasilije1990

Description

@Vasilije1990

Problem / Background

The CacheDBInterface class in cognee/infrastructure/databases/cache/cache_db_interface.py has a hold_lock() context manager that calls self.acquire() and self.release() (lines 42, 46), but the abstract methods are defined as acquire_lock() and release_lock() (lines 22, 30). This means hold_lock() will raise AttributeError at runtime for any implementation that correctly follows the interface.

Goal

Fix the method name mismatch so the context manager correctly calls the defined abstract methods.

Proposed Solution

In hold_lock(), change:

self.acquire()    →  self.acquire_lock()
self.release()    →  self.release_lock()

Or alternatively, rename the abstract methods to match — but the _lock suffix is more descriptive and should be kept.

Acceptance Criteria

  • hold_lock() calls self.acquire_lock() and self.release_lock() correctly
  • Verify that RedisAdapter and FSCacheAdapter implementations are consistent
  • Add a basic unit test for the context manager protocol
  • ruff check . passes

Dependencies / Blockers

None.

Relevant Links / Resources

  • File: cognee/infrastructure/databases/cache/cache_db_interface.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions