LearnNewsExamplesServices
Frontmatter
id9937
titleOptimize Vector Apoptosis Cartesian Deadlock & Suppress Chroma SDK Warnings
stateClosed
labels
bugaiarchitectureperformance
assigneestobiu
createdAtApr 12, 2026, 8:46 PM
updatedAtApr 12, 2026, 8:49 PM
githubUrlhttps://github.com/neomjs/neo/issues/9937
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtApr 12, 2026, 8:49 PM

Optimize Vector Apoptosis Cartesian Deadlock & Suppress Chroma SDK Warnings

Closedbugaiarchitectureperformance
tobiu
tobiu commented on Apr 12, 2026, 8:46 PM

The Problem

Sandman (DreamService) encountered a critical freeze event during the Vector Apoptosis routine (GraphService.getOrphanedNodes()). The Node.js event pool locked up, completely hanging the backend permanently without any console output or crashing.

Root Cause 1: SQLite Unindexed Left Join Deadlock The initial SQL implementation relied on a dual-condition LEFT JOIN:

SELECT n.id, n.data 
FROM Nodes n 
LEFT JOIN Edges e ON n.id = e.source OR n.id = e.target 
WHERE e.id IS NULL

SQLite foreign key constraints do not implicitly create child column indices. Compounded by an OR condition in the JOIN ON clause (which negates SQLite's query plan optimization), this query executed an unindexed Cartesian product $O(N \times M)$ scan. At the current Native Edge Graph scale, this generated ~25,000,000 string comparisons synchronously on the better-sqlite3 V8 thread, entirely deadlocking the MCP engine.

Root Cause 2: Chroma SDK Deserialization Noise The mcp-server-memory-core stderr output was severely polluted with dynamic_text_embedding_service package resolution warnings resulting from Python ChromaDB schema deserialization mismatches.

The Solution

  1. Topological N-Query Optimization (SQLite.mjs / GraphService.mjs):
    • Rewrote the Vector Apoptosis extraction logic utilizing twin uncorrelated NOT EXISTS subqueries to explicitly decouple the execution block and circumvent the Cartesian sweep.
    • Surgically injected CREATE INDEX IF NOT EXISTS natively into the WAL Initialization sequence (SQLite.mjs) targeting Edges(source) and Edges(target).
  2. MCP Terminal Suppression (ChromaManager.mjs):
    • Corrected the console.warn suppression filter string interpolation to strictly mirror Chromium backend logging specifications (using underscoring: dummy_embedding_function).

Origin Session

Origin Session ID: af26000d-914a-4eb0-8d28-2c09e9cb4cb5

tobiu added the bug label on Apr 12, 2026, 8:46 PM
tobiu added the ai label on Apr 12, 2026, 8:46 PM
tobiu added the architecture label on Apr 12, 2026, 8:46 PM
tobiu added the performance label on Apr 12, 2026, 8:46 PM
tobiu referenced in commit 612acaf - "fix(memory-core): Optimize Vector Apoptosis Cartesian deadlock and suppress SDK warnings (#9937)" on Apr 12, 2026, 8:46 PM
tobiu cross-referenced by PR #9938 on Apr 12, 2026, 8:46 PM
tobiu assigned to @tobiu on Apr 12, 2026, 8:46 PM
tobiu closed this issue on Apr 12, 2026, 8:49 PM
tobiu referenced in commit 7cff42e - "fix(memory-core): Optimize Vector Apoptosis Cartesian deadlock and suppress SDK warnings (#9937) (#9938)" on Apr 12, 2026, 8:49 PM