惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
GbyAI
GbyAI
U
Unit 42
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
D
DataBreaches.Net
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
Martin Fowler
Martin Fowler
月光博客
月光博客
MongoDB | Blog
MongoDB | Blog
MyScale Blog
MyScale Blog
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
罗磊的独立博客
B
Blog RSS Feed
J
Java Code Geeks
The GitHub Blog
The GitHub Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(memory-core): stream embedding cache seed during rein...
steipete · 2026-04-28 · via Recent Commits to openclaw:main

@@ -308,16 +308,17 @@ export abstract class MemoryManagerSyncOps {

308308

return openMemoryDatabaseAtPath(dbPath, this.settings.store.vector.enabled);

309309

}

310310311-

private seedEmbeddingCache(sourceDb: DatabaseSync): void {

311+

private async seedEmbeddingCache(sourceDb: DatabaseSync): Promise<void> {

312312

if (!this.cache.enabled) {

313313

return;

314314

}

315+

let transactionStarted = false;

315316

try {

316317

const rows = sourceDb

317318

.prepare(

318319

`SELECT provider, model, provider_key, hash, embedding, dims, updated_at FROM ${EMBEDDING_CACHE_TABLE}`,

319320

)

320-

.all() as Array<{

321+

.iterate() as IterableIterator<{

321322

provider: string;

322323

model: string;

323324

provider_key: string;

@@ -326,19 +327,23 @@ export abstract class MemoryManagerSyncOps {

326327

dims: number | null;

327328

updated_at: number;

328329

}>;

329-

if (!rows.length) {

330-

return;

331-

}

332-

const insert = this.db.prepare(

333-

`INSERT INTO ${EMBEDDING_CACHE_TABLE} (provider, model, provider_key, hash, embedding, dims, updated_at)

334-

VALUES (?, ?, ?, ?, ?, ?, ?)

335-

ON CONFLICT(provider, model, provider_key, hash) DO UPDATE SET

336-

embedding=excluded.embedding,

337-

dims=excluded.dims,

338-

updated_at=excluded.updated_at`,

339-

);

340-

this.db.exec("BEGIN");

330+

// Keep gateway health probes responsive while rebuilding large caches.

331+

const SEED_EMBEDDING_YIELD_EVERY = 1000;

332+

let rowCount = 0;

333+

let insert: ReturnType<DatabaseSync["prepare"]> | null = null;

341334

for (const row of rows) {

335+

if (!insert) {

336+

insert = this.db.prepare(

337+

`INSERT INTO ${EMBEDDING_CACHE_TABLE} (provider, model, provider_key, hash, embedding, dims, updated_at)

338+

VALUES (?, ?, ?, ?, ?, ?, ?)

339+

ON CONFLICT(provider, model, provider_key, hash) DO UPDATE SET

340+

embedding=excluded.embedding,

341+

dims=excluded.dims,

342+

updated_at=excluded.updated_at`,

343+

);

344+

this.db.exec("BEGIN");

345+

transactionStarted = true;

346+

}

342347

insert.run(

343348

row.provider,

344349

row.model,

@@ -348,12 +353,22 @@ export abstract class MemoryManagerSyncOps {

348353

row.dims,

349354

row.updated_at,

350355

);

356+

rowCount += 1;

357+

if (rowCount % SEED_EMBEDDING_YIELD_EVERY === 0) {

358+

await new Promise<void>((resolve) => {

359+

setImmediate(resolve);

360+

});

361+

}

362+

}

363+

if (transactionStarted) {

364+

this.db.exec("COMMIT");

351365

}

352-

this.db.exec("COMMIT");

353366

} catch (err) {

354-

try {

355-

this.db.exec("ROLLBACK");

356-

} catch {}

367+

if (transactionStarted) {

368+

try {

369+

this.db.exec("ROLLBACK");

370+

} catch {}

371+

}

357372

throw err;

358373

}

359374

}

@@ -1167,7 +1182,7 @@ export abstract class MemoryManagerSyncOps {

11671182

targetPath: dbPath,

11681183

tempPath: tempDbPath,

11691184

build: async () => {

1170-

this.seedEmbeddingCache(originalDb);

1185+

await this.seedEmbeddingCache(originalDb);

11711186

const shouldSyncMemory = this.sources.has("memory");

11721187

const shouldSyncSessions = this.shouldSyncSessions(

11731188

{ reason: params.reason, force: params.force },