Closed sanak closed 2 years ago
@strk Thanks for the comments.
The effects of the change are STILL a "reconnection", so why dropping the comment ? I'd keep the comment to make sure it doesn't break in the future.
Okay, sure. Sorry for dropping the comment... 🙇
Also, you did not specify WHY the \c reconnection failed for you (did it fail for you?). Asking an already running process to reconnect would be faster than quitting the process and starting a new one...
The reproducible step is a bit complex, but it is as follows.
feature/simplify-docker-settings
) on the PR (https://github.com/gtt-project/docker-gtt/pull/53)
git clone git@github.com:gtt-project/docker-gtt.git -b feature/simplify-docker-settings
cd docker-gtt
.env.example
to .env
, then execute docker-compose up
.
copy .env.example .env
docker-compose up
redmine_1 | Unknown database adapter `postgis` found in config/database.yml, use Gemfile.local to load your own database gems
redmine_1 | Your Gemfile lists the gem puma (>= 0) more than once.
redmine_1 | You should probably keep only one of them.
redmine_1 | Remove any duplicate entries and specify the gem only once.
redmine_1 | While it's not a problem now, it could cause errors if you change the version of one of them later.
redmine_1 | Your Gemfile lists the gem immutable-struct (>= 0) more than once.
redmine_1 | You should probably keep only one of them.
redmine_1 | Remove any duplicate entries and specify the gem only once.
redmine_1 | While it's not a problem now, it could cause errors if you change the version of one of them later.
redmine_1 | The Gemfile's dependencies are satisfied
redmine_1 | Unknown database adapter `postgis` found in config/database.yml, use Gemfile.local to load your own database gems
postgis_1 | The files belonging to this database system will be owned by user "postgres".
postgis_1 | This user must also own the server process.
postgis_1 |
postgis_1 | The database cluster will be initialized with locale "en_US.utf8".
postgis_1 | The default database encoding has accordingly been set to "UTF8".
postgis_1 | The default text search configuration will be set to "english".
postgis_1 |
postgis_1 | Data page checksums are disabled.
postgis_1 |
postgis_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgis_1 | creating subdirectories ... ok
postgis_1 | selecting dynamic shared memory implementation ... posix
postgis_1 | selecting default max_connections ... 100
postgis_1 | selecting default shared_buffers ... 128MB
postgis_1 | selecting default time zone ... Etc/UTC
postgis_1 | creating configuration files ... ok
postgis_1 | running bootstrap script ... ok
redmine_1 | Unknown database adapter `postgis` found in config/database.yml, use Gemfile.local to load your own database gems
redmine_1 | rake aborted!
redmine_1 | ActiveRecord::ConnectionNotEstablished: could not connect to server: Connection refused
redmine_1 | Is the server running on host "postgis" (172.24.0.2) and accepting
redmine_1 | TCP/IP connections on port 5432?
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/postgresql_adapter.rb:83:in `rescue in new_client'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client'
redmine_1 | /usr/local/bundle/gems/activerecord-postgis-adapter-7.1.1/lib/active_record/connection_adapters/postgis/create_connection.rb:41:in `postgis_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_handling.rb:283:in `connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <top (required)>'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/railties/databases.rake:90:in `each'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <top (required)>'
redmine_1 |
redmine_1 | Caused by:
redmine_1 | PG::ConnectionBad: could not connect to server: Connection refused
redmine_1 | Is the server running on host "postgis" (172.24.0.2) and accepting
redmine_1 | TCP/IP connections on port 5432?
redmine_1 | /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `initialize'
redmine_1 | /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `new'
redmine_1 | /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `connect'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in `new_client'
redmine_1 | /usr/local/bundle/gems/activerecord-postgis-adapter-7.1.1/lib/active_record/connection_adapters/postgis/create_connection.rb:41:in `postgis_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/connection_handling.rb:283:in `connection'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <top (required)>'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/railties/databases.rake:90:in `each'
redmine_1 | /usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <top (required)>'
redmine_1 | Tasks: TOP => db:migrate
redmine_1 | (See full trace by running task with --trace)
redmine_1 | W, [2022-06-06T14:17:28.623475 #10] WARN -- : Creating scope :system. Overwriting existing method Enumeration.system.
redmine_1 | W, [2022-06-06T14:17:28.657263 #10] WARN -- : Creating scope :sorted. Overwriting existing method User.sorted.
docker-gtt_redmine_1 exited with code 1
postgis_1 | performing post-bootstrap initialization ... ok
postgis_1 | syncing data to disk ... ok
postgis_1 |
postgis_1 | initdb: warning: enabling "trust" authentication for local connections
postgis_1 | You can change this by editing pg_hba.conf or using the option -A, or
postgis_1 | --auth-local and --auth-host, the next time you run initdb.
postgis_1 |
postgis_1 | Success. You can now start the database server using:
postgis_1 |
postgis_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
postgis_1 |
postgis_1 | waiting for server to start....2022-06-06 14:17:30.098 UTC [125] LOG: starting PostgreSQL 14.3 (Debian 14.3-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
postgis_1 | 2022-06-06 14:17:30.102 UTC [125] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgis_1 | 2022-06-06 14:17:30.122 UTC [129] LOG: database system was shut down at 2022-06-06 14:17:29 UTC
postgis_1 | 2022-06-06 14:17:30.136 UTC [125] LOG: database system is ready to accept connections
postgis_1 | done
postgis_1 | server started
postgis_1 | CREATE DATABASE
postgis_1 |
postgis_1 |
postgis_1 | /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/10_postgis.sh
postgis_1 | CREATE DATABASE
postgis_1 | Loading PostGIS extensions into template_postgis
postgis_1 | CREATE EXTENSION
postgis_1 | CREATE EXTENSION
postgis_1 | You are now connected to database "template_postgis" as user "gtt".
postgis_1 | CREATE EXTENSION
postgis_1 | CREATE EXTENSION
postgis_1 | Loading PostGIS extensions into gtt
postgis_1 | CREATE EXTENSION
postgis_1 | CREATE EXTENSION
postgis_1 | You are now connected to database "gtt" as user "gtt".
postgis_1 | CREATE EXTENSION
postgis_1 | CREATE EXTENSION
postgis_1 |
postgis_1 | 2022-06-06 14:17:42.134 UTC [125] LOG: received fast shutdown request
postgis_1 | 2022-06-06 14:17:42.135 UTC [125] LOG: aborting any active transactions
postgis_1 | waiting for server to shut down....2022-06-06 14:17:42.143 UTC [125] LOG: background worker "logical replication launcher" (PID 140) exited with exit code 1
postgis_1 | 2022-06-06 14:17:42.146 UTC [131] LOG: shutting down
postgis_1 | 2022-06-06 14:17:42.292 UTC [125] LOG: database system is shut down
postgis_1 | done
postgis_1 | server stopped
postgis_1 |
postgis_1 | PostgreSQL init process complete; ready for start up.
postgis_1 |
postgis_1 | 2022-06-06 14:17:42.437 UTC [1] LOG: starting PostgreSQL 14.3 (Debian 14.3-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
postgis_1 | 2022-06-06 14:17:42.440 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgis_1 | 2022-06-06 14:17:42.440 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgis_1 | 2022-06-06 14:17:42.443 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgis_1 | 2022-06-06 14:17:42.463 UTC [185] LOG: database system was shut down at 2022-06-06 14:17:42 UTC
postgis_1 | 2022-06-06 14:17:42.478 UTC [1] LOG: database system is ready to accept connections
docker-compose down -v
docker image ls
docker image rm (postgis/postgis:14-3.2 image id)
# Build postgis/postgis:14-3.2 docker image locally
docker-compose up
redmine_1 | Unknown database adapter `postgis` found in config/database.yml, use Gemfile.local to load your own database gems
redmine_1 | Your Gemfile lists the gem puma (>= 0) more than once.
redmine_1 | You should probably keep only one of them.
redmine_1 | Remove any duplicate entries and specify the gem only once.
redmine_1 | While it's not a problem now, it could cause errors if you change the version of one of them later.
redmine_1 | Your Gemfile lists the gem immutable-struct (>= 0) more than once.
redmine_1 | You should probably keep only one of them.
redmine_1 | Remove any duplicate entries and specify the gem only once.
redmine_1 | While it's not a problem now, it could cause errors if you change the version of one of them later.
redmine_1 | The Gemfile's dependencies are satisfied
postgis_1 | syncing data to disk ... initdb: warning: enabling "trust" authentication for local connections
postgis_1 | You can change this by editing pg_hba.conf or using the option -A, or
postgis_1 | --auth-local and --auth-host, the next time you run initdb.
postgis_1 | ok
postgis_1 |
postgis_1 |
postgis_1 | Success. You can now start the database server using:
postgis_1 |
postgis_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
postgis_1 |
postgis_1 | waiting for server to start....2022-06-06 14:23:34.812 UTC [49] LOG: starting PostgreSQL 14.3 (Debian 14.3-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
postgis_1 | 2022-06-06 14:23:34.814 UTC [49] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgis_1 | 2022-06-06 14:23:34.818 UTC [50] LOG: database system was shut down at 2022-06-06 14:23:34 UTC
postgis_1 | 2022-06-06 14:23:34.822 UTC [49] LOG: database system is ready to accept connections
redmine_1 | Unknown database adapter `postgis` found in config/database.yml, use Gemfile.local to load your own database gems
postgis_1 | done
postgis_1 | server started
postgis_1 | CREATE DATABASE
postgis_1 |
postgis_1 |
postgis_1 | /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/10_postgis.sh
postgis_1 | CREATE DATABASE
postgis_1 | Loading PostGIS extensions into template_postgis
postgis_1 | CREATE EXTENSION
postgis_1 | CREATE EXTENSION
postgis_1 | CREATE EXTENSION
postgis_1 | CREATE EXTENSION
postgis_1 | Loading PostGIS extensions into gtt
redmine_1 | Unknown database adapter `postgis` found in config/database.yml, use Gemfile.local to load your own database gems
postgis_1 | CREATE EXTENSION
postgis_1 | CREATE EXTENSION
postgis_1 | CREATE EXTENSION
postgis_1 | CREATE EXTENSION
postgis_1 |
postgis_1 | waiting for server to shut down...2022-06-06 14:23:36.315 UTC [49] LOG: received fast shutdown request
postgis_1 | .2022-06-06 14:23:36.316 UTC [49] LOG: aborting any active transactions
postgis_1 | 2022-06-06 14:23:36.319 UTC [49] LOG: background worker "logical replication launcher" (PID 56) exited with exit code 1
postgis_1 | 2022-06-06 14:23:36.320 UTC [51] LOG: shutting down
postgis_1 | 2022-06-06 14:23:36.421 UTC [49] LOG: database system is shut down
postgis_1 | done
postgis_1 | server stopped
postgis_1 |
postgis_1 | PostgreSQL init process complete; ready for start up.
postgis_1 |
postgis_1 | 2022-06-06 14:23:36.530 UTC [1] LOG: starting PostgreSQL 14.3 (Debian 14.3-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
postgis_1 | 2022-06-06 14:23:36.530 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgis_1 | 2022-06-06 14:23:36.530 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgis_1 | 2022-06-06 14:23:36.532 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgis_1 | 2022-06-06 14:23:36.535 UTC [74] LOG: database system was shut down at 2022-06-06 14:23:36 UTC
postgis_1 | 2022-06-06 14:23:36.539 UTC [1] LOG: database system is ready to accept connections
redmine_1 | W, [2022-06-06T14:23:37.508553 #11] WARN -- : Creating scope :system. Overwriting existing method Enumeration.system.
redmine_1 | W, [2022-06-06T14:23:37.538897 #11] WARN -- : Creating scope :sorted. Overwriting existing method User.sorted.
redmine_1 | I, [2022-06-06T14:23:37.807782 #11] INFO -- : Migrating to Setup (1)
redmine_1 | == 1 Setup: migrating =========================================================
redmine_1 | -- create_table("attachments", {:force=>true, :id=>:integer})
redmine_1 | -> 0.0049s
:
redmine_1 | Unknown database adapter `postgis` found in config/database.yml, use Gemfile.local to load your own database gems
redmine_1 | => Booting Puma
redmine_1 | => Rails 6.1.4.7 application starting in production
redmine_1 | => Run `bin/rails server --help` for more startup options
redmine_1 | W, [2022-06-06T14:23:42.871831 #1] WARN -- : Creating scope :system. Overwriting existing method Enumeration.system.
redmine_1 | W, [2022-06-06T14:23:42.892371 #1] WARN -- : Creating scope :sorted. Overwriting existing method User.sorted.
redmine_1 | W, [2022-06-06T14:23:43.090894 #1] WARN -- : Creating scope :sorted. Overwriting existing method Group.sorted.
redmine_1 | Puma starting in single mode...
redmine_1 | * Puma version: 5.6.4 (ruby 3.1.2-p20) ("Birdie's Version")
redmine_1 | * Min threads: 0
redmine_1 | * Max threads: 5
redmine_1 | * Environment: production
redmine_1 | * PID: 1
redmine_1 | * Listening on http://0.0.0.0:3000
redmine_1 | Use Ctrl-C to stop
Another solution is docker-compose.yml
side's workaround as I mentioned in #296, but it is not handy and needs to wait for last postgis_tiger_geocoder
extension which is not necessary in our use case.
docker-compose.yml
side workaround is possible by waiting for lastpostgis_tiger_geocoder
extension like as follows, but this is not handy.volumes: - postgis:/var/lib/postgresql/data + healthcheck: + test: "pg_isready && psql -c \"\\dx\" | grep postgis_tiger_geocoder" + interval: 10s + timeout: 2s + retries: 5 + start_period: 10s
redmine: : depends_on:
@sanak:
imho: there is a related upstream issue: https://github.com/docker-library/postgres/issues/146 and as I understand, the problem is a little complex.
the current upstream best practice : the best way to test if the container is "ready" is to connect to it using its external IP address (it does not listen externally until the initialization process is fully complete).
like - using the external IP ( -h
) everywhere : pg_isready -h $(hostname -i)
or psql -h postgres
or ....
I'm not understanding how this "waiting for service" is at all related
to using \c
in the SQL stream. The long explanation did not explain
why \c
could not be used.
@ImreSamu
Okay, thanks for the information.
I will try to use external IP in docker-gtt
- docker-compose.yml
side.
@strk
I'm not understanding how this "waiting for service" is at all related to using
\c
in the SQL stream. The long explanation did not explain why\c
could not be used.
Okay, sure.
I actually don't know why the error happen when using \c
, and investigating the cause may take a certain time, so I will try @ImreSamu's advice at first.
Sorry for bothering you.
@ImreSamu
Thanks!
Using external IP in docker-gtt
- docker-compose.yml
healthcheck solved the issue.
commit diff: https://github.com/gtt-project/docker-gtt/pull/53/commits/6bbff06f532efbb27fda79540526f6306ab1b0e0
I close this PR with issue #296.
Closes #296
@ImreSamu (CC: @strk) I create this PR with the following steps, so could you check this ?
Note that my environment is macOS Monterey M1 (Apple Silicon) with zsh, so I couldn't execute
make test
due to No.3 error.make update
to apply above changes to all.make test
with setting environment variables, but encounter the following bash error.Check whether search_path is still valid.
Check whether reconnecting is not happen. (Comparing with https://github.com/postgis/docker-postgis/pull/292#issue-1197169442 - debian log)