Embedded Postgres cannot obtain process PID on Mac OS

1k Views Asked by At

I'm using embedded PostgreSQL with Java 11 for integration testing. On Windows it runs fine, but on Mac it first downloads Mac OS binaries (which is expected):

Extract /Users/fubar/.embedpostgresql/postgresql-11.1-1-osx-binaries.zip START

But then it fails with the following stacktrace:

java.lang.NoSuchFieldException: handle
at java.base/java.lang.Class.getDeclaredField(Class.java:2411)
at de.flapdoodle.embed.process.runtime.Processes.windowsProcessId(Processes.java:109)
at de.flapdoodle.embed.process.runtime.Processes.access$200(Processes.java:51)
at de.flapdoodle.embed.process.runtime.Processes$PidHelper$2.getPid(Processes.java:209)

When I look into Processes source code I see that internally it uses PidHelper.LEGACY, that fails the first attempt to obtain pid via unixLikeProcessId().

Could anyone, please, give a hint why this is happenning or how to fix that?

1

There are 1 best solutions below

0
On

Logs revealed the following:

Possibly failed to run initdb:
initdb: invalid locale name "en-US"

So the initdb failed, PostgeSQL instance didn't start and didn't create a postmaster.pid file, which all led to the error above.

The problem was in locale that was configured via additionalInitDbParams=[--locale=en-US, -EUTF8].