From 6a91912d2b23760c3f3b4848f852069e76b2f76b Mon Sep 17 00:00:00 2001 From: Jeremy Knows Date: Tue, 12 May 2026 10:18:46 -0400 Subject: [PATCH] fix(migrate v0.29.1 Phase B): force poolSize:1 for explicit BEGIN/COMMIT path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit phaseBBackfill calls backfillEffectiveDate which uses explicit BEGIN/COMMIT for PGLite portability. postgres.js rejects manual transactions with UNSAFE_TRANSACTION when the pool's max > 1, so on multi-pool postgres installs the migration wedges mid-batch after the first batch. Fix: pass poolSize:1 to engine.connect() in Phase B only. Phase C (read-only verify, no manual transactions) keeps the default pool size. The cast pattern matches src/core/brain-registry.ts:406 — poolSize is accepted by postgres-engine's connect() implementation but isn't surfaced on the generic BrainEngine.connect() interface, so the cast is the documented way to thread it. Observed on a developer postgres install (May 11, 2026): migration wedged after 3 consecutive partials. Unblocks MINIONS half-install check in gbrain doctor. --- src/commands/migrations/v0_29_1.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commands/migrations/v0_29_1.ts b/src/commands/migrations/v0_29_1.ts index ea9c1ed2b..6cd8ca5da 100644 --- a/src/commands/migrations/v0_29_1.ts +++ b/src/commands/migrations/v0_29_1.ts @@ -20,6 +20,7 @@ import { execSync } from 'child_process'; import type { BrainEngine } from '../../core/engine.ts'; +import type { EngineConfig } from '../../core/types.ts'; import type { Migration, OrchestratorOpts, OrchestratorResult, OrchestratorPhaseResult } from './types.ts'; import { childGlobalFlags } from '../../core/cli-options.ts'; @@ -52,7 +53,14 @@ async function phaseBBackfill(opts: OrchestratorOpts): Promise 1; force single-connection so the same code path + // works on both engines. Phase C (read-only verify) keeps the default. + // Cast pattern matches src/core/brain-registry.ts:406 — poolSize is + // accepted by postgres-engine's connect() but not surfaced on the + // generic BrainEngine.connect() interface. + await engine.connect({ ...engineConfig, poolSize: 1 } as EngineConfig & { poolSize: number }); let totalExamined = 0; let totalUpdated = 0;