Skip to content

Update debugging and env variables for Postgres spin up - #1001

Open
jaclark5 wants to merge 1 commit into
MolSSI:mainfrom
jaclark5:fix_snowflake
Open

jaclark5 wants to merge 1 commit into
MolSSI:mainfrom
jaclark5:fix_snowflake

Conversation

@jaclark5

@jaclark5 jaclark5 commented Apr 6, 2026 •

Copy link
Copy Markdown

PostgreSQL Snowflake Startup Changes

  • Functional Improvement: Prefer pg_ctl found directly on PATH before falling back to pg_config-based discovery in PostgresHarness.

    • Why necessary: Prevents mixed PostgreSQL toolchains (for example, pg_config from one installation and pg_ctl/postgres from another), which can cause fragile startup behavior after package manager upgrades.
    • Platforms that benefit: macOS (especially Homebrew users), Linux systems with multiple PostgreSQL installs, and CI environments with layered tool paths.
  • Debugging Enhancement: Include PostgreSQL logfile path and log tail in startup failures raised by PostgresHarness.start().

    • Why necessary: pg_ctl often returns generic errors like "could not start server"; surfacing log tail makes root-cause diagnosis immediate without manual file hunting.
    • Platforms that benefit: All platforms (macOS, Linux, Windows-like POSIX layers) where PostgreSQL logs are available.
  • Functional Improvement: Add targeted detection of locale-related PostgreSQL startup failure and retry pg_ctl start once with LC_ALL=C and LANG=C.

    • Why necessary: Some environments export invalid locale state (for example empty LC_ALL), which can trigger PostgreSQL startup aborts; retrying only on known failure signatures avoids broad environment changes.
    • Platforms that benefit: Primarily macOS (where this failure was observed), and any Unix-like environment where locale configuration can be invalid in shell/notebook sessions.
  • Functional Improvement: Add a PostgreSQL minimum version check in qcfractal/db_socket/socket.py before creating tables and running Alembic upgrades.

    • Why necessary: QCFractal schema features require PostgreSQL 15+ (for example NULLS NOT DISTINCT behavior in unique constraints); failing early with a clear message avoids hard-to-diagnose migration/runtime failures later.
    • Platforms that benefit: All platforms, especially environments with older default PostgreSQL versions (common on Linux distributions and long-lived workstation installs).
  • Debugging Enhancement: Add explicit retry note text to the raised startup error when locale-safe retry was attempted.

    • Why necessary: Makes it clear in a single traceback whether fallback logic was used, reducing ambiguity during triage and PR review.
    • Platforms that benefit: All platforms.

Close #1000

Status

  • Code base linted
  • Ready to go

@jaclark5 jaclark5 changed the title Update debugging and env variables Update debugging and env variables for Postgres spin up Apr 6, 2026
@bennybp

bennybp commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

looks mostly reasonable. I'm curious at what your set up is that is causing it to fail, though. I do search through $PATH. I do this manually, for some reason (I think because pg_config can be in a separate place the pg_ctl?).

Where are your your pg_config and pg_ctl located, and what does "pg_config --bindir" show?

@jaclark5

jaclark5 commented Apr 6, 2026

Copy link
Copy Markdown
Author

pg_config --bindir

/opt/homebrew/bin/pg_config
/opt/homebrew/bin/pg_ctl
/opt/homebrew/Cellar/postgresql@15/15.17/bin

I can remove that part if you want. I think setting the env is really what fix my issue, but checking the path is something I tried first and didn't think it would hurt to leave it.

@jaclark5

Copy link
Copy Markdown
Author

@bennybp would you prefer I remove the pg_config --bindir?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snowflake doesn't start up

2 participants