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

推荐订阅源

H
Help Net Security
腾讯CDC
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
V
V2EX
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
量子位
F
Fortinet All Blogs
G
Google Developers Blog
T
The Blog of Author Tim Ferriss
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
Tailwind CSS Blog
J
Java Code Geeks
S
SegmentFault 最新的问题
D
Docker
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
M
MIT News - Artificial intelligence
博客园 - 【当耐特】

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(state): avoid sqlite wal on nfs state volumes · openc...
849261680 · 2026-06-14 · via Recent Commits to openclaw:main
11

// Covers SQLite WAL maintenance configuration.

2+

import childProcess from "node:child_process";

3+

import fs from "node:fs";

4+

import os from "node:os";

5+

import path from "node:path";

26

import type { DatabaseSync } from "node:sqlite";

37

import { afterEach, describe, expect, it, vi } from "vitest";

48

import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js";

@@ -10,11 +14,27 @@ import {

1014

function createMockDb(): DatabaseSync {

1115

return {

1216

exec: vi.fn(),

17+

prepare: vi.fn(() => ({

18+

get: vi.fn(() => ({ journal_mode: "delete" })),

19+

})),

1320

} as unknown as DatabaseSync;

1421

}

152223+

function statfsFixture(type: number): ReturnType<typeof fs.statfsSync> {

24+

return {

25+

type,

26+

bsize: 1024,

27+

blocks: 1,

28+

bfree: 1,

29+

bavail: 1,

30+

files: 0,

31+

ffree: 0,

32+

};

33+

}

34+1635

describe("sqlite WAL maintenance", () => {

1736

afterEach(() => {

37+

vi.restoreAllMocks();

1838

vi.useRealTimers();

1939

});

2040

@@ -30,6 +50,115 @@ describe("sqlite WAL maintenance", () => {

3050

);

3151

});

325253+

it("uses rollback journaling for databases on NFS-backed volumes", () => {

54+

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-sqlite-nfs-"));

55+

try {

56+

const db = createMockDb();

57+

const statfs = vi.spyOn(fs, "statfsSync").mockReturnValue(statfsFixture(0x6969));

58+59+

const maintenance = configureSqliteWalMaintenance(db, {

60+

checkpointIntervalMs: 0,

61+

databasePath: path.join(tempDir, "missing", "openclaw.sqlite"),

62+

});

63+64+

expect(statfs).toHaveBeenCalledWith(tempDir);

65+

expect(db["prepare"]).toHaveBeenCalledWith("PRAGMA journal_mode = DELETE;");

66+

expect(db["exec"]).not.toHaveBeenCalled();

67+

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

68+

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

69+

expect(db["exec"]).not.toHaveBeenCalled();

70+

} finally {

71+

fs.rmSync(tempDir, { recursive: true, force: true });

72+

}

73+

});

74+75+

it("refuses NFS-backed databases when SQLite keeps WAL active", () => {

76+

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-sqlite-nfs-"));

77+

try {

78+

const db = createMockDb();

79+

vi.mocked(db["prepare"]).mockReturnValue({

80+

get: vi.fn(() => ({ journal_mode: "wal" })),

81+

} as unknown as ReturnType<DatabaseSync["prepare"]>);

82+

vi.spyOn(fs, "statfsSync").mockReturnValue(statfsFixture(0x6969));

83+84+

expect(() =>

85+

configureSqliteWalMaintenance(db, {

86+

checkpointIntervalMs: 0,

87+

databaseLabel: "test-db",

88+

databasePath: path.join(tempDir, "openclaw.sqlite"),

89+

}),

90+

).toThrow(/test-db .*journal_mode=wal/);

91+

} finally {

92+

fs.rmSync(tempDir, { recursive: true, force: true });

93+

}

94+

});

95+96+

it("uses mountinfo filesystem names when statfs magic is not enough", () => {

97+

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-sqlite-nfs-"));

98+

try {

99+

const db = createMockDb();

100+

vi.spyOn(fs, "statfsSync").mockReturnValue(statfsFixture(0));

101+

vi.spyOn(fs, "readFileSync").mockReturnValue(

102+

`42 12 0:41 / ${tempDir} rw,relatime - nfs4 server:/share rw\n`,

103+

);

104+105+

configureSqliteWalMaintenance(db, {

106+

checkpointIntervalMs: 0,

107+

databasePath: path.join(tempDir, "openclaw.sqlite"),

108+

});

109+110+

expect(db["prepare"]).toHaveBeenCalledWith("PRAGMA journal_mode = DELETE;");

111+

} finally {

112+

fs.rmSync(tempDir, { recursive: true, force: true });

113+

}

114+

});

115+116+

it("uses mount command filesystem names on platforms without proc mountinfo", () => {

117+

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-sqlite-nfs-"));

118+

try {

119+

const db = createMockDb();

120+

vi.spyOn(fs, "statfsSync").mockReturnValue(statfsFixture(0));

121+

vi.spyOn(fs, "readFileSync").mockImplementation(() => {

122+

throw new Error("no proc mountinfo");

123+

});

124+

vi.spyOn(childProcess, "execFileSync").mockReturnValue(

125+

Buffer.from(`server:/share on ${tempDir} (nfs, nodev, nosuid)\n`),

126+

);

127+128+

configureSqliteWalMaintenance(db, {

129+

checkpointIntervalMs: 0,

130+

databasePath: path.join(tempDir, "openclaw.sqlite"),

131+

});

132+133+

expect(db["prepare"]).toHaveBeenCalledWith("PRAGMA journal_mode = DELETE;");

134+

} finally {

135+

fs.rmSync(tempDir, { recursive: true, force: true });

136+

}

137+

});

138+139+

it("parses Linux mount command filesystem names when proc mountinfo is unavailable", () => {

140+

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-sqlite-nfs-"));

141+

try {

142+

const db = createMockDb();

143+

vi.spyOn(fs, "statfsSync").mockReturnValue(statfsFixture(0));

144+

vi.spyOn(fs, "readFileSync").mockImplementation(() => {

145+

throw new Error("no proc mountinfo");

146+

});

147+

vi.spyOn(childProcess, "execFileSync").mockReturnValue(

148+

Buffer.from(`server:/share on ${tempDir} type nfs4 (rw,relatime)\n`),

149+

);

150+151+

configureSqliteWalMaintenance(db, {

152+

checkpointIntervalMs: 0,

153+

databasePath: path.join(tempDir, "openclaw.sqlite"),

154+

});

155+156+

expect(db["prepare"]).toHaveBeenCalledWith("PRAGMA journal_mode = DELETE;");

157+

} finally {

158+

fs.rmSync(tempDir, { recursive: true, force: true });

159+

}

160+

});

161+33162

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

34163

vi.useFakeTimers();

35164

const db = createMockDb();