From 7f972d3ab520261dcd2088b0c18be336942dfd16 Mon Sep 17 00:00:00 2001 From: Igor Ilic <30923996+dexters1@users.noreply.github.com> Date: Fri, 25 Jul 2025 11:25:13 +0200 Subject: [PATCH] feat: Add fix for kuzu lock after migration (#1147) ## Description Add potential fix for Kuzu database lock after migration ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --- .../databases/graph/kuzu/kuzu_migrate.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cognee/infrastructure/databases/graph/kuzu/kuzu_migrate.py b/cognee/infrastructure/databases/graph/kuzu/kuzu_migrate.py index 53eeb70d0..e958374ad 100644 --- a/cognee/infrastructure/databases/graph/kuzu/kuzu_migrate.py +++ b/cognee/infrastructure/databases/graph/kuzu/kuzu_migrate.py @@ -169,6 +169,10 @@ def kuzu_migration(new_db, old_db, new_version, old_version=None, overwrite=None # Rename new kuzu database to old kuzu database name if enabled if overwrite or delete_old: + # Remove kuzu lock from migrated DB + lock_file = new_db + ".lock" + if os.path.exists(lock_file): + os.remove(lock_file) rename_databases(old_db, old_version, new_db, delete_old) print("✅ Kuzu graph database migration finished successfully!") @@ -189,7 +193,7 @@ def rename_databases(old_db: str, old_version: str, new_db: str, delete_old: boo if os.path.isfile(old_db): # File-based database: handle main file and accompanying lock/WAL - for ext in ["", ".lock", ".wal"]: + for ext in ["", ".wal"]: src = old_db + ext dst = backup_base + ext if os.path.exists(src): @@ -211,7 +215,7 @@ def rename_databases(old_db: str, old_version: str, new_db: str, delete_old: boo sys.exit(1) # Now move new files into place - for ext in ["", ".lock", ".wal"]: + for ext in ["", ".wal"]: src_new = new_db + ext dst_new = os.path.join(base_dir, name + ext) if os.path.exists(src_new): @@ -227,7 +231,7 @@ Examples: %(prog)s --old-version 0.9.0 --new-version 0.11.0 \\ --old-db /path/to/old/db --new-db /path/to/new/db --overwrite -Note: This script will create virtual environments in .kuzu_envs/ directory +Note: This script will create temporary virtual environments in .kuzu_envs/ directory to isolate different Kuzu versions. """, formatter_class=argparse.RawDescriptionHelpFormatter,