Postgres image is not creating database - postgresql

According to these docs, I can specify the name of the database created by the postgres docker image with the env var POSTGRES_DB. I have set it in my docker-compose file, but it isn't being created.
Here's relevant section from the compose file:
pg:
image: postgres:10
volumes:
- db-data:/var/lib/postgresql/data
environment:
POSTGRES_DB: user-auth
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Here are the logs:
Attaching to userauth_pg_1
pg_1 | 2018-02-05 18:05:54.803 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
pg_1 | 2018-02-05 18:05:54.803 UTC [1] LOG: listening on IPv6 address "::", port 5432
pg_1 | 2018-02-05 18:05:54.806 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
pg_1 | 2018-02-05 18:05:54.817 UTC [24] LOG: database system was interrupted; last known up at 2018-02-05 18:03:26 UTC
pg_1 | 2018-02-05 18:05:54.942 UTC [24] LOG: database system was not properly shut down; automatic recovery in progress
pg_1 | 2018-02-05 18:05:54.944 UTC [24] LOG: redo starts at 0/1633ED0
pg_1 | 2018-02-05 18:05:54.944 UTC [24] LOG: invalid record length at 0/1633F08: wanted 24, got 0
pg_1 | 2018-02-05 18:05:54.944 UTC [24] LOG: redo done at 0/1633ED0
pg_1 | 2018-02-05 18:05:54.955 UTC [1] LOG: database system is ready to accept connections
pg_1 | 2018-02-05 18:05:59.140 UTC [31] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:06:15.528 UTC [32] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:08:46.120 UTC [33] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:08:46.151 UTC [34] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:02.138 UTC [35] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:02.926 UTC [36] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:04.244 UTC [37] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:04.273 UTC [38] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:04.602 UTC [39] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:04.910 UTC [40] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:05.777 UTC [41] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:05.823 UTC [42] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:05.878 UTC [43] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:06.663 UTC [44] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:06.716 UTC [45] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:16:32.713 UTC [46] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:47:04.603 UTC [47] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:51:34.413 UTC [1] LOG: received smart shutdown request
pg_1 | 2018-02-05 18:51:34.417 UTC [1] LOG: worker process: logical replication launcher (PID 30) exited with exit code 1
pg_1 | 2018-02-05 18:51:34.419 UTC [25] LOG: shutting down
pg_1 | 2018-02-05 18:51:34.434 UTC [1] LOG: database system is shut down
pg_1 | 2018-02-05 19:08:42.934 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
pg_1 | 2018-02-05 19:08:42.934 UTC [1] LOG: listening on IPv6 address "::", port 5432
pg_1 | 2018-02-05 19:08:42.937 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
pg_1 | 2018-02-05 19:08:42.951 UTC [25] LOG: database system was shut down at 2018-02-05 18:51:34 UTC
pg_1 | 2018-02-05 19:08:42.956 UTC [1] LOG: database system is ready to accept connections
pg_1 | 2018-02-05 19:09:04.316 UTC [32] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 19:09:18.081 UTC [33] FATAL: database "user-auth" does not exist

You most probably started the container without the env variables set.
The db was then initialized without user or DB info.
You need to delete the volume and try again.
Credit: https://github.com/docker-library/postgres/issues/453#issuecomment-393939412

You can always initialize scripts for your database before running the container that if even in case you want to add multiple users or create tables initially inside of your container. a basic script would be like :
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE DATABASE database_name;
CREATE USER new_user_name WITH ENCRYPTED PASSWORD 'new_password';
GRANT ALL PRIVILEGES ON DATABASE new_user_name TO database_nam;
EOSQL
and can be saved as a shell file (init_db.sh for example).
Make sure at last to copy the file from your relative directory to the container by adding it to the docker-compose.yml file :
services:
db:
image: postgres:latest
ports:
- '4020:5432'
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- ./init_db.sh:/docker-entrypoint-initdb.d/init_db.sh

In my case, I've already had PostgreSQL working in the background on windows. And when I tried to connect to the docker container, I connected to my windows Postgres. You need to open services.msc and turn off PostreSQL

