Content-Length: 212789 | pFad | http://github.com/PostgresApp/PostgresApp/issues/789

FD 'Port in use' check not working in older versions of macOS · Issue #789 · PostgresApp/PostgresApp · GitHub
Skip to content
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

'Port in use' check not working in older versions of macOS #789

Open
tbussmann opened this issue Nov 20, 2024 · 2 comments
Open

'Port in use' check not working in older versions of macOS #789

tbussmann opened this issue Nov 20, 2024 · 2 comments

Comments

@tbussmann
Copy link
Member

In macOS 10.15, the check for the 'port in use' error before being able to press the 'Initialise' or 'Start' buttons seem not to work. Instead the operation is initiated and an "pg_ctl: could not start server" error is presented. This however does not seem to be a regressions of the latest refactoring regarding PID file deletion as I can reproduce the problem even with 2.7.2. The issue does not affect macOS 12. I have not tried to reproduce this on other older versions of macOS.

@jakob
Copy link
Member

jakob commented Nov 22, 2024

I've tried to reproduce this bug with Postgres.app 2.7.10 on macOS 10.15.7. It works fine for me.

Could it be something related to your VM? Maybe there is a weird network configuration that makes it break.

The check in Postgres.app is hard coded to try opening a port on "127.0.0.1". It seems that this check in the GUI succeeds, but then PostgreSQL fails to open a port. Maybe it has something to do with listen_address? Did you change the default config?

@tbussmann
Copy link
Member Author

I've spent some more investigation on this. Thank you for the hint on listen_address! I can now reproduce the behaviour even on modern versions of macOS:

  • create a server on a specific port, like 3322
  • initialize and start the server
  • netstat -anvp tcp | grep 3322 should now show a process in state LISTEN on 127.0.0.1.3322 for tcp4
  • connect psql to the server and execute ALTER SYSTEM SET listen_addresses TO '*';
  • restart the server
  • netstat -anvp tcp | grep 3322 should now show a process in state LISTEN on *.3322 for tcp4
  • change another (inzialized) server to run on that port
  • note that Postgres.App shows "Not running" as server state, not "Port in use"
  • try to start the server and get a error message "Port 3322 is already in use"

this is not perfect, but does no harm.

If you alternatively

  • create a new server on that port
  • note that Postgres.App shows "Empty data directory" as server state
  • attempt to initialize the server, get a error message "Could not start PostgreSQL server."

we are in an error state that is not resolvable without manual intervention: The init_db has been run but the server could not be started and the process aborts before the usual role and database could be created. This is an error condition we have seen in many issues but I never understood how this can happen.

Obviously, * (or 0.0.0.0) does include 127.0.0.1 but our portInUse test seems not to be able to detect that. A nc -b lo0 -l 3322 fails with Address already in use. But Postgres itself seem to be happy binding on 127.0.0.1 again, it only chokes on the lockfile when attempting to bind to the unix domain socket (but it doesn't change if I set unix_socket_directories to ''):

LOG:  listening on IPv6 address "::1", port 3322
LOG:  listening on IPv4 address "127.0.0.1", port 3322
FATAL:  lock file "/tmp/.s.PGSQL.3322.lock" already exists
HINT:  Is another postmaster (PID 18227) using socket file "/tmp/.s.PGSQL.3322"?

This my be the same root problem as in #798

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

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/PostgresApp/PostgresApp/issues/789

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy