fix: bound startup-script preflight with a 30s timeout (#85) - #104
Merged
Merged
Conversation
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.
Version suggestionBased on this PR's title (
This is informational only — no tag or release is created automatically yet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
preflight_startup_scriptran 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.tokio::time::timeoutwith a clearly attributed error message (src-tauri/src/pool_manager.rs:65+:991). This ports that guard exactly: sameSTARTUP_SCRIPT_TIMEOUT_MSvalue (30,000ms), same error text ("Timed out running PostgreSQL startup script after 30000 ms").Fixes #85.
Test plan
hung_startup_script_times_out_instead_of_hanging_pool_creationtotests/live_db.rs, using apg_sleep(35)startup script (outlasts the 30s timeout).timeout 40, which killed the process (exit 124) — the pre-fix preflight did not return within 40 seconds.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 passedcargo clippy --all-targets -- -D warnings— cleancargo fmt --all -- --check— clean