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

推荐订阅源

罗磊的独立博客
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
A
About on SuperTechFans
Martin Fowler
Martin Fowler
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
D
DataBreaches.Net
B
Blog
博客园 - 【当耐特】
爱范儿
爱范儿
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
WordPress大学
WordPress大学
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
I
InfoQ
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
Microsoft Azure Blog
Microsoft Azure Blog
雷峰网
雷峰网
量子位
G
Google Developers 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: use passive periodic sqlite wal checkpoints · opencl...
honor2030 · 2026-06-14 · via Recent Commits to openclaw:main

File tree

  • packages/memory-host-sdk/src/host

Original file line numberDiff line numberDiff line change

@@ -311,7 +311,9 @@ $OPENCLAW_STATE_DIR/tasks/runs.sqlite

311311
312312

The registry loads into memory at gateway start and syncs writes to SQLite for durability across restarts.

313313

The Gateway keeps the SQLite write-ahead log bounded by using SQLite's default

314-

autocheckpoint threshold plus periodic and shutdown `TRUNCATE` checkpoints.

314+

autocheckpoint threshold plus periodic `PASSIVE` checkpoints. Shutdown and

315+

explicit maintenance checkpoints still use `TRUNCATE` so normal closes can

316+

reclaim WAL space without making the background sweeper wait on active readers.

315317
316318

### Automatic maintenance

317319
Original file line numberDiff line numberDiff line change

@@ -3,6 +3,7 @@

33

export {

44

CHARS_PER_TOKEN_ESTIMATE,

55

DEFAULT_SQLITE_WAL_AUTOCHECKPOINT_PAGES,

6+

DEFAULT_SQLITE_WAL_CHECKPOINT_INTERVAL_MS,

67

DEFAULT_SQLITE_WAL_TRUNCATE_INTERVAL_MS,

78

applyWindowsSpawnProgramPolicy,

89

configureSqliteWalMaintenance,

Original file line numberDiff line numberDiff line change

@@ -80,6 +80,7 @@ export { shouldUseEnvHttpProxyForUrl } from "../../../../src/infra/net/proxy-env

8080

export { ssrfPolicyFromHttpBaseUrlAllowedHostname } from "../../../../src/infra/net/ssrf.js";

8181

export {

8282

DEFAULT_SQLITE_WAL_AUTOCHECKPOINT_PAGES,

83+

DEFAULT_SQLITE_WAL_CHECKPOINT_INTERVAL_MS,

8384

DEFAULT_SQLITE_WAL_TRUNCATE_INTERVAL_MS,

8485

configureSqliteWalMaintenance,

8586

} from "../../../../src/infra/sqlite-wal.js";

Original file line numberDiff line numberDiff line change

@@ -2,6 +2,7 @@

22
33

export {

44

DEFAULT_SQLITE_WAL_AUTOCHECKPOINT_PAGES,

5+

DEFAULT_SQLITE_WAL_CHECKPOINT_INTERVAL_MS,

56

DEFAULT_SQLITE_WAL_TRUNCATE_INTERVAL_MS,

67

configureSqliteWalMaintenance,

78

} from "./openclaw-runtime-io.js";

Original file line numberDiff line numberDiff line change

@@ -159,18 +159,19 @@ describe("sqlite WAL maintenance", () => {

159159

}

160160

});

161161
162-

