yandex-qatools / postgresql-embedded

Embedded PostgreSQL Server
Other
493 stars 90 forks source link

postgresql-embedded fails to start in travis environment #145

Open arhelmus opened 5 years ago

arhelmus commented 5 years ago

Hi there, first of all, thx for your library it worked great for the last two years for me.

Currently, I have a public project which uses postgres-embedded and builds it at CI, but after some changes (probably in Travis ci agents), my test code cannot connect to Postgres on build machines. I cannot reproduce it locally and not sure how to get more information about what's going on.

Here is build log https://travis-ci.org/ArchDev/akka-http-rest/jobs/440496384#L796 and file where I use the library https://github.com/ArchDev/akka-http-rest/blob/master/src/test/scala/me/archdev/utils/InMemoryPostgresStorage.scala also Travis build config https://github.com/ArchDev/akka-http-rest/blob/master/.travis.yml

This happening only on CI (worst words ever). Locally everything works great for me. Can you please help me to debug that issue?

ilkerc commented 5 years ago

I'm digging this problem for a while (using wercker CI tool). Using wercker CLI I can do the same steps locally on my machine and debug intermediate containers. (Postgres is being initiated on a maven test step.)

What I have discovered so far are:

Here is the log of the failing intermediate container.

f942d41eb4eb:/tmp/postgresql-embed-27b0c95b-2ddb-413a-88ac-abe62ef8949a/pgsql-10.3-1/pgsql/bin$ whoami
postgres

Binary files do exists.

f942d41eb4eb:/tmp/postgresql-embed-27b0c95b-2ddb-413a-88ac-abe62ef8949a/pgsql-10.3-1/pgsql/bin$ ls
''$'\001''p'   initdb          pg_dump      pg_rewind        postgres
 clusterdb     oid2name        pg_dumpall       pg_standby       postmaster
 createdb      pg_archivecleanup   pg_isready       pg_test_fsync    psql
 createuser    pg_basebackup       pg_receivewal    pg_test_timing   psql.bin
 dropdb        pg_config       pg_recvlogical   pg_upgrade       reindexdb
 dropuser      pg_controldata      pg_resetwal      pg_waldump       vacuumdb
 ecpg          pg_ctl          pg_restore       pgbench      vacuumlo

Somehow, I can not run the executable. Which lead me to checking the instruction set compability

f942d41eb4eb:/tmp/postgresql-embed-27b0c95b-2ddb-413a-88ac-abe62ef8949a/pgsql-10.3-1/pgsql/bin$ ./initdb
-sh: ./initdb: not found

I also checked x64 compability:

f942d41eb4eb:/tmp/postgresql-embed-27b0c95b-2ddb-413a-88ac-abe62ef8949a/pgsql-10.3-1/pgsql/bin$ uname -a
Linux f942d41eb4eb 4.14.79-boot2docker #1 SMP Thu Nov 8 01:56:42 UTC 2018 x86_64 GNU/Linux

Anyone having insights about that?

ilkerc commented 5 years ago

Somehow it did had to do with the base image I was using. Maybe it was missing some runtime libraries.. I left using alpine versions and ended up using ubuntu 16.04 with preinstalled jdk.

After all, it was able to execute initdb. While maven is being executed as root I created a new user and did installation & packaging using the unprivileged user.

Anyone having the same issue, I'll paste here the wercker.yml file. Hope you wont waste hours like I did :)

box: mlaccetti/docker-oracle-java8-ubuntu-16.04
build:
  steps:
  - script:
      name: install required packages
      code: |
        apt-get -y update
        apt-get install -y git curl sudo
        useradd -ms /bin/bash mavenuser
  - wercker/maven:
      goals: install
      cache_repo: true
      version: 3.5.4
      sudo_user: mavenuser