From a037ade1ca7b788d89eb76a44db66e7ae422e9e7 Mon Sep 17 00:00:00 2001 From: Greyson LaLonde Date: Tue, 10 Mar 2026 22:55:10 -0400 Subject: [PATCH] fix: add _write_lock to reset() and optimize() for batch atomicity --- lib/crewai/src/crewai/memory/storage/lancedb_storage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/crewai/src/crewai/memory/storage/lancedb_storage.py b/lib/crewai/src/crewai/memory/storage/lancedb_storage.py index 049572f18..f0d1d1cdc 100644 --- a/lib/crewai/src/crewai/memory/storage/lancedb_storage.py +++ b/lib/crewai/src/crewai/memory/storage/lancedb_storage.py @@ -612,7 +612,7 @@ class LanceDBStorage: return info.record_count def reset(self, scope_prefix: str | None = None) -> None: - with self._file_lock(): + with self._write_lock, self._file_lock(): if scope_prefix is None or scope_prefix.strip("/") == "": if self._table is not None: self._db.drop_table(self._table_name) @@ -636,7 +636,7 @@ class LanceDBStorage: """ if self._table is None: return - with self._file_lock(): + with self._write_lock, self._file_lock(): self._table.optimize() self._ensure_scope_index()