Skip to content

fix: bound startup-script preflight with a 30s timeout (#85) - #104

Merged
aesslinger merged 1 commit into
mainfrom
fix/85-startup-script-preflight-timeout
Sep 16, 2026
Merged

aesslinger merged 1 commit into
mainfrom
fix/85-startup-script-preflight-timeout

Conversation

@aesslinger

Copy link
Copy Markdown
Collaborator

Summary

  • preflight_startup_script ran the connect + transaction + batch_execute + rollback sequence with no timeout, so a startup script that blocks (an advisory lock, a slow function, pg_sleep) or a stalled host wedged pool creation — and therefore every RPC that needs a pool — indefinitely.
  • The builtin driver wraps the same preflight in a 30-second tokio::time::timeout with a clearly attributed error message (src-tauri/src/pool_manager.rs:65 + :991). This ports that guard exactly: same STARTUP_SCRIPT_TIMEOUT_MS value (30,000ms), same error text ("Timed out running PostgreSQL startup script after 30000 ms").
  • The timeout wraps the whole preflight body (connect included), matching the builtin's scope — a stalled connection, not just a stalled script execution, is also bounded.

Fixes #85.

Test plan

  • TDD: added hung_startup_script_times_out_instead_of_hanging_pool_creation to tests/live_db.rs, using a pg_sleep(35) startup script (outlasts the 30s timeout).
  • Confirmed the test genuinely fails against the pre-fix code: ran it under an outer timeout 40, which killed the process (exit 124) — the pre-fix preflight did not return within 40 seconds.
  • Confirmed the test passes against the fix: completes in ~30.3s (bounded by the 30s timeout, not the 35s pg_sleep), with the exact expected error message.
  • cargo test --test live_db -- --test-threads=1 — 25 passed, 1 pre-existing pgvector-only test ignored (unrelated to this change)
  • cargo test --lib — 309 passed
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean

preflight_startup_script ran the connect + transaction + batch_execute +
rollback sequence with no timeout, so a startup script that blocks (an
advisory lock, a slow function, pg_sleep) or a stalled host wedged pool
creation -- and therefore every RPC that needs a pool -- indefinitely.
The builtin driver wraps the same preflight in a 30-second
tokio::time::timeout with a clearly attributed error message; this ports
that guard exactly (same STARTUP_SCRIPT_TIMEOUT_MS value, same error
text).

TDD: added hung_startup_script_times_out_instead_of_hanging_pool_creation
(a pg_sleep(35) startup script) to tests/live_db.rs. Confirmed it hangs
past 40s against the pre-fix code (killed by an outer `timeout 40`, exit
124) and passes in ~30.3s against the fix, with the exact expected
"Timed out running PostgreSQL startup script after 30000 ms" message.
Full live_db suite (25 passed, 1 pre-existing pgvector-only test ignored)
and the 309-test unit suite both pass; clippy and fmt clean.
@aesslinger aesslinger added the prerelease:rc Version suggestion targets a release candidate label Sep 16, 2026
@github-actions

Copy link
Copy Markdown

Version suggestion

Based on this PR's title (fix) and the prerelease:rc label:

Current 1.0.0-rc.3
Suggested next tag v1.0.0-rc.4

This is informational only — no tag or release is created automatically yet.

@aesslinger aesslinger self-assigned this Sep 16, 2026
@aesslinger
aesslinger merged commit 5d365f2 into main Sep 16, 2026
13 of 14 checks passed
@aesslinger
aesslinger deleted the fix/85-startup-script-preflight-timeout branch September 16, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prerelease:rc Version suggestion targets a release candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No timeout on startup-script preflight (a hung startup script wedges pool creation indefinitely)

1 participant