PostGIS 10.4 creation failing


#1

I’m trying to set up testing automation for a simple Rails app using postgres 10.3. I’ve configured my config.yml as follows…

# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
       - image: circleci/ruby:2.4.1-node-browsers

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
       - image: circleci/postgres:10.4-alpine-postgis
         environment:
           POSTGRES_USER: postgres
           POSTGRES_DB: sun-server_development

    working_directory: ~/repo

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "Gemfile.lock" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run:
          name: install dependencies
          command: |
            bundle install --jobs=4 --retry=3 --path vendor/bundle

      - save_cache:
          paths:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}

      # found in https://github.com/CircleCI-Public/circleci-demo-ruby-rails/blob/master/.circleci/config.yml
      # sgardn
      - run:
          name: Wait for DB
          command: dockerize -wait tcp://localhost:5432 -timeout 1m

      - run:
          name: Sleep more because CI isn't waiting for DB setup
          command: sleep 30

      # Database setup
      - run: bundle exec rake db:create
      - run: bundle exec rake db:schema:load

      # run tests!
      - run:
          name: run tests
          command: |
            mkdir /tmp/test-results
            TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

            bundle exec rspec --format progress \
                            --format RspecJunitFormatter \
                            --out /tmp/test-results/rspec.xml \
                            --format progress \
                            $TEST_FILES

      # collect reports
      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results
          destination: test-results

Which is pretty unsurprising. What is surprising is that the command to run db:create goes ahead and seems to run while the docker image for postgres is still trying to build. What gives? Why would any of the steps run while I’m still trying to set up the database? Here’s what I see from the feedback for the image building for postgres:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... sh: locale: not found
2018-07-24 20:49:01.391 UTC [79] WARNING:  no usable system locales were found
ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

****************************************************
WARNING: No password has been set for the database.
         This will allow anyone with access to the
         Postgres port to access your database. In
         Docker's default configuration, this is
         effectively any other container on the same
         system.

         Use "-e POSTGRES_PASSWORD=password" to set
         it in "docker run".
****************************************************
waiting for server to start....2018-07-24 20:49:03.900 UTC [92] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-07-24 20:49:03.909 UTC [93] LOG:  database system was shut down at 2018-07-24 20:49:01 UTC
2018-07-24 20:49:03.910 UTC [92] LOG:  database system is ready to accept connections
 done
server started
CREATE DATABASE

ALTER ROLE


/usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/postgis.sh
CREATE DATABASE
UPDATE 1
Loading PostGIS extensions into template_postgis
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION
Loading PostGIS extensions into sun-server_development
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION

waiting for server to shut down....2018-07-24 20:49:07.410 UTC [92] LOG:  received fast shutdown request
2018-07-24 20:49:07.410 UTC [92] LOG:  aborting any active transactions
2018-07-24 20:49:07.411 UTC [92] LOG:  worker process: logical replication launcher (PID 99) exited with exit code 1
2018-07-24 20:49:07.416 UTC [94] LOG:  shutting down
2018-07-24 20:49:07.439 UTC [92] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2018-07-24 20:49:07.515 UTC [25] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2018-07-24 20:49:07.515 UTC [25] LOG:  listening on IPv6 address "::", port 5432
2018-07-24 20:49:07.515 UTC [25] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-07-24 20:49:07.525 UTC [140] LOG:  database system was shut down at 2018-07-24 20:49:07 UTC
2018-07-24 20:49:07.526 UTC [25] LOG:  database system is ready to accept connections
2018-07-24 20:49:08.412 UTC [159] LOG:  incomplete startup packet

Job was canceled

This is what I see for the rake db:create command that comes later:

#!/bin/bash -eo pipefail
bundle exec rake db:create
could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

#2

I’m seeing this as well - looks like the container is being killed before the app even gets started for me:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /dev/shm/pgdata/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... sh: locale: not found
2018-09-11 20:40:57.384 UTC [50] WARNING:  no usable system locales were found
ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /dev/shm/pgdata/data -l logfile start

****************************************************
WARNING: No password has been set for the database.
         This will allow anyone with access to the
         Postgres port to access your database. In
         Docker's default configuration, this is
         effectively any other container on the same
         system.

         Use "-e POSTGRES_PASSWORD=password" to set
         it in "docker run".
****************************************************
waiting for server to start....2018-09-11 20:40:57.777 UTC [88] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-09-11 20:40:57.786 UTC [90] LOG:  database system was shut down at 2018-09-11 20:40:57 UTC
2018-09-11 20:40:57.787 UTC [88] LOG:  database system is ready to accept connections
 done
server started
CREATE DATABASE


/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

waiting for server to shut down....2018-09-11 20:40:58.092 UTC [88] LOG:  received fast shutdown request
2018-09-11 20:40:58.092 UTC [88] LOG:  aborting any active transactions
2018-09-11 20:40:58.092 UTC [88] LOG:  worker process: logical replication launcher (PID 96) exited with exit code 1
2018-09-11 20:40:58.092 UTC [91] LOG:  shutting down
2018-09-11 20:40:58.095 UTC [88] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2018-09-11 20:40:58.198 UTC [6] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2018-09-11 20:40:58.198 UTC [6] LOG:  listening on IPv6 address "::", port 5432
2018-09-11 20:40:58.199 UTC [6] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-09-11 20:40:58.208 UTC [121] LOG:  database system was shut down at 2018-09-11 20:40:58 UTC
2018-09-11 20:40:58.209 UTC [6] LOG:  database system is ready to accept connections
2018-09-11 20:41:05.448 UTC [141] FATAL:  role "root" does not exist
2018-09-11 20:41:05.450 UTC [142] FATAL:  role "root" does not exist

Job was canceled

#3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.