zonkyio / embedded-postgres

Java embedded PostgreSQL component for testing
Apache License 2.0
352 stars 47 forks source link

Segmentation fault: 11 on macOS Monterey #78

Closed henrik242 closed 2 years ago

henrik242 commented 2 years ago

I seem to be unable to use embedded-postgres (I'm on v1.3.1)

Process [/var/folders/lp/58zt5n313qg4s0d0b_yqnmsc0000gn/T/embedded-pg/PG-a2a9bc65661eac6f108fc920268a87b3/bin/initdb, -A, trust, -U, postgres, -D, /var/folders/lp/58zt5n313qg4s0d0b_yqnmsc0000gn/T/epg16198865472753438309, -E, UTF-8] failed
java.lang.IllegalStateException: Process [/var/folders/lp/58zt5n313qg4s0d0b_yqnmsc0000gn/T/embedded-pg/PG-a2a9bc65661eac6f108fc920268a87b3/bin/initdb, -A, trust, -U, postgres, -D, /var/folders/lp/58zt5n313qg4s0d0b_yqnmsc0000gn/T/epg16198865472753438309, -E, UTF-8] failed
    at io.zonky.test.db.postgres.embedded.EmbeddedPostgres.system(EmbeddedPostgres.java:632)
    at io.zonky.test.db.postgres.embedded.EmbeddedPostgres.initdb(EmbeddedPostgres.java:252)
    at io.zonky.test.db.postgres.embedded.EmbeddedPostgres.<init>(EmbeddedPostgres.java:159)
    at io.zonky.test.db.postgres.embedded.EmbeddedPostgres$Builder.start(EmbeddedPostgres.java:583)
    at io.zonky.test.db.postgres.embedded.EmbeddedPostgres.start(EmbeddedPostgres.java:477)
$ pwd
/var/folders/lp/58zt5n313qg4s0d0b_yqnmsc0000gn/T/embedded-pg/PG-a2a9bc65661eac6f108fc920268a87b3/bin
$ ./postgres 
Segmentation fault: 11
$ file postgres 
postgres: Mach-O universal binary with 2 architectures: [i386:Mach-O executable i386] [x86_64]
postgres (for architecture i386):   Mach-O executable i386
postgres (for architecture x86_64): Mach-O 64-bit executable x86_64
$ uname -a
Darwin foo.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64
$  ./initdb -V
initdb (PostgreSQL) 10.18
$  ./pg_ctl -V
pg_ctl (PostgreSQL) 10.18
henrik242 commented 2 years ago

Switching to a newer postgresql binary than the default 10.18 fixed it, e.g.

configurations.all {
     resolutionStrategy.eachDependency { DependencyResolveDetails details ->
         if (details.requested.group == 'io.zonky.test.postgres') {
            details.useVersion '11.13.0'
        }
    }
}
scottrobey commented 2 years ago

In case it helps... I downloaded the Postgres binaries directly from the EDB website and they seg fault for me when I run them directly from command line (without even using embedded-postgres) on macOS 12.0.1, so that seems to be where the root cause of the issue is I believe. I tried the binaries from:

But I get the following when I try to run the binary:

./postgres 
[1]    19003 segmentation fault  ./postgres

Version 11.13 and 12.8 from http://get.enterprisedb.com/postgresql/postgresql-11.13-1-osx-binaries.zip and http://get.enterprisedb.com/postgresql/postgresql-12.8-1-osx-binaries.zip did seem to work for me:

 ./postgres -V
postgres (PostgreSQL) 11.13

and

./postgres -V
postgres (PostgreSQL) 12.8
tomix26 commented 2 years ago

Thanks a lot for your investigation guys, I will consider upgrading the default version of postgres binaries.

henrik242 commented 2 years ago

Thanks a lot for your investigation guys, I will consider upgrading the default version of postgres binaries.

šŸ‘šŸ»

robjampar commented 2 years ago

we're running into this as well, the fix from henrik worked great. I would suggest that the default version gets pushed to 11.13, especially as the wider adoption of Monterey will ramp up.

justincrow commented 2 years ago

For those using SBT, just append the version you want to your library dependencies:

libraryDependencies += "io.zonky.test.postgres" % "embedded-postgres-binaries-darwin-amd64" % "11.13.0" % "runtime"

prabhushrikant commented 2 years ago

Switching to a newer postgresql binary than the default 10.18 fixed it, e.g.

configurations.all {
     resolutionStrategy.eachDependency { DependencyResolveDetails details ->
         if (details.requested.group == 'io.zonky.test.postgres') {
            details.useVersion '11.13.0'
        }
    }
}

Which dependency manager is this for? Gradle? How to achieve the same in Maven? I tried following link https://github.com/zonkyio/embedded-postgres#postgres-version but didn't solve it for me.

henrik242 commented 2 years ago

Which dependency manager is this for? Gradle? How to achieve the same in Maven? I tried following link https://github.com/zonkyio/embedded-postgres#postgres-version but didn't solve it for me.

Yeah, that's Gradle. The linked doc should solve the same thing in Maven, I don't really know why not.

ayushsangani commented 2 years ago

@tomix26 Do you know what's the timeline for upgrading the default version of Postgres to get this working? I have been using a workaround for a while now. Thanks in advance!!

BobbyJohansen commented 2 years ago

I would suggest that the default version gets pushed to 11.13, especially as the wider adoption of Monterey will ramp up.

What about databases that are below this version and on 10.X? Id love backward compatible support if possible.

grzegorz-banaszek commented 2 years ago

@prabhushrikant For maven you need to have the following in your pom:

  <dependencyManagement>

    <dependencies>
      <dependency>
        <groupId>io.zonky.test.postgres</groupId>
        <artifactId>embedded-postgres-binaries-bom</artifactId>
        <version>11.13.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>io.zonky.test</groupId>
      <artifactId>embedded-postgres</artifactId>
      <version>1.3.1</version>
      <scope>test</scope>
    </dependency>

  </dependencies>
tomix26 commented 2 years ago

The embedded postgres 2.0 has been upgraded to postgres binaries 14.3. This upgrade should resolve all of the issues listed above.