I'm trying to get working a dockerized version of latest distribution of (1.2.0.Latest) Aerogear Unified Push Server (UPS) but using Postgres instead of MySql. In fact, the official UPS Docker distribution is based on it. It is quite easy to replace the connector in the base Docker file with the Postgres connector:
ENV POSTGRES_JDBC_VERSION 42.1.4
ENV db_module_dir=$JBOSS_HOME/modules/org/postgresql/main/
RUN mkdir -p ${db_module_dir}
RUN wget -O postgres-jdbc.jar http://central.maven.org/maven2/org/postgresql/postgresql/$POSTGRES_JDBC_VERSION/postgresql-$POSTGRES_JDBC_VERSION.jar
RUN mv postgres-jdbc.jar ${db_module_dir}
COPY configuration/xml/postgres-module.xml ${db_module_dir}/module.xml
I did this variation in older versions and everything worked fine.
Now, starting the container (through Docker Compose) from scratch (no pre-existingdatabases) I get the following error from the Liquibase job (jar) that builds/migrate the database schema/data:
Unexpected error running Liquibase: org.postgresql.util.PSQLException: ERROR: relation "PRIMARY" already exists
Here is the full log:
myproject_ups_db | The files belonging to this database system will be owned by user "postgres".
myproject_ups_db | This user must also own the server process.
myproject_ups_db |
myproject_ups_db | The database cluster will be initialized with locale "en_US.utf8".
myproject_ups_db | The default database encoding has accordingly been set to "UTF8".
myproject_ups_db | The default text search configuration will be set to "english".
myproject_ups_db |
myproject_ups_db | Data page checksums are disabled.
myproject_ups_db |
myproject_ups_db | fixing permissions on existing directory /var/lib/postgresql/data ... ok
myproject_ups_db | creating subdirectories ... ok
myproject_ups_db | selecting default max_connections ... 100
myproject_ups_db | selecting default shared_buffers ... 128MB
myproject_ups_db | selecting dynamic shared memory implementation ... posix
myproject_ups_db | creating configuration files ... ok
myproject_ups_db | creating template1 database in /var/lib/postgresql/data/base/1 ... ok
myproject_ups_db | initializing pg_authid ... ok
myproject_ups_db | initializing dependencies ... ok
myproject_ups_db | creating system views ... ok
myproject_ups_db | loading system objects' descriptions ... ok
myproject_ups_db | creating collations ... ok
myproject_ups_db | creating conversions ... ok
myproject_ups_db | creating dictionaries ... ok
myproject_ups_db | setting privileges on built-in objects ... ok
myproject_ups_db | creating information schema ... ok
myproject_ups_db | loading PL/pgSQL server-side language ... ok
myproject_ups_db | vacuuming database template1 ... ok
myproject_ups_db | copying template1 to template0 ... ok
myproject_ups_db | copying template1 to postgres ... ok
myproject_ups_db | syncing data to disk ... ok
myproject_ups_db |
myproject_ups_db | Success. You can now start the database server using:
myproject_ups_db |
myproject_ups_db | postgres -D /var/lib/postgresql/data
myproject_ups_db | or
myproject_ups_db | pg_ctl -D /var/lib/postgresql/data -l logfile start
myproject_ups_db |
myproject_ups_db |
myproject_ups_db | WARNING: enabling "trust" authentication for local connections
myproject_ups_db | You can change this by editing pg_hba.conf or using the option -A, or
myproject_ups_db | --auth-local and --auth-host, the next time you run initdb.
myproject_ups_db | waiting for server to start....LOG: database system was shut down at 2017-09-23 16:00:34 UTC
myproject_ups_db | LOG: MultiXact member wraparound protections are now enabled
myproject_ups_db | LOG: database system is ready to accept connections
myproject_ups_db | LOG: autovacuum launcher started
myproject_ups_db | done
myproject_ups_db | server started
myproject_ups_db | CREATE DATABASE
myproject_ups_db |
myproject_ups_db | CREATE ROLE
myproject_ups_db |
myproject_ups_db |
myproject_ups_db | /docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/
myproject_ups_db |
myproject_ups_db | LOG: received fast shutdown request
myproject_ups_db | LOG: aborting any active transactions
myproject_ups_db | LOG: autovacuum launcher shutting down
myproject_ups_db | LOG: shutting down
myproject_ups_db | waiting for server to shut down....LOG: database system is shut down
myproject_ups_db | done
myproject_ups_db | server stopped
myproject_ups_db |
myproject_ups_db | PostgreSQL init process complete; ready for start up.
myproject_ups_db |
myproject_ups_db | LOG: database system was shut down at 2017-09-23 16:00:36 UTC
myproject_ups_db | LOG: MultiXact member wraparound protections are now enabled
myproject_ups_db | LOG: database system is ready to accept connections
myproject_ups_db | LOG: autovacuum launcher started
myproject_ups | Starting Liquibase migration
myproject_ups | Unexpected error running Liquibase: org.postgresql.util.PSQLException: ERROR: relation "PRIMARY" already exists
myproject_ups |
myproject_ups |
myproject_ups exited with code 255
Any suggestion?
Finally, I've found the solution. I want to share it in the following.
Problem arises from latest file included in the Liquibase job (jar):
liquibase/1.2.0/2017-09-06-flat-model-entities.xml
Just commenting the directive:
<changeSet author="matzew (generated)" id="1504688114371-22">
<addPrimaryKey columnNames="push_message_variant_id" constraintName="PRIMARY" tableName="variant_error_status"/>
</changeSet>
fixes the 'ERROR: relation "PRIMARY" already exists' problem.
After that, there are two more problems dealing with "duplicated index names" for indexes:
in the same file above, just renaming them as
makes everything work properly with no errors.
I guess such errors are related with using Postgres, maybe the Liquibase job was designed (and tested) just for MySql.