mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-28 10:49:56 +02:00
Fix deadlock in SqliteStore (#5234)
This commit is contained in:
@@ -223,10 +223,9 @@ class AsyncSqliteStore(AsyncBatchedBaseStore, BaseSqliteStore):
|
||||
Yields:
|
||||
An SQLite cursor object.
|
||||
"""
|
||||
if not self.is_setup:
|
||||
await self.setup()
|
||||
async with self.lock:
|
||||
if not self.is_setup:
|
||||
await self.setup()
|
||||
|
||||
if transaction:
|
||||
await self.conn.execute("BEGIN")
|
||||
|
||||
|
||||
@@ -981,10 +981,9 @@ class SqliteStore(BaseSqliteStore, BaseStore):
|
||||
Args:
|
||||
transaction (bool): whether to use transaction for the DB operations
|
||||
"""
|
||||
if not self.is_setup:
|
||||
self.setup()
|
||||
with self.lock:
|
||||
if not self.is_setup:
|
||||
self.setup()
|
||||
|
||||
if transaction:
|
||||
self.conn.execute("BEGIN")
|
||||
|
||||
@@ -1002,10 +1001,10 @@ class SqliteStore(BaseSqliteStore, BaseStore):
|
||||
This method creates the necessary tables in the SQLite database if they don't
|
||||
already exist and runs database migrations. It should be called before first use.
|
||||
"""
|
||||
if self.is_setup:
|
||||
return
|
||||
|
||||
with self.lock:
|
||||
if self.is_setup:
|
||||
return
|
||||
# Create migrations table if it doesn't exist
|
||||
self.conn.executescript(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user