Repository navigation
Description
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
- Start with a legacy Memory Core sidecar containing
meta,files,chunks, andembedding_cache, plus an existing per-agent SQLite database. - Ensure at least one legacy
embedding_cacherow has the same(provider, model, provider_key, hash)primary key as a canonicalmemory_embedding_cacherow, but a differentembeddingorupdated_atvalue. - Upgrade to OpenClaw 2026.7.1 and run
openclaw gateway runor restart the installed Gateway service. - The migration executes
INSERT OR IGNOREfor the cache rows, then checks that every legacy row exactly matches the canonical row acrossembedding,dims, andupdated_at. - 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.jscopyLegacyMemoryIndexRows()usesINSERT OR IGNOREformemory_embedding_cache.- It then calls
assertLegacyRowsCopied()with equality checks for all cache fields. migrateLegacyMemorySidecarSource()only treatsLegacyMemoryRowsConflictErroras canonical-wins whentableName === "files";embedding_cachegoes 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:
- Seed canonical
memory_embedding_cachewith key K and value A. - Seed legacy
embedding_cachewith the same key K and value B / a differentupdated_at. - Include legacy
filesandchunksnot yet in canonical storage. - Run the sidecar migration.
- Assert the selected cache conflict policy, successful import of non-conflicting index rows, sidecar convergence, and successful Gateway startup checkpoint.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
seawindcn commentedon Jul 14, 2026
+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
2026.7.1 (2d2ddc4)(same as OP)sudo npm install -g openclaw@2026.7.12026.6.10 (aa69b12)for an extended periodSteps to reproduce (overlap with OP, with one difference)
sudo npm install -g openclaw@2026.7.1(direct cross-version upgrade from 6.10)systemctl --user restart openclaw-gateway.servicejournalctl --user -u openclaw-gateway --since "1 min ago"shows: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:
(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:
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, commit4da0eb19, merged 2026-07-14 03:05Z by Peter Steinberger, closes #103076) is already merged into main.However, OP's specific
embedding_cacheconflict 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 missingembedding_cachebranch incopyLegacyMemoryIndexRows(). Same family of bug, but probably not the same fix.Suggested fix for maintainer (extends OP's hint)
embedding_cacheto the canonical-wins branch (mirroringfiles):Add a second regression case to supplement OP's:
embedding_cacherows (theoretically should not fail, but in practice it does — false positive). This pins down the equality check itself, not just the conflict resolution.embeddingvalue → should canonical-win.Surface
embedding_cacherow counts in release notes / migration warnings: current note saysMemory 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:
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:
Note: the legacy
filesrows 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.
Moranilt commentedon Jul 14, 2026
Is not worked for me.
I've had
/home/{username}/.openclaw/agents/mainand there are 2 files sqlite. I've deleted it and then started gateway service again. It works for me.NeoGeoSNK commentedon Jul 14, 2026
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 │
smelike commentedon Jul 14, 2026
I got the same situation, openclaw update 7.1, then openclaw can not up run.
clawsweeper commentedon Jul 14, 2026
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:
canonicalCanonical: #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:
fixed_by_candidate: fix(memory-core): preserve canonical cache rows during legacy migration #107243 - This open, mergeable PR explicitly closes the issue and supplies before/after Gateway and migration proof for the embedding-cache conflict.partial_overlap: 2026.7.1 gateway crash-loop: legacy memory sidecarmeta/chunksconflicts are fatal whilefilesconflicts auto-resolve #107220 - The sibling includes embedding-cache conflicts but also tracks distinct meta and chunk conflict policies that are not resolved by this issue's narrow fix.superseded: fix(memory-core): preserve canonical embedding cache on migration #107276 - This closed-unmerged alternative addressed the same narrow cache conflict; the still-open linked PR is the viable candidate path.adjacent_distinct: [Bug]: additional legacy-state migration sources still block gateway startup after #102780 (Matrix, Memory Core, update-check state, Codex sidecar ownership) #103076 - That resolved report covered non-converging already-imported migration residue, while this issue concerns a transactional same-key cache collision.adjacent_distinct: fix(state): converge legacy startup migrations #107002 - The merged convergence repair handled safely superseded residue but intentionally retained fail-closed treatment for real divergent import conflicts.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:
Codex review notes: model internal, reasoning high; reviewed against ca83f1ca51be.
Label changes
Label changes:
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.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:linked-pr-open: Current issue advisory state selects this label.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:
extensions/memory-core/doctor-contract-api.ts:512, 2d2ddc43d0dc)extensions/memory-core/doctor-contract-api.ts:512, ca83f1ca51be)extensions/memory-core/doctor-contract-api.test.ts:1, 89a5bda234a3)extensions/memory-core/doctor-contract-api.ts:512, d851aa3)extensions/memory-core/doctor-contract-api.ts:1, 414c250af90d)extensions/memory-core/doctor-contract-api.ts:1, 4da0eb19c570)Likely related people:
extensions/memory-core/doctor-contract-api.ts,extensions/memory-core/doctor-contract-api.test.ts)extensions/memory-core/doctor-contract-api.ts,extensions/memory-core/doctor-contract-api.test.ts)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 re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.steipete commentedon Jul 14, 2026
Fixed on
mainby #107243 inc1191cdf2fbbea4cc9797d7f110a4e0acf50d3c7.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/readyztwice.The broader metadata/chunk conflict report in #107220 remains separate.
chore: bump OpenClaw to 2026.7.2-beta.2 and lower heap cap to 3GB