Failed to read postmaster.pid file while running embedded-postgres

659 Views Asked by At

My Spring application uses yandex-qatools/postgresql-embedded for executing Unit Tests.

While executing them, I am constantly getting the below error :

ERROR 75847 --- [    Test worker] r.y.q.embed.postgresql.PostgresProcess   : Failed to read PID file (File '/var/folders/sh/xr6l_7bs1_z9v1jfsyctc45w0000gp/T/postgresql-embed-b05c213f-7416-4200-a586-a3afb3263478/db-content-4f285249-22ea-4625-b771-156adbf5851f/postmaster.pid' does not exist)

java.io.FileNotFoundException: File '/var/folders/sh/xr6l_7bs1_z9v1jfsyctc45w0000gp/T/postgresql-embed-b05c213f-7416-4200-a586-a3afb3263478/db-content-4f285249-22ea-4625-b771-156adbf5851f/postmaster.pid' does not exist

There is a warning popped up before the exception, but for now, let's ignore it.

WARN 75847 --- [    Test worker] r.y.q.embed.postgresql.PostgresProcess   : Possibly failed to run initdb:
no data was returned by command ""/private/var/folders/sh/xr6l_7bs1_z9v1jfsyctc45w0000gp/T/postgresql-embed-b05c213f-7416-4200-a586-a3afb3263478/pgsql-10.3-1/pgsql/bin/postgres" -V"

The program "postgres" is needed by initdb but was not found in the

same directory as "/private/var/folders/sh/xr6l_7bs1_z9v1jfsyctc45w0000gp/T/postgresql-embed-b05c213f-7416-4200-a586-a3afb3263478/pgsql-10.3-1/pgsql/bin/initdb".

Check your installation.

I verified that no other instance of Postgress is running on my local machine using ps -ef|grep postgres

Followed this thread as well, but it doesn't help.

Ran out of options to fix this, can anyone please suggest how to resolve it.

OSX version: 12.1

Thanks in advance

1

There are 1 best solutions below

0
On

In my case, besides your error, I also could see the following error:

r.y.q.embed.postgresql.PostgresProcess : Possibly failed to run initdb: initdb: invalid locale settings; check LANG and LC_* environment variables

This message led me to the solution. I just added the below environment properties to my .zshrc file:

export LANG="en_US.UTF-8" 
export LC_ALL="en_US.UTF-8" 
export LC_CTYPE="en_US.UTF-8"