Repository navigation
fix(memory): avoid gateway crash loops on legacy index conflicts - #108652
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a70b051dc0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (err instanceof LegacyMemoryRowsConflictError && err.tableName === "files") { | ||
| // Memory index rows are derived from canonical memory sources. Keep the | ||
| // current per-agent index and let normal sync rebuild any stale entries. | ||
| if (err instanceof LegacyMemoryDerivedRowsConflictError) { |
There was a problem hiding this comment.
Rebuild stale FTS rows before archiving
When the legacy sidecar conflicts only in fts (for example, the canonical chunk row matches but memory_index_chunks_fts.text is stale), this broad catch makes the sidecar archive-ready. The savepoint rollback discards the legacy FTS copy, ensureMemoryIndexSchema only backfills FTS when the table is empty, and searchKeyword reads from memory_index_chunks_fts, so keyword recall can stay wrong until a full/manual reindex instead of being repaired by doctor.
Useful? React with 👍 / 👎.
| @@ -41,6 +41,7 @@ Docs: https://docs.openclaw.ai | |||
|
|
|||
| ### Fixes | |||
|
|
|||
| - **Memory Core legacy index recovery:** keep canonical per-agent search-index rows when stale legacy metadata, chunk, cache, vector, or FTS rows collide, archive the derived sidecar, and preserve retry warnings for structural vector errors so upgrades no longer leave Doctor and Gateway readiness in a permanent retry loop. Fixes #107220. Thanks @liewjiajun. | |||
There was a problem hiding this comment.
Remove normal-fix changelog entry
Root AGENTS.md says CHANGELOG.md is release-only and “Do not edit for normal PRs, direct main fixes, or ship it; release generation owns it.” This is a normal Memory Core fix, so adding an Unreleased entry here creates release-note churn that the generator has to undo; please keep this context in the PR/body metadata instead.
Useful? React with 👍 / 👎.
84aefe3 to
5017beb
Compare
5017beb to
914f525
Compare
|
Merged via squash.
|
Backport #108652 for the 2026.7.1 correction release.
Backport openclaw#108652 for the 2026.7.1 correction release.
Backport openclaw#108652 for the 2026.7.1 correction release.
Closes #107220
What Problem This Solves
Fixes an issue where upgrades from the legacy Memory Core sidecar could leave Doctor and Gateway readiness in a permanent retry loop when stale metadata, chunk, cache, vector, or FTS rows collided with the current per-agent index.
Why This Change Was Made
Memory index tables are derived search state, so a same-identity mismatch now keeps the canonical per-agent row, rolls back the attempted sidecar merge, and archives the stale sidecar. Structural failures remain separate: orphan vector rows, incompatible vector dimensions, invalid schemas, and database setup failures still retain the sidecar and report a retryable warning.
This preserves the useful non-conflicting merge path while making the canonical-wins rule consistent across every derived index table.
User Impact
Affected operators can run Doctor or restart the Gateway normally without manually moving
memory/main.sqlite. Canonical memory index rows remain intact, and repeated Doctor runs are idempotent.Evidence
openclaw doctor --fix --yes --non-interactive, canonical SQLite before/after assertion, second Doctor run, Gateway start, and/readyzresponse{"ready":true,"failing":[]}. RunAI-assisted: yes. I reviewed the ownership boundary, current and shipped behavior, related fixes, SQLite conflict/transaction contracts, tests, and the live operator path.