zonkyio / embedded-postgres

Java embedded PostgreSQL component for testing
Apache License 2.0
349 stars 46 forks source link

Running under linux on an M1 mac #95

Closed kujeger closed 1 year ago

kujeger commented 2 years ago

Hi!

Probably a bit of an edge case, but when running this under linux on an M1, there seems to be a page alignment issue with the postgres build:

'io.zonky.test.postgres:embedded-postgres-binaries-linux-arm64v8:14.5.0'

[ INFO] 12:01:21 [main           ] Detected a Linux aarch64 system []
[ INFO] 12:01:21 [main           ] Detected distribution: 'Arch Linux ARM' []
[ INFO] 12:01:21 [main           ] System specific postgres binaries found: 'postgres-linux-arm_64.txz' []
[ INFO] 12:01:21 [main           ] Postgres binaries at /tmp/embedded-pg/PG-cd76b1533991a06ea76072a418c92e0b []
[ INFO] 12:01:21 [initdb:pid(59135)] /tmp/embedded-pg/PG-cd76b1533991a06ea76072a418c92e0b/bin/postgres: error while loading shared libraries: libxml2.so.2: ELF load command address/offset not page-aligned []
[ INFO] 12:01:21 [initdb:pid(59135)] no data was returned by command ""/tmp/embedded-pg/PG-cd76b1533991a06ea76072a418c92e0b/bin/postgres" -V" []
[ INFO] 12:01:21 [initdb:pid(59135)] initdb: error: The program "postgres" is needed by initdb but was not found in the []
[ INFO] 12:01:21 [initdb:pid(59135)] same directory as "/tmp/embedded-pg/PG-cd76b1533991a06ea76072a418c92e0b/bin/initdb". []
[ INFO] 12:01:21 [initdb:pid(59135)] Check your installation. []
[..]
java.lang.IllegalStateException: Process [/tmp/embedded-pg/PG-cd76b1533991a06ea76072a418c92e0b/bin/initdb, -A, trust, -U, postgres, -D, /tmp/epg13859057345091657383, -E, UTF-8] failed

I'm guessing this is because the M1 macs use a 16K page architecture, while some things incorrectly assume arm64 is 4K-pages only.

The official postgres arm64v8 docker images work fine on this machine.

Ryan-Dake commented 2 years ago

I'm having the same issue. Is there a configuration fix or solution?

tomix26 commented 1 year ago

Hi @kujeger, thanks for the report. To be honest, I'm not an expert in this area and don't know how to solve it. So if anyone has an idea how to deal with this problem, help is welcome.

tomix26 commented 1 year ago

I've checked the error more carefully and realized that the libxml2.so library mentioned in the error message comes from apt-get. So it seems to me that the library can be corrupted, outdated or incompatible with the rest of the binaries (or the M1 platform).

apt-get update && apt-get install -y --no-install-recommends \
        ...
        libxml2-dev
        ...

Maybe it's happening because the build relies on the outdated Ubuntu 14.04. The older version was chosen to ensure wider compatibility of the produced binaries. But maybe this version is too outdated and it's time for an upgrade.

bcipriano commented 1 year ago

I'm also having an issue w/ M1+linux via Docker: https://github.com/zonkyio/embedded-postgres/issues/99

@kujeger It's not totally clear, when you say "linux on an M1" are you using Docker? If so, what base image are you using?

tomix26 commented 1 year ago

I think that https://github.com/zonkyio/embedded-postgres-binaries/pull/64 should fix the error, so I'm closing the issue. If not, feel free to reopen it.