I was using devcontainer (Python 3 & PostgreSQL) in Visual Studio Code and sqltools.connections settings in devcontainer.json were overriding the configuration in docker-compose.yml.
I changed the settings there too and it worked as expected!

If you are using the Docker application you should delete the existing container and install it again with the command:
docker run --name containerName -p 5432:5432 -e POSTGRES_PASSWORD=postgresql -e POSTGRES_USER=postgresql -e POSTGRES_DB=dbName -d postgres

docker system prune
Adding this removed previous database settings of docker. Then ran again the pipeline after cleanup.

Related

postgresql log about no existing database

I don't understand this postgresql log :
2022-03-27 08:00:19.441 UTC [584262] postgres#boutique2 FATAL: database "boutique2" does not exist
2022-03-27 08:00:19.704 UTC [584264] postgres#boutique2 FATAL: database "boutique2" does not exist
2022-03-27 08:01:54.770 UTC [781] LOG: received fast shutdown request
2022-03-27 08:01:54.773 UTC [781] LOG: aborting any active transactions
2022-03-27 08:01:54.779 UTC [781] LOG: background worker "logical replication launcher" (PID 800) exited with exit code 1
2022-03-27 08:01:54.780 UTC [795] LOG: shutting down
2022-03-27 08:01:54.797 UTC [781] LOG: database system is shut down
2022-03-27 08:02:16.254 UTC [770] LOG: starting PostgreSQL 13.5 (Debian 13.5-0+deb11u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-03-27 08:02:16.255 UTC [770] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-03-27 08:02:16.256 UTC [770] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-03-27 08:02:16.271 UTC [772] LOG: database system was shut down at 2022-03-27 08:01:54 UTC
2022-03-27 08:02:16.285 UTC [770] LOG: database system is ready to accept connections
2022-03-27 08:02:17.243 UTC [891] postgres#boutique2 FATAL: database "boutique2" does not exist
2022-03-27 08:02:17.640 UTC [1044] postgres#boutique2 FATAL: database "boutique2" does not exist
I dropped this database, which is not present in my mojolicious scripts, the only ones on this server.
root#perso:/etc/postgresql/13/main# grep postgresql.conf -e 'boutique2'
root#perso:/etc/postgresql/13/main# grep pg_hba.conf -e 'boutique2'
root#perso:/etc/postgresql/13/main#
Has please someone an idea about ?

Hasura installation problem using docker - PostgreSQL not responding

I want to install Hasura using docker. According to the Hasura doc, I created the docker-compose.yml file. then I compose docker with docker-compose up. In my terminal log, a message comes LOG: database system is ready to accept connections. But when I go to the http://localhost:8080/, I find nothing.
I don't understand where is the problem and how to solve it?
docker-compose.yml file
version: '3.6'
services:
postgres:
image: postgres:12
restart: always
volumes:
- ./db_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgrespassword
graphql-engine:
image: hasura/graphql-engine:v2.0.10
ports:
- "8080:8080"
depends_on:
- "postgres"
restart: always
environment:
## postgres database to store Hasura metadata
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword#postgres:5432/postgres
## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs
PG_DATABASE_URL: postgres://postgres:postgrespassword#postgres:5432/postgres
## enable the console served by server
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to set an admin secret
# HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
volumes:
db_data:
my terminal:
sumon#error-inside hasura % docker-compose up
hasura_postgres_1 is up-to-date
9675a01ed8fd_hasura_graphql-engine_1 is up-to-date
Attaching to hasura_postgres_1, 9675a01ed8fd_hasura_graphql-engine_1
9675a01ed8fd_hasura_graphql-engine_1 | qemu: uncaught target signal 11 (Segmentation fault) - core dumped
9675a01ed8fd_hasura_graphql-engine_1 | qemu: uncaught target signal 11 (Segmentation fault) - core dumped
9675a01ed8fd_hasura_graphql-engine_1 | qemu: uncaught target signal 11 (Segmentation fault) - core dumped
9675a01ed8fd_hasura_graphql-engine_1 | qemu: uncaught target signal 11 (Segmentation fault) - core dumped
postgres_1 | The files belonging to this database system will be owned by user "postgres".
postgres_1 | This user must also own the server process.
postgres_1 |
postgres_1 | The database cluster will be initialized with locale "en_US.utf8".
postgres_1 | The default database encoding has accordingly been set to "UTF8".
postgres_1 | The default text search configuration will be set to "english".
postgres_1 |
postgres_1 | Data page checksums are disabled.
postgres_1 |
postgres_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgres_1 | creating subdirectories ... ok
postgres_1 | selecting dynamic shared memory implementation ... posix
postgres_1 | selecting default max_connections ... 100
postgres_1 | selecting default shared_buffers ... 128MB
postgres_1 | selecting default time zone ... Etc/UTC
postgres_1 | creating configuration files ... ok
postgres_1 | running bootstrap script ... ok
postgres_1 | performing post-bootstrap initialization ... ok
postgres_1 | syncing data to disk ... ok
postgres_1 |
postgres_1 |
postgres_1 | Success. You can now start the database server using:
postgres_1 |
postgres_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
postgres_1 |
postgres_1 | initdb: warning: enabling "trust" authentication for local connections
postgres_1 | You can change this by editing pg_hba.conf or using the option -A, or
postgres_1 | --auth-local and --auth-host, the next time you run initdb.
postgres_1 | waiting for server to start....2021-10-23 04:46:45.991 UTC [50] LOG: starting PostgreSQL 12.8 (Debian 12.8-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
postgres_1 | 2021-10-23 04:46:45.993 UTC [50] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2021-10-23 04:46:46.023 UTC [51] LOG: database system was shut down at 2021-10-23 04:46:44 UTC
postgres_1 | 2021-10-23 04:46:46.039 UTC [50] LOG: database system is ready to accept connections
postgres_1 | done
postgres_1 | server started
postgres_1 |
postgres_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
postgres_1 |
postgres_1 | waiting for server to shut down...2021-10-23 04:46:46.242 UTC [50] LOG: received fast shutdown request
postgres_1 | .2021-10-23 04:46:46.243 UTC [50] LOG: aborting any active transactions
postgres_1 | 2021-10-23 04:46:46.245 UTC [50] LOG: background worker "logical replication launcher" (PID 57) exited with exit code 1
postgres_1 | 2021-10-23 04:46:46.245 UTC [52] LOG: shutting down
postgres_1 | 2021-10-23 04:46:46.279 UTC [50] LOG: database system is shut down
postgres_1 | done
postgres_1 | server stopped
postgres_1 |
postgres_1 | PostgreSQL init process complete; ready for start up.
postgres_1 |
postgres_1 | 2021-10-23 04:46:46.358 UTC [1] LOG: starting PostgreSQL 12.8 (Debian 12.8-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
postgres_1 | 2021-10-23 04:46:46.359 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2021-10-23 04:46:46.359 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2021-10-23 04:46:46.363 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2021-10-23 04:46:46.395 UTC [69] LOG: database system was shut down at 2021-10-23 04:46:46 UTC
postgres_1 | 2021-10-23 04:46:46.413 UTC [1] LOG: database system is ready to accept connections
postgres_1 | 2021-10-23 04:51:52.553 UTC [1] LOG: received fast shutdown request
postgres_1 | 2021-10-23 04:51:52.555 UTC [1] LOG: aborting any active transactions
postgres_1 | 2021-10-23 04:51:52.556 UTC [1] LOG: background worker "logical replication launcher" (PID 75) exited with exit code 1
postgres_1 | 2021-10-23 04:51:52.559 UTC [70] LOG: shutting down
postgres_1 | 2021-10-23 04:51:52.596 UTC [1] LOG: database system is shut down
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | 2021-10-23 04:52:02.912 UTC [1] LOG: starting PostgreSQL 12.8 (Debian 12.8-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
postgres_1 | 2021-10-23 04:52:02.913 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2021-10-23 04:52:02.913 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2021-10-23 04:52:02.917 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2021-10-23 04:52:02.949 UTC [28] LOG: database system was shut down at 2021-10-23 04:51:52 UTC
postgres_1 | 2021-10-23 04:52:02.967 UTC [1] LOG: database system is ready to accept connections
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | 2021-10-23 05:09:34.960 UTC [1] LOG: starting PostgreSQL 12.8 (Debian 12.8-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
postgres_1 | 2021-10-23 05:09:34.960 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2021-10-23 05:09:34.960 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2021-10-23 05:09:34.964 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2021-10-23 05:09:34.996 UTC [28] LOG: database system was interrupted; last known up at 2021-10-23 04:57:03 UTC
postgres_1 | 2021-10-23 05:09:36.329 UTC [28] LOG: database system was not properly shut down; automatic recovery in progress
postgres_1 | 2021-10-23 05:09:36.342 UTC [28] LOG: redo starts at 0/164DF58
postgres_1 | 2021-10-23 05:09:36.342 UTC [28] LOG: invalid record length at 0/164E058: wanted 24, got 0
postgres_1 | 2021-10-23 05:09:36.342 UTC [28] LOG: redo done at 0/164E020
postgres_1 | 2021-10-23 05:09:36.367 UTC [1] LOG: database system is ready to accept connections
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | 2021-10-23 05:14:07.556 UTC [1] LOG: starting PostgreSQL 12.8 (Debian 12.8-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
postgres_1 | 2021-10-23 05:14:07.556 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2021-10-23 05:14:07.556 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2021-10-23 05:14:07.560 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2021-10-23 05:14:07.591 UTC [28] LOG: database system was interrupted; last known up at 2021-10-23 05:09:36 UTC
postgres_1 | 2021-10-23 05:14:08.941 UTC [28] LOG: database system was not properly shut down; automatic recovery in progress
postgres_1 | 2021-10-23 05:14:08.944 UTC [28] LOG: redo starts at 0/164E0D0
postgres_1 | 2021-10-23 05:14:08.944 UTC [28] LOG: invalid record length at 0/164E108: wanted 24, got 0
postgres_1 | 2021-10-23 05:14:08.944 UTC [28] LOG: redo done at 0/164E0D0
postgres_1 | 2021-10-23 05:14:08.963 UTC [1] LOG: database system is ready to accept connections
postgres_1 | 2021-10-23 06:21:46.578 UTC [32] WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted

Connecting to an existing docker postgres container with sequelize

I have an existing postgres container that is working fine on its own. I am trying to follow best practices with Sequelize with proper migrations and models now.
I spin up the docker container containing the postgres database:
Starting postgres-express-docker_postgres_1 ... done
Attaching to postgres-express-docker_postgres_1
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | 2020-08-06 14:43:59.373 UTC [1] LOG: starting PostgreSQL 12.3 (Debian 12.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
postgres_1 | 2020-08-06 14:43:59.373 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2020-08-06 14:43:59.373 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2020-08-06 14:43:59.376 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2020-08-06 14:43:59.388 UTC [27] LOG: database system was shut down at 2020-08-06 14:43:54 UTC
postgres_1 | 2020-08-06 14:43:59.393 UTC [1] LOG: database system is ready to accept connections
Then when I try to run sequelize db:migrate to run the built out migrations I get:
ERROR: getaddrinfo ENOTFOUND 0.0.0.0:5432
What Am I missing here? The sequelize Config is pointing to the same address...
Thanks in advance

Has anyone migrated Stellar's Docker Compose to Kubernetes and fixed the issue with Stellar Horizon DB?

I may be encountering the same issue described in Horizon: does not exit if database connection fails #898 (https://github.com/stellar/go/issues/898) but with a different set up scenario.
I am in the process of migrating https://github.com/satoshipay/docker-stellar-horizon Docker Compose definitions to Kubernetes. I have been able to migrate most of the set up but hitting a problem with Horizon where the DB is not getting created during startup. I believe I have stellar core with the dependency on Postgres working as designed and the DB created as part of startup but the set up is different for Horizon.
The current issue I am hitting is the following...
Horizon Server Pod Logs
todkapmcbookpro:kubernetes todd$ kubectl get pods
NAME READY STATUS RESTARTS AGE
postgres-horizon-564d479db4-2xvqd 1/1 Running 0 20m
postgres-sc-9f5f7fb4-prlpr 1/1 Running 0 22m
stellar-core-7ff77b4db8-tx4mt 1/1 Running 0 18m
stellar-horizon-6cff98554b-d7djn 0/1 CrashLoopBackOff 8 18m
todkapmcbookpro:kubernetes todd$ kubectl logs stellar-horizon-6cff98554b-d7djn
Initializing Horizon database...
2019/05/02 12:58:09 connect failed: pq: database "stellar-horizon" does not exist
Horizon database initialization failed (possibly because it has been done before)
2019/05/02 12:58:09 pq: database "stellar-horizon" does not exist
todkapmcbookpro:kubernetes todd$
Horizon Postgres DB pod logs
todkapmcbookpro:kubernetes todd$ kubectl logs postgres-horizon-564d479db4-2xvqd
2019-05-02 12:40:06.424 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2019-05-02 12:40:06.424 UTC [1] LOG: listening on IPv6 address "::", port 5432
2019-05-02 12:40:06.437 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-05-02 12:40:06.444 UTC [23] LOG: database system was interrupted; last known up at 2019-05-02 12:38:19 UTC
2019-05-02 12:40:06.453 UTC [23] LOG: database system was not properly shut down; automatic recovery in progress
2019-05-02 12:40:06.454 UTC [23] LOG: redo starts at 0/1636FB8
2019-05-02 12:40:06.454 UTC [23] LOG: invalid record length at 0/1636FF0: wanted 24, got 0
2019-05-02 12:40:06.454 UTC [23] LOG: redo done at 0/1636FB8
2019-05-02 12:40:06.459 UTC [1] LOG: database system is ready to accept connections
2019-05-02 12:42:35.675 UTC [30] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:42:35.690 UTC [31] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:42:37.123 UTC [32] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:42:37.136 UTC [33] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:42:50.131 UTC [34] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:42:50.153 UTC [35] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:43:16.094 UTC [36] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:43:16.115 UTC [37] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:43:57.097 UTC [38] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:43:57.111 UTC [39] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:45:21.050 UTC [40] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:45:21.069 UTC [41] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:48:05.122 UTC [42] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:48:05.145 UTC [43] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:53:07.077 UTC [44] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:53:07.099 UTC [45] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:58:09.084 UTC [46] FATAL: database "stellar-horizon" does not exist
2019-05-02 12:58:09.098 UTC [47] FATAL: database "stellar-horizon" does not exist
2019-05-02 13:03:18.055 UTC [48] FATAL: database "stellar-horizon" does not exist
2019-05-02 13:03:18.071 UTC [49] FATAL: database "stellar-horizon" does not exist
2019-05-02 13:08:28.057 UTC [50] FATAL: database "stellar-horizon" does not exist
2019-05-02 13:08:28.078 UTC [51] FATAL: database "stellar-horizon" does not exist
2019-05-02 13:13:42.071 UTC [52] FATAL: database "stellar-horizon" does not exist
2019-05-02 13:13:42.097 UTC [53] FATAL: database "stellar-horizon" does not exist
2019-05-02 13:18:55.128 UTC [54] FATAL: database "stellar-horizon" does not exist
2019-05-02 13:18:55.152 UTC [55] FATAL: database "stellar-horizon" does not exist
It would be ideal if the setup for Horizon and Core were the same (especially as it relates to the DB configuration env properties). I think I have the settings correct but may be missing something subtle.
I have a branch of this WIP where the failure occurs. I have included a quick set up script as well as a minikube set up in this branch.
https://github.com/todkap/stellar-testnet/tree/k8-deploy/kubernetes
We were able to resolve and published an article demonstrating the end to end flow.
https://itnext.io/how-to-deploy-a-stellar-validator-on-kubernetes-with-helm-a111e5dfe437

Docker Container: Relation X doesn't exist in database

I am developping a java application, I created an image of the database PostgreSQL by using docker.
I have a folder "docker-entrypoint-initdb.d" which contains files to create tables, data.
When I launch my application, I get this exception:
org.postgresql.util.PSQLException: ERROR: relation
"myerp.sequence_comptable" does not exist.
Here the content of docker-compose.yml:
version: '2'
services:
myerp.db:
image: postgres:10
ports:
- "127.0.0.1:9032:5432"
volumes:
- "./init/db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d"
environment:
- POSTGRES_DB=db_myerp
- POSTGRES_USER=usr_myerp
- POSTGRES_PASSWORD=myerp
When I launch command docker compose up:
Creating network "dev_default" with the default driver
Creating dev_myerp.db_1 ... done
Attaching to dev_myerp.db_1
myerp.db_1 | The files belonging to this database system will be owned by user "postgres".
myerp.db_1 | This user must also own the server process.
myerp.db_1 |
myerp.db_1 | The database cluster will be initialized with locale "en_US.utf8".
myerp.db_1 | The default database encoding has accordingly been set to "UTF8".
myerp.db_1 | The default text search configuration will be set to "English".
myerp.db_1 |
myerp.db_1 | Data page checksums are disabled.
myerp.db_1 |
myerp.db_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
myerp.db_1 | creating subdirectories ... ok
myerp.db_1 | selecting default max_connections ... 100
myerp.db_1 | selecting default shared_buffers ... 128MB
myerp.db_1 | selecting dynamic shared memory implementation ... posix
myerp.db_1 | creating configuration files ... ok
myerp.db_1 | running bootstrap script ... ok
myerp.db_1 | performing post-bootstrap initialization ... ok
myerp.db_1 | syncing data to disk ... ok
myerp.db_1 |
myerp.db_1 | Success. You can now start the database server using:
myerp.db_1 |
myerp.db_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
myerp.db_1 |
myerp.db_1 |
myerp.db_1 | WARNING: enabling "trust" authentication for local connections
myerp.db_1 | You can change this by editing pg_hba.conf or using the option -A, or
myerp.db_1 | --auth-local and --auth-host, the next time you run initdb.
myerp.db_1 | waiting for server to start....2018-09-24 14:53:52.027 UTC [40] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
myerp.db_1 | 2018-09-24 14:53:52.061 UTC [41] LOG: database system was shut down at 2018-09-24 14:53:51 UTC
myerp.db_1 | 2018-09-24 14:53:52.069 UTC [40] LOG: database system is ready to accept connections
myerp.db_1 | done
myerp.db_1 | server started
myerp.db_1 | CREATE DATABASE
myerp.db_1 |
myerp.db_1 |
myerp.db_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
myerp.db_1 |
myerp.db_1 | waiting for server to shut down....2018-09-24 14:53:52.541 UTC [40] LOG: received fast shutdown request
myerp.db_1 | 2018-09-24 14:53:52.552 UTC [40] LOG: aborting any active transactions
myerp.db_1 | 2018-09-24 14:53:52.555 UTC [40] LOG: worker process: logical replication launcher (PID 47) exited with exit code 1
myerp.db_1 | 2018-09-24 14:53:52.559 UTC [42] LOG: shutting down
myerp.db_1 | 2018-09-24 14:53:52.588 UTC [40] LOG: database system is shut down
myerp.db_1 | done
myerp.db_1 | server stopped
myerp.db_1 |
myerp.db_1 | PostgreSQL init process complete; ready for start up.
myerp.db_1 |
myerp.db_1 | 2018-09-24 14:53:52.657 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
myerp.db_1 | 2018-09-24 14:53:52.657 UTC [1] LOG: listening on IPv6 address "::", port 5432
myerp.db_1 | 2018-09-24 14:53:52.667 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
myerp.db_1 | 2018-09-24 14:53:52.696 UTC [58] LOG: database system was shut down at 2018-09-24 14:53:52 UTC
myerp.db_1 | 2018-09-24 14:53:52.705 UTC [1] LOG: database system is ready to accept connections
myerp.db_1 | 2018-09-24 14:57:16.551 UTC [68] ERROR: relation "myerp.sequence_ecriture_comptable" does not exist at character 46
myerp.db_1 | 2018-09-24 14:57:16.551 UTC [68] STATEMENT:
myerp.db_1 | SELECT derniere_valeur FROM myerp.sequence_ecriture_comptable
myerp.db_1 | WHERE annee = $1 AND journal_code = $2
Can you help me please?
Thank you
I was getting the same error:
psql:/docker-entrypoint-initdb.d/init2.sql:20: ERROR: relation "tablename" does not exist
It can be solved by adding the following line at the very beginning of every
docker-entrypoint-initdb.d/* sql file:
\c dbname;