fix(core): make embedded Postgres shared_memory_type default platform-aware

shared_memory_type=mmap (defaulted 2026-07-16 for SysV shm exhaustion)
is invalid on Windows — PostgreSQL only accepts "windows" there and
dies with FATAL invalid value for parameter before opening the port.
Every Windows embedded start broke, failing the Windows release smoke
in both the v0.70.0 and v0.70.1 tag runs. Default flags now come from
defaultEmbeddedPostgresFlagsFor(platform): empty on win32 (no override
needed; SysV exhaustion cannot occur there), mmap elsewhere. Regression
test asserts the per-platform flag invariant.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-07-17 19:09:03 -07:00
parent 6b893f78ec
commit 8517a5d3ba
3 changed files with 40 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
---
"@runfusion/fusion": patch
---
summary: Fix embedded PostgreSQL failing to start on Windows after the mmap shared-memory default.
category: fix
dev: "shared_memory_type=mmap (default added 2026-07-16 for SysV shm exhaustion) is rejected on Windows, where the only valid value is windows — every Windows embedded start died with FATAL invalid value for parameter before the port opened, failing the v0.70.0/v0.70.1 Windows release smoke. Default flags are now platform-aware via defaultEmbeddedPostgresFlagsFor: empty on win32 (Windows needs no override; SysV exhaustion cannot occur there), mmap elsewhere."

View File

@@ -34,6 +34,7 @@ import {
EmbeddedStartTimeoutError,
DEFAULT_START_TIMEOUT_MS,
DEFAULT_EMBEDDED_POSTGRES_FLAGS,
defaultEmbeddedPostgresFlagsFor,
isDataDirInitialized,
isWindowsElevatedAdmin,
normalizeMacosEmbeddedPostgresDylibSymlinks,
@@ -1124,6 +1125,24 @@ describe("embedded-lifecycle: shared-memory-safe postgres flags", () => {
__setEmbeddedPostgresCtorForTests(RecordingEmbeddedPostgres as never);
}
/*
* FNXC:PostgresEmbedded 2026-07-17-19:20:
* `shared_memory_type=mmap` is rejected by PostgreSQL on Windows (only value:
* `windows`) with a FATAL before the port opens — the mmap default broke every
* Windows embedded start and the v0.70.0/v0.70.1 Windows release smoke. The
* default flag set must stay platform-aware: no shared_memory_type override on
* win32, mmap everywhere else.
*/
it.each(["win32", "darwin", "linux"] as const)("default flags are valid for %s", (platform) => {
const flags = defaultEmbeddedPostgresFlagsFor(platform);
if (platform === "win32") {
expect(flags).toEqual([]);
} else {
expect(flags).toEqual(["-c", "shared_memory_type=mmap"]);
}
expect(flags.join(" ")).not.toMatch(platform === "win32" ? /shared_memory_type/ : /shared_memory_type=(windows|sysv)/);
});
it.each([
["omitted", undefined, [...DEFAULT_EMBEDDED_POSTGRES_FLAGS]],
["empty", [], [...DEFAULT_EMBEDDED_POSTGRES_FLAGS]],

View File

@@ -630,8 +630,21 @@ export const DEFAULT_EMBEDDED_DATABASE = "fusion";
* so the zero-config cluster has been boot-smoke tested with a 64MB /dev/shm
* lower bound. Defaults precede caller flags because PostgreSQL applies repeated
* `-c key=value` settings last-wins, preserving an operator's explicit override.
*
* FNXC:PostgresEmbedded 2026-07-17-19:20:
* `mmap` is only valid on POSIX platforms. On Windows PostgreSQL accepts a single
* value, `windows`, and rejects `mmap` with FATAL `invalid value for parameter
* "shared_memory_type"` before opening the port — this broke every Windows
* embedded start (and the v0.70.0/v0.70.1 Windows release smoke) the day the
* mmap default landed. Windows needs no override at all, so the default flag set
* is empty there; the SysV exhaustion the mmap default fixes cannot occur on
* Windows anyway.
*/
export const DEFAULT_EMBEDDED_POSTGRES_FLAGS = ["-c", "shared_memory_type=mmap"] as const;
export function defaultEmbeddedPostgresFlagsFor(platform: NodeJS.Platform): readonly string[] {
return platform === "win32" ? [] : ["-c", "shared_memory_type=mmap"];
}
export const DEFAULT_EMBEDDED_POSTGRES_FLAGS = defaultEmbeddedPostgresFlagsFor(process.platform);
/**
* FNXC:PostgresEmbedded 2026-06-24-09:05: