mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-22 18:35:21 -06:00
fix(sqlite): wait for startup checkpoint locks (#118022)
This commit is contained in:
@@ -2,6 +2,7 @@ import type { DatabaseSync } from "node:sqlite";
|
||||
import { openNodeSqliteDatabase } from "../infra/node-sqlite.js";
|
||||
import { assertSqliteIntegrity } from "../infra/sqlite-integrity.js";
|
||||
import { runSqliteImmediateTransactionSync } from "../infra/sqlite-transaction.js";
|
||||
import { configureSqlitePreSchemaPragmas } from "../infra/sqlite-wal.js";
|
||||
import {
|
||||
OPENCLAW_SQLITE_BUSY_TIMEOUT_MS,
|
||||
type OpenClawStateDatabaseOptions,
|
||||
@@ -64,6 +65,9 @@ export function withOpenClawStateStartupMigrationCheckpointDatabase<T>(
|
||||
ensureOpenClawStatePermissions(pathname, env);
|
||||
const db = openNodeSqliteDatabase(pathname);
|
||||
try {
|
||||
configureSqlitePreSchemaPragmas(db, {
|
||||
busyTimeoutMs: OPENCLAW_SQLITE_BUSY_TIMEOUT_MS,
|
||||
});
|
||||
assertSqliteIntegrity(db, pathname);
|
||||
ensureStartupMigrationCheckpointSchema(db, pathname);
|
||||
return callback(db);
|
||||
|
||||
@@ -2819,6 +2819,17 @@ INSERT INTO macos_port_guardian_records VALUES (4242, 18789, '/usr/bin/ssh', 're
|
||||
expect(checkpointCallback).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("configures checkpoint lock waits before schema mutation", () => {
|
||||
const stateDir = createTempStateDir();
|
||||
|
||||
withOpenClawStateStartupMigrationCheckpointDatabase(
|
||||
(db) => {
|
||||
expect(readSqliteNumberPragma(db, "busy_timeout")).toBe(OPENCLAW_SQLITE_BUSY_TIMEOUT_MS);
|
||||
},
|
||||
{ env: { OPENCLAW_STATE_DIR: stateDir } },
|
||||
);
|
||||
});
|
||||
|
||||
it("runs full integrity before a pending state schema migration", () => {
|
||||
const stateDir = createTempStateDir();
|
||||
const databasePath = createCanonicalAuditStateDatabase(stateDir);
|
||||
|
||||
Reference in New Issue
Block a user