Skip to content

[Bug]: Memory Core embedding_cache conflict permanently blocks Gateway startup on 2026.7.1 #107133

Closed

Description

@Tony-ooo

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

On OpenClaw 2026.7.1, the Memory Core legacy sidecar migration rolls back and permanently blocks Gateway startup when legacy embedding_cache rows have primary keys already present in canonical memory_embedding_cache but non-key fields differ.

Steps to reproduce

  1. Start with a legacy Memory Core sidecar containing meta, files, chunks, and embedding_cache, plus an existing per-agent SQLite database.
  2. Ensure at least one legacy embedding_cache row has the same (provider, model, provider_key, hash) primary key as a canonical memory_embedding_cache row, but a different embedding or updated_at value.
  3. Upgrade to OpenClaw 2026.7.1 and run openclaw gateway run or restart the installed Gateway service.
  4. The migration executes INSERT OR IGNORE for the cache rows, then checks that every legacy row exactly matches the canonical row across embedding, dims, and updated_at.
  5. The ignored conflicting row fails that equality check, LegacyMemoryRowsConflictError("embedding_cache") is thrown, the migration savepoint is rolled back, and Gateway startup is rejected.

Observed locally with redacted, read-only SQLite statistics:

canonical memory_embedding_cache rows: 218
legacy embedding_cache rows: 42
legacy rows whose primary key already exists canonically: 42
legacy rows with a new primary key: 0
exact full-row matches: 0
embedding mismatches: 34
updated_at mismatches: 42

No memory text, embeddings, hashes, provider keys, credentials, or user paths are included in this report.

Expected behavior

The migration should converge without blocking Gateway startup when canonical cache rows already exist for the same cache keys. Cache conflicts should have an explicit policy, such as keeping canonical rows (matching the existing canonical-wins handling for files conflicts), or deterministically selecting a row by documented freshness rules. A focused regression test should cover same-key/different-value embedding_cache rows.

Actual behavior

Gateway exits during startup migration with:

OpenClaw startup migrations did not complete cleanly; refusing to report the gateway ready.
- Skipped Memory Core legacy memory index import for agent main because legacy rows could not be imported: Error: legacy memory embedding_cache rows conflict with canonical memory index rows

The Windows Scheduled Task returns to Ready, port 127.0.0.1:18789 remains free, and openclaw gateway status --json reports runtime.status = stopped, rpc.ok = false, and ECONNREFUSED.

openclaw gateway restart cannot recover because every Gateway start retries the same migration and exits again.

OpenClaw version

2026.7.1 (2d2ddc4)

Operating system

Windows 11, Node.js 24.17.0

Install method

npm global

Model

n/a (failure occurs before Gateway readiness)

Provider / routing chain

n/a (failure occurs before model/provider routing)

Additional provider/model setup details

Not applicable.

Logs

[state-migrations] Legacy state migration warnings:
- Skipped Memory Core legacy memory index import for agent main because legacy rows could not be imported: Error: legacy memory embedding_cache rows conflict with canonical memory index rows

[openclaw] Reason: OpenClaw startup migrations did not complete cleanly; refusing to report the gateway ready.

Screenshots, recordings, and evidence

Source path in the 2026.7.1 npm distribution:

  • dist/extensions/memory-core/doctor-contract-api.js
  • copyLegacyMemoryIndexRows() uses INSERT OR IGNORE for memory_embedding_cache.
  • It then calls assertLegacyRowsCopied() with equality checks for all cache fields.
  • migrateLegacyMemorySidecarSource() only treats LegacyMemoryRowsConflictError as canonical-wins when tableName === "files"; embedding_cache goes to the blocking warning path.
  • runDoctorConfigPreflight() treats the resulting startup migration warning as fatal and refuses Gateway readiness.

This is narrower than #103076 / #103545 and the repair in #107002. Those addressed already-migrated residue and warning/notice convergence. This report is an import-transaction conflict caused by same-primary-key cache rows with differing non-key values.

Impact and severity

Affected: upgraded installations that retain a legacy Memory Core sidecar while the per-agent canonical cache already contains the same cache keys with newer or otherwise different values.

Severity: High. Gateway startup is completely blocked; local UI and channels cannot connect.

Frequency: 100% across repeated startup and restart attempts on the observed state directory.

Consequence: The documented restart path cannot recover. Manual state intervention would be required unless the migration conflict policy is fixed.

Additional information

The implementation already has a canonical-wins branch for files conflicts:

if (err instanceof LegacyMemoryRowsConflictError && err.tableName === "files") {
  // keep canonical per-agent SQLite rows
  return { archiveReady: true };
}

