MolSSI / QCFractal

A distributed compute and database platform for quantum chemistry.
https://molssi.github.io/QCFractal/
BSD 3-Clause "New" or "Revised" License
144 stars 47 forks source link

Cannot connect to database via Unix socket #696

Closed lilyminium closed 11 months ago

lilyminium commented 2 years ago

Describe the bug

This is a repeated problem on my Mac OS Catalina (10.15.7). I haven't tried other architectures. On the Linux cluster the package works very well as installed, but I believe that's a TCP connection. (I don't know anything about Postgres, such as whether the default protocol is expected to be TCP.)

To Reproduce

This is the error I get using qcfractal 0.15.6 and the default environment in the quickstart notebook in #695, but with +chardet, +importlib_resources, and with qcelemental 0.22.0 instead of 0.23.0.

>>> server = FractalSnowflakeHandler()

(from printing stderr)

createdb: error: could not connect to database template1: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.49462"?

The command is ['/Users/lily/anaconda3/envs/snowflake/bin/createdb', '-p', '49462'].

Expected behavior

Additional context

If I hack PostgresHarnes._run to pass in localhost, it switches to Unix sockets.

https://github.com/MolSSI/QCFractal/blob/867b1bc9c87ae4be37d9656d95a7bd308b7b79a3/qcfractal/postgres_harness.py#L41-L49

    def _run(self, commands):
+        command_str = " ".join(list(map(str, commands)))
+        if (any(x in command_str for x in ["-p ", "--port="])
+                and not any(x in command_str for x in ["-h ", "--host="])):
+            commands.extend(["-h", "127.0.0.1"])

        proc = subprocess.run(commands, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout = proc.stdout.decode()
        if not self.quiet:
            self.logger(stdout)

        ret = {"retcode": proc.returncode, "stdout": stdout, "stderr": proc.stderr.decode()}
        return ret
bennybp commented 11 months ago

I think this is all working in v0.50, but it not, then let me know!