it("runs periodic TRUNCATE checkpoints and stops them on close", () => {

162+

it("runs lightweight periodic PASSIVE checkpoints and TRUNCATE on close", () => {

163163

vi.useFakeTimers();

164164

const db = createMockDb();

165165
166166

const maintenance = configureSqliteWalMaintenance(db, { checkpointIntervalMs: 100 });

167167

expect(db["exec"]).toHaveBeenCalledTimes(2);

168168
169169

vi.advanceTimersByTime(100);

170-

expect(db["exec"]).toHaveBeenLastCalledWith("PRAGMA wal_checkpoint(TRUNCATE);");

170+

expect(db["exec"]).toHaveBeenLastCalledWith("PRAGMA wal_checkpoint(PASSIVE);");

171171

expect(db["exec"]).toHaveBeenCalledTimes(3);

172172
173173

expect(maintenance.close()).toBe(true);

174+

expect(db["exec"]).toHaveBeenLastCalledWith("PRAGMA wal_checkpoint(TRUNCATE);");

174175

expect(db["exec"]).toHaveBeenCalledTimes(4);

175176
176177

vi.advanceTimersByTime(200);

@@ -190,6 +191,22 @@ describe("sqlite WAL maintenance", () => {

190191

maintenance.close();

191192

});

192193
194+

it("honors explicit checkpoint mode overrides for periodic and close checkpoints", () => {

195+

vi.useFakeTimers();

196+

const db = createMockDb();

197+
198+

const maintenance = configureSqliteWalMaintenance(db, {

199+

checkpointIntervalMs: 100,

200+

checkpointMode: "FULL",

201+

});

202+
203+

vi.advanceTimersByTime(100);

204+

expect(db["exec"]).toHaveBeenLastCalledWith("PRAGMA wal_checkpoint(FULL);");

205+
206+

expect(maintenance.close()).toBe(true);

207+

expect(db["exec"]).toHaveBeenLastCalledWith("PRAGMA wal_checkpoint(FULL);");

208+

});

209+
193210

it("reports checkpoint errors without throwing from background maintenance", () => {

194211

const db = createMockDb();

195212

const error = new Error("busy");

Original file line numberDiff line numberDiff line change

@@ -8,7 +8,12 @@ import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js";

88

// WAL maintenance configures SQLite write-ahead logging and schedules bounded

99

// checkpoints so state databases do not accumulate unbounded WAL files.

1010

export const DEFAULT_SQLITE_WAL_AUTOCHECKPOINT_PAGES = 1000;

11-

export const DEFAULT_SQLITE_WAL_TRUNCATE_INTERVAL_MS = 30 * 60 * 1000;

11+

export const DEFAULT_SQLITE_WAL_CHECKPOINT_INTERVAL_MS = 30 * 60 * 1000;

12+

/**

13+

* @deprecated Use DEFAULT_SQLITE_WAL_CHECKPOINT_INTERVAL_MS.

14+

* Periodic checkpoints default to PASSIVE.

15+

*/

16+

export const DEFAULT_SQLITE_WAL_TRUNCATE_INTERVAL_MS = DEFAULT_SQLITE_WAL_CHECKPOINT_INTERVAL_MS;

1217

const LINUX_NFS_SUPER_MAGIC = 0x6969;

1318

const PROC_MOUNTINFO_PATH = "/proc/self/mountinfo";

1419

@@ -183,11 +188,12 @@ export function configureSqliteWalMaintenance(

183188

"autoCheckpointPages",

184189

);

185190

const checkpointIntervalMs = normalizeNonNegativeInteger(

186-

options.checkpointIntervalMs ?? DEFAULT_SQLITE_WAL_TRUNCATE_INTERVAL_MS,

191+

options.checkpointIntervalMs ?? DEFAULT_SQLITE_WAL_CHECKPOINT_INTERVAL_MS,

187192

"checkpointIntervalMs",

188193

);

189194

const timerIntervalMs = Math.min(checkpointIntervalMs, MAX_TIMER_TIMEOUT_MS);

190195

const checkpointMode = options.checkpointMode ?? "TRUNCATE";

196+

const periodicCheckpointMode = options.checkpointMode ?? "PASSIVE";

191197

if (options.databasePath && isNfsBackedPath(options.databasePath)) {

192198

requireRollbackJournalMode(db, options);

193199

return {

@@ -198,19 +204,24 @@ export function configureSqliteWalMaintenance(

198204

db.exec("PRAGMA journal_mode = WAL;");

199205

db.exec(`PRAGMA wal_autocheckpoint = ${autoCheckpointPages};`);

200206
201-

const checkpoint = (): boolean => {

207+

const runCheckpoint = (mode: SqliteWalCheckpointMode): boolean => {

202208

try {

203-

db.exec(`PRAGMA wal_checkpoint(${checkpointMode});`);

209+

db.exec(`PRAGMA wal_checkpoint(${mode});`);

204210

return true;

205211

} catch (error) {

206212

options.onCheckpointError?.(error);

207213

return false;

208214

}

209215

};

210216
217+

const checkpoint = (): boolean => runCheckpoint(checkpointMode);

218+
211219

let timer: IntervalHandle | null = null;

212220

if (timerIntervalMs > 0) {

213-

timer = setInterval(checkpoint, timerIntervalMs) as IntervalHandle;

221+

timer = setInterval(

222+

() => runCheckpoint(periodicCheckpointMode),

223+

timerIntervalMs,

224+

) as IntervalHandle;

214225

timer.unref?.();

215226

}

216227