There is no equivalent branch for embedding_cache. Because all observed legacy cache keys already existed canonically and none introduced a new key, retaining canonical cache rows would have preserved the current authoritative cache while allowing the legacy files and chunks rows to migrate.

Suggested regression case:

  1. Seed canonical memory_embedding_cache with key K and value A.
  2. Seed legacy embedding_cache with the same key K and value B / a different updated_at.
  3. Include legacy files and chunks not yet in canonical storage.
  4. Run the sidecar migration.
  5. Assert the selected cache conflict policy, successful import of non-conflicting index rows, sidecar convergence, and successful Gateway startup checkpoint.

Activity

  1. seawindcn commented on Jul 14, 2026

    @seawindcn

    +1 — I reproduced this fail, exactly matching Tony-ooo's report. Adding data-rich repro + workaround details for the OP and maintainer to triage faster:

    My environment

    • OpenClaw version: 2026.7.1 (2d2ddc4) (same as OP)
    • Install method: sudo npm install -g openclaw@2026.7.1
    • OS: Linux (Ubuntu 24.04 equivalent), Node.js 24.18.0
    • Previously running 2026.6.10 (aa69b12) for an extended period
    • Skipped all 7.0/7.1 betas — went directly from 6.10 → 7.1

    Steps to reproduce (overlap with OP, with one difference)

    1. sudo npm install -g openclaw@2026.7.1 (direct cross-version upgrade from 6.10)
    2. systemctl --user restart openclaw-gateway.service
    3. First startup fails. journalctl --user -u openclaw-gateway --since "1 min ago" shows:
    [openclaw] Reason: OpenClaw startup migrations did not complete cleanly;
                refusing to report the gateway ready.
    
    [state-migrations] Legacy state migration warnings:
    - Left legacy update-check state in place because shared SQLite state already differs: update-check.json
    - Skipped Memory Core short-term recall import for /home/seawind/.openclaw/workspace because SQLite rows already exist
    - Skipped Memory Core legacy memory index import for agent main because legacy rows could not be imported:
        Error: legacy memory embedding_cache rows conflict with canonical memory index rows
    

    Additional observation beyond OP's report

    I attempted 7 restarts in a row (08:43 → 08:51 UTC). Every attempt failed with the same reason above. After 08:45, the error mutated to:

    OpenClaw startup migrations are already running for this state directory
    

    (My guess: systemd restarts fast enough that the migration lock doesn't clear between attempts, so concurrent starts hit a different gate. Either way the gateway never reaches ready.)

    Workaround I'm planning to try (not yet executed)

    Given OP's root-cause analysis, my plan once 7.1.1 isn't out yet is to roll back to 6.10, do a manual pre-migration, then attempt 7.1 again:

    # 1. Roll back to 6.10 (keep the gateway alive)
    sudo npm install -g openclaw@2026.6.10
    systemctl --user start openclaw-gateway.service
    # (gateway immediately active, send hook md5 unchanged, 153 v9.x framework patches intact)
    
    # 2. Manually pre-migrate the three conflicts:
    #    a. Reset update-check.json
    rm -f /home/seawind/.openclaw/update-check.json
    
    #    b. Find embedding_cache rows with the same PK but different values, keeping canonical
    sqlite3 /home/seawind/.openclaw/state/memory-core.db \
      "SELECT provider, model, provider_key, hash, COUNT(*)
       FROM memory_embedding_cache
       GROUP BY 1,2,3,4 HAVING COUNT(*) > 1;"
    
    #    c. Move the legacy sidecar aside so 7.1 starts from clean
    mv /home/seawind/.openclaw/agents/main/memory/legacy \
       /home/seawind/.openclaw/backup/memory-legacy-2026-07-14/
    
    # 3. Then try 7.1 again
    sudo npm install -g openclaw@2026.7.1
    systemctl --user restart openclaw-gateway.service

    Risk: This may discard part of the canonical memory rows for agent main. Webchat/feishu session transcripts remain intact so no business data is lost; only the OpenClaw-derived memory canonical index is at risk.

    On PR #107002

    I noticed PR #107002 (fix(state): converge legacy startup migrations, commit 4da0eb19, merged 2026-07-14 03:05Z by Peter Steinberger, closes #103076) is already merged into main.

    However, OP's specific embedding_cache conflict doesn't appear to be explicitly called out in #107002. #107002 covers state-directory/update-check/plugin-install/Matrix/CodeX/session-binding, and its body description does not mention the missing embedding_cache branch in copyLegacyMemoryIndexRows(). Same family of bug, but probably not the same fix.

    Suggested fix for maintainer (extends OP's hint)

    1. Add embedding_cache to the canonical-wins branch (mirroring files):
    - if (err instanceof LegacyMemoryRowsConflictError && err.tableName === "files") {
    -   // keep canonical per-agent SQLite rows
    -   return { archiveReady: true };
    - }
    + if (err instanceof LegacyMemoryRowsConflictError &&
    +     (err.tableName === "files" || err.tableName === "embedding_cache")) {
    +   // keep canonical per-agent SQLite rows
    +   return { archiveReady: true };
    + }
    1. Add a second regression case to supplement OP's:

      • Same key K and identical non-key values for two embedding_cache rows (theoretically should not fail, but in practice it does — false positive). This pins down the equality check itself, not just the conflict resolution.
      • OP's case: same key K, different embedding value → should canonical-win.
      • My addition: same key K, all values identical → should be a no-op, not a conflict.
    2. Surface embedding_cache row counts in release notes / migration warnings: current note says Memory Core legacy memory index import for agent <X> but the embedded row counts and conflict counts would speed up diagnosis considerably.

    Severity reassessment

    OP marked this High. I think it should be Critical:

    • Upgrade → gateway dead, no self-recovery path
    • Any 6.10 → 7.1 direct upgrade 100% fails (everyone crossing this major version hits the same wall)
    • Already-installed 7.1 users whose OS or systemd triggers a restart are also affected
    • There is no in-tree tool that can safely pre-migrate (similar to a Postgres data directory migration requiring a dedicated pg_upgrade)

    Self-help workaround (NOT a mainline patch, but helps users who are already stuck)

    If someone is already stuck on 7.1 and can't easily roll back:

    # 1. Stop the gateway (it's already in failed state, but stop cleanly anyway)
    systemctl --user stop openclaw-gateway.service
    
    # 2. Back up the state directory
    cp -r /home/seawind/.openclaw/state/ /home/seawind/.openclaw/backup/state-pre-7.1-bypass/
    
    # 3. Move the entire Memory Core legacy sidecar aside — without embedding_cache in the sidecar,
    #    7.1 should not get stuck
    mv /home/seawind/.openclaw/agents/main/memory/legacy \
       /home/seawind/.openclaw/backup/memory-legacy-bypass/
    
    # 4. Restart the gateway
    systemctl --user start openclaw-gateway.service
    
    # Verify: gateway comes up, memory canonical tables are intact, but legacy files/chunks/metadata
    # migration is lost and will need re-running once 7.1.1 is out.

    Note: the legacy files rows hold OCR'd error-book screenshots and textbook material. If you lose them, you'll need to re-run OCR on the originals. So this workaround is "ship 7.1 today, lose some cache, recover later" — fine for dev environments, risky for production.


    I'd rate this as worth a 7.1.1 patch release with the same urgency as the #98565 restart-flapping fix. I've already set up a cron monitor on my side that announces when 7.1.1 ships.

  2. Moranilt commented on Jul 14, 2026

    @Moranilt
    mv /home/seawind/.openclaw/agents/main/memory/legacy \
       /home/seawind/.openclaw/backup/memory-legacy-bypass/
    

    Is not worked for me.
    I've had /home/{username}/.openclaw/agents/main and there are 2 files sqlite. I've deleted it and then started gateway service again. It works for me.

  3. NeoGeoSNK commented on Jul 14, 2026

    @NeoGeoSNK

    I need remove everything!!!!!
    related to the migration process, otherwise it crash my gateway, beside the sqlite files mentioned above I need remove the dream files also :(
    Legacy state detected ────────────────────────────────────────────────────────────────────╮
    │ │
    │ - Memory Core daily ingestion: │
    │ ~/.openclaw/workspace/memory/.dreams/daily-ingestion.json -> SQLite plugin state │
    │ - Memory Core session ingestion: │
    │ ~/.openclaw/workspace/memory/.dreams/session-ingestion.json -> SQLite plugin state │
    │ - Memory Core short-term recall: │
    │ ~/.openclaw/workspace/memory/.dreams/short-term-recall.json -> SQLite plugin state │
    │ - Memory Core phase signals: │
    │ ~/.openclaw/workspace/memory/.dreams/phase-signals.json -> SQLite plugin state │

  4. smelike commented on Jul 14, 2026

    @smelike

    I got the same situation, openclaw update 7.1, then openclaw can not up run.

  5. added
    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    on Jul 14, 2026
  6. clawsweeper commented on Jul 14, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 14, 2026, 6:57 AM ET / 10:57 UTC.

    Summary
    This is a current, independently corroborated upgrade regression, and current main does not yet contain the fix; keep the issue open while the linked, proof-positive fix PR is reviewed.

    Reproducibility: yes. The issue supplies a deterministic SQLite fixture shape, exact failure path, and repeated Windows/Linux observations; I did not execute the fixture against this read-only checkout, so the structured status remains source-reproducible rather than locally reproduced.

    Root-cause cluster
    Relationship: canonical
    Canonical: #107133
    Summary: This issue is the narrow canonical report for compatible embedding-cache identity collisions; one open PR is its candidate fix, while the broader sibling also covers distinct meta and chunk conflicts.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Next step
    An open closing PR already owns the narrow implementation; review and land that candidate rather than queueing a competing fix PR.

    Review details

    Best possible solution:

    Land the linked fix with canonical-wins behavior only for dimensionally compatible cache identities, preserve and retry incompatible sidecars, verify idempotent Doctor migration plus Gateway readiness, and ship it promptly in a patch release.

    Do we have a high-confidence way to reproduce the issue?

    Yes. The issue supplies a deterministic SQLite fixture shape, exact failure path, and repeated Windows/Linux observations; I did not execute the fixture against this read-only checkout, so the structured status remains source-reproducible rather than locally reproduced.

    Is this the best way to solve the issue?

    Yes, with the linked PR's dimensional-safety guard. Preserving authoritative canonical derived cache rows for compatible identities is narrower and safer than deleting databases or globally downgrading genuine migration conflicts.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The linked fix must retain fail-closed behavior for dimensionally incompatible or malformed canonical embeddings rather than treating every cache-key collision as safe.
    • Until the fix merges and ships, affected v2026.7.1 upgrades remain stuck and users may attempt destructive manual deletion of memory databases or legacy state.

    Codex review notes: model internal, reasoning high; reviewed against ca83f1ca51be.

    Label changes

    Label changes:

    • add P0: A routine upgrade can leave the Gateway completely unusable with no in-product recovery path, and current recovery attempts require terminal and manual state intervention.
    • add impact:crash-loop: Every Gateway start retries the same failed migration and exits before readiness, leaving channels and local clients unavailable.
    • add impact:ux-release-blocker: Affected users cannot complete or recover from the upgrade through OpenClaw itself and are resorting to deleting or moving SQLite and legacy-state files manually.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:linked-pr-open: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.

    Label justifications:

    • P0: A routine upgrade can leave the Gateway completely unusable with no in-product recovery path, and current recovery attempts require terminal and manual state intervention.
    • impact:crash-loop: Every Gateway start retries the same failed migration and exits before readiness, leaving channels and local clients unavailable.
    • impact:ux-release-blocker: Affected users cannot complete or recover from the upgrade through OpenClaw itself and are resorting to deleting or moving SQLite and legacy-state files manually.
    Evidence reviewed

    What I checked:

    Likely related people:

    • mushuiyu886: Authored the commit that introduced the Memory Core legacy sidecar import, retry-safety rules, and its large regression suite. (role: introduced behavior; confidence: high; commits: 414c250af90d; files: extensions/memory-core/doctor-contract-api.ts, extensions/memory-core/doctor-contract-api.test.ts)
    • vincentkoc: Co-authored the commit establishing the current sidecar migration and conflict-validation behavior. (role: feature-history co-author; confidence: high; commits: 414c250af90d; files: extensions/memory-core/doctor-contract-api.ts, extensions/memory-core/doctor-contract-api.test.ts)
    • steipete: Authored and merged the recent cross-surface startup-migration convergence work that modified the same Memory Core doctor contract immediately before this narrower conflict was reported. (role: recent area contributor and merger; confidence: high; commits: 4da0eb19c570; files: extensions/memory-core/doctor-contract-api.ts, extensions/memory-core/doctor-contract-api.test.ts, src/infra/state-migrations.doctor.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  7. steipete commented on Jul 14, 2026

    @steipete
    Contributor

    Fixed on main by #107243 in c1191cdf2fbbea4cc9797d7f110a4e0acf50d3c7.

    The migration now preserves canonical cache collisions only when declared dimensions, JSON array shape, and actual vector lengths are compatible; malformed or incompatible collisions remain fail-closed with the sidecar retained. Exact-head proof included 35 focused migration tests, the full hosted CI gate, and a real two-start Gateway migration (run_b5f278178191) that preserved the canonical cache, imported legacy source/chunk data, archived the sidecar, and reached /readyz twice.

    The broader metadata/chunk conflict report in #107220 remains separate.

  8. locked as resolved and limited conversation to collaborators on Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions