Просмотр исходного кода

fix(storage): don't recreate legacy env/ on a v2.3 instance (restart-fatal)

runV1MigrationIfNeeded() unconditionally created <dataDir>/env and opened an
LMDB there to check the v1->v2 marker — even on instances already migrated to
the v2.3 multi-project layout (projects/default/env). The first v2.3 boot
renames env/ into projects/default/env and runs fine until the next restart,
when this recreates a spurious env/ and migrateLegacyEnvToDefaultProject()
refuses to start ('both legacy and new exist'). Every restart of a migrated
instance was therefore fatal.

Fix: if projects/default/env exists, skip the v1 check without creating env/.
Bumps VERSION 2.3.1 -> 2.3.2.
fszontagh 1 месяц назад
Родитель
Сommit
e617efa774
3 измененных файлов с 20 добавлено и 1 удалено
  1. 3 0
      .gitignore
  2. 1 1
      VERSION
  3. 16 0
      service/src/main.cpp

+ 3 - 0
.gitignore

@@ -25,3 +25,6 @@ Thumbs.db
 # Core dumps
 # Core dumps
 core
 core
 core.*
 core.*
+
+.claude/worktrees/
+.playwright-mcp/

+ 1 - 1
VERSION

@@ -1 +1 @@
-2.3.1
+2.3.2

+ 16 - 0
service/src/main.cpp

@@ -189,6 +189,22 @@ int runV1MigrationIfNeeded(const std::filesystem::path& dataDir,
                             bool forceMigrate, bool noAutoMigrate) {
                             bool forceMigrate, bool noAutoMigrate) {
     using namespace smartbotic::db::storage;
     using namespace smartbotic::db::storage;
 
 
+    // Already on the v2.3 multi-project layout? Then this instance is well past
+    // any v1.x → v2.0 migration. Skip the check entirely — crucially without
+    // create_directories(<dataDir>/env), which would re-create the legacy env
+    // dir on every boot and trip the v2.3 ambiguous-layout guard in
+    // migrateLegacyEnvToDefaultProject() (it refuses to start when both
+    // <dataDir>/env and <dataDir>/projects/default/env exist). That made any
+    // restart of a migrated instance fatal.
+    {
+        std::error_code ec23;
+        if (std::filesystem::exists(dataDir / "projects" / "default" / "env", ec23)) {
+            spdlog::info("v2.0 migration: v2.3 layout present (projects/default/env) — "
+                         "skipping v1 check (not creating legacy env/)");
+            return 0;
+        }
+    }
+
     // v2.0 env lives at <dataDir>/env/ — separate from v1.x's snapshots/
     // v2.0 env lives at <dataDir>/env/ — separate from v1.x's snapshots/
     // and wal/. Open via the Stage 1 RAII wrapper.
     // and wal/. Open via the Stage 1 RAII wrapper.
     LmdbEnvOpts envOpts;
     LmdbEnvOpts envOpts;