Skip to content

fix: Don't explicitly use a socket for Postgres #712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stahnma
Copy link
Contributor

@stahnma stahnma commented May 29, 2025

Previously, the default configuration for flox/postgres uses both a socket and
a TCP connection. This was both redundant and caused Postgres not to start in
several scenarios -- primarily because the postgres socket file path was deep
in the .flox structure, which already might be deep in the filesystem. The
maximum lenght for a file socket path on MacOS is 103 characters. If it's
longer than that, PG will not start. This change simply removes the call to -c socket because it's redundant with the way Postgres is already configured via
this env.

Additionally, the presence of PGHOST cause the primary go Postgres library to
panic as it tries to parse that even when the presence of TCP connection
information is available.

@floxbot floxbot added the team-content Issues to be picked up by @flox/team-content label May 29, 2025
@stahnma stahnma force-pushed the postgres_no_socket branch from d06d56b to 214fb3e Compare May 29, 2025 01:14
Previously, the default configuration for flox/postgres uses both a socket and
a TCP connection. This was both redundant and caused Postgres not to start in
several scenarios -- primarily because the postgres socket file path was deep
in the .flox structure, which already might be deep in the filesystem. The
maximum lenght for a file socket path on MacOS is 103 characters. If it's
longer than that, PG will not start. This change simply removes the call to `-c
socket` because it's redundant with the way Postgres is already configured via
this env.

Additionally, the presence of PGHOST cause the primary go Postgres library to
panic as it tries to parse that even when the presence of TCP connection
information is available.

I actually wonder if PGHOST should be renamed to PGRUN or something else, as
it's only used to locate the `/run` directory.
@stahnma stahnma force-pushed the postgres_no_socket branch from 214fb3e to a1d67b6 Compare May 29, 2025 01:17
@rossturk
Copy link
Collaborator

I have made this change and reverted it once before.

Screenshot 2025-05-29 at 1 16 55 AM

It was a while ago, but IIRC it was because in my testing I encountered a super bare system where this did not work. It was then that I realized that most systems where I work had, at one time or another, had Postgres installed via a package manager with elevated privs. Once I tried it on a system that never had, it failed because (iirc) a required suidroot socket was missing.

Copy link
Collaborator

@rossturk rossturk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure this works across all of our footprints (including wsl and flox containerize) - I have tried this before and reverted after encountering issues.

Also, be good to check that this can still support multiple instances on the same host (configured with alternate ports).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-content Issues to be picked up by @flox/team-content
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants