Memory Index Repeatedly Broken After Gateway Restart (OOM during Rebuild)
Bug Description
Memory search becomes unavailable after every gateway restart. The root cause is an OOM (Out of Memory) issue during index rebuild.
Reproduction Steps
- Gateway restarts (manual or automatic)
- Memory plugin detects database state anomaly
- Clears
main.sqlite and starts full index rebuild
- Rebuilding embeddings for 415 files requires ~500MB memory
- Process is killed by OOM killer (SIGKILL)
.tmp-xxx file never merges back to main database
main.sqlite remains empty
memory_search returns "index metadata is missing" or "timed out"
Evidence
# After gateway restart, main.sqlite is empty
sqlite3 ~/.openclaw/memory/main.sqlite "SELECT COUNT(*) FROM meta, chunks, files;"
# Output: 0|0|0
# Multiple .tmp files are created but never merged
ls -la ~/.openclaw/memory/main.sqlite.tmp-*
# Shows files growing but never completing
# Process is killed by OOM
ps aux | grep openclaw-memory
# Shows high memory usage (~300MB per process)
Expected Behavior
- Index rebuild should handle OOM gracefully (e.g., batch processing, checkpoint/resume)
- If rebuild fails, restore from backup instead of leaving empty database
- Gateway restart should not trigger full rebuild if database is healthy
Environment
- OpenClaw version: 2026.6.5 (5181e4f)
- OS: macOS 26.5.1 (arm64)
- Node: v26.0.0
- Memory: 8GB
- Embedding model: bge-m3 (Ollama)
- Indexed files: 415
Suggested Fixes
- Batch processing: Rebuild index in smaller batches to reduce memory usage
- Checkpoint/resume: Save progress during rebuild, resume if interrupted
- Backup restore: If rebuild fails, restore from last known good backup
- Skip rebuild: Don't trigger full rebuild if database exists and is readable
- Memory limit: Add
--max-memory option to openclaw memory index
Workaround
Currently, manual intervention is required:
openclaw gateway stop
openclaw memory index --force
openclaw gateway start
Memory Index Repeatedly Broken After Gateway Restart (OOM during Rebuild)
Bug Description
Memory search becomes unavailable after every gateway restart. The root cause is an OOM (Out of Memory) issue during index rebuild.
Reproduction Steps
main.sqliteand starts full index rebuild.tmp-xxxfile never merges back to main databasemain.sqliteremains emptymemory_searchreturns "index metadata is missing" or "timed out"Evidence
Expected Behavior
Environment
Suggested Fixes
--max-memoryoption toopenclaw memory indexWorkaround
Currently, manual intervention is required: