Update failed (postgresql)

Doing the newest update (incl. postgresql) result in an error:

root@community:/var/discourse# ./launcher rebuild app

Ensuring launcher is up to date

Fetching origin

Launcher is up-to-date

Stopping old container

+ /usr/bin/docker stop -t 60 app

app

cd /pups && git pull && /pups/bin/pups --stdin

Already up to date.

I, [2020-06-03T15:38:58.391364 #1] INFO -- : Loading --stdin

I, [2020-06-03T15:38:58.398128 #1] INFO -- : > locale-gen $LANG && update-locale

I, [2020-06-03T15:38:58.731357 #1] INFO -- : Generating locales (this might take a while)...

Generation complete.

I, [2020-06-03T15:38:58.731849 #1] INFO -- : > mkdir -p /shared/postgres_run

I, [2020-06-03T15:38:58.751775 #1] INFO -- : 

I, [2020-06-03T15:38:58.756078 #1] INFO -- : > chown postgres:postgres /shared/postgres_run

I, [2020-06-03T15:38:58.765806 #1] INFO -- : 

I, [2020-06-03T15:38:58.766148 #1] INFO -- : > chmod 775 /shared/postgres_run

I, [2020-06-03T15:38:58.767966 #1] INFO -- : 

I, [2020-06-03T15:38:58.768305 #1] INFO -- : > rm -fr /var/run/postgresql

I, [2020-06-03T15:38:58.770246 #1] INFO -- : 

I, [2020-06-03T15:38:58.770626 #1] INFO -- : > ln -s /shared/postgres_run /var/run/postgresql

I, [2020-06-03T15:38:58.785523 #1] INFO -- : 

I, [2020-06-03T15:38:58.785863 #1] INFO -- : > socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1

2020/06/03 15:38:58 socat[26] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory

I, [2020-06-03T15:38:58.911895 #1] INFO -- : 

I, [2020-06-03T15:38:58.912203 #1] INFO -- : > rm -fr /shared/postgres_run/.s*

I, [2020-06-03T15:38:58.914376 #1] INFO -- : 

I, [2020-06-03T15:38:58.914625 #1] INFO -- : > rm -fr /shared/postgres_run/*.pid

I, [2020-06-03T15:38:58.916280 #1] INFO -- : 

I, [2020-06-03T15:38:58.916527 #1] INFO -- : > mkdir -p /shared/postgres_run/12-main.pg_stat_tmp

I, [2020-06-03T15:38:58.917967 #1] INFO -- : 

I, [2020-06-03T15:38:58.918303 #1] INFO -- : > chown postgres:postgres /shared/postgres_run/12-main.pg_stat_tmp

I, [2020-06-03T15:38:58.919709 #1] INFO -- : 

I, [2020-06-03T15:38:58.925728 #1] INFO -- : File > /etc/service/postgres/run chmod: +x chown: 

I, [2020-06-03T15:38:58.928444 #1] INFO -- : File > /etc/service/postgres/log/run chmod: +x chown: 

I, [2020-06-03T15:38:58.931357 #1] INFO -- : File > /etc/runit/3.d/99-postgres chmod: +x chown: 

I, [2020-06-03T15:38:58.934190 #1] INFO -- : File > /root/upgrade_postgres chmod: +x chown: 

I, [2020-06-03T15:38:58.934528 #1] INFO -- : > chown -R root /var/lib/postgresql/12/main

I, [2020-06-03T15:40:44.749613 #1] INFO -- : 

I, [2020-06-03T15:40:44.750250 #1] INFO -- : > [ ! -e /shared/postgres_data ] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -E -u postgres /usr/lib/postgresql/12/bin/initdb -D /shared/postgres_data || exit 0

I, [2020-06-03T15:40:44.751653 #1] INFO -- : 

I, [2020-06-03T15:40:44.751914 #1] INFO -- : > chown -R postgres:postgres /shared/postgres_data

I, [2020-06-03T15:40:47.940064 #1] INFO -- : 

I, [2020-06-03T15:40:47.940713 #1] INFO -- : > chown -R postgres:postgres /var/run/postgresql

I, [2020-06-03T15:40:47.942521 #1] INFO -- : 

I, [2020-06-03T15:40:47.942924 #1] INFO -- : > /root/upgrade_postgres

initdb: 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.

debconf: delaying package configuration, since apt-utils is not installed

I, [2020-06-03T15:42:45.495966 #1] INFO -- : Upgrading PostgreSQL from version 10 to 12

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.UTF-8".

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 /shared/postgres_data_new ... ok

creating subdirectories ... ok

selecting dynamic shared memory implementation ... posix

selecting default max_connections ... 100

selecting default shared_buffers ... 128MB

selecting default time zone ... Etc/UTC

creating configuration files ... ok

running bootstrap script ... ok

performing post-bootstrap initialization ... ok

syncing data to disk ... ok

Success. You can now start the database server using:

/usr/lib/postgresql/12/bin/pg_ctl -D /shared/postgres_data_new -l logfile start

Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]

Hit:2 http://deb.debian.org/debian buster InRelease

Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]

Get:4 https://deb.nodesource.com/node_10.x buster InRelease [4,584 B]

Get:5 http://apt.postgresql.org/pub/repos/apt buster-pgdg InRelease [84.6 kB]

Get:6 http://security.debian.org/debian-security buster/updates/main amd64 Packages [201 kB]

Get:7 https://deb.nodesource.com/node_10.x buster/main amd64 Packages [768 B]

Get:8 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main amd64 Packages [171 kB]

Fetched 577 kB in 1s (698 kB/s)

Reading package lists...

Reading package lists...

Building dependency tree...

Reading state information...

The following additional packages will be installed:

postgresql-client-10

Suggested packages:

postgresql-doc-10

The following NEW packages will be installed:

postgresql-10 postgresql-client-10

0 upgraded, 2 newly installed, 0 to remove and 10 not upgraded.

Need to get 6,390 kB of archives.

After this operation, 30.6 MB of additional disk space will be used.

Get:1 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main amd64 postgresql-client-10 amd64 10.13-1.pgdg100+1 [1,428 kB]

Get:2 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main amd64 postgresql-10 amd64 10.13-1.pgdg100+1 [4,961 kB]

Fetched 6,390 kB in 0s (38.2 MB/s)

Selecting previously unselected package postgresql-client-10.

(Reading database ... 43929 files and directories currently installed.)

Preparing to unpack .../postgresql-client-10_10.13-1.pgdg100+1_amd64.deb ...

Unpacking postgresql-client-10 (10.13-1.pgdg100+1) ...

Selecting previously unselected package postgresql-10.

Preparing to unpack .../postgresql-10_10.13-1.pgdg100+1_amd64.deb ...

Unpacking postgresql-10 (10.13-1.pgdg100+1) ...

Setting up postgresql-client-10 (10.13-1.pgdg100+1) ...

update-alternatives: warning: forcing reinstallation of alternative /usr/share/postgresql/12/man/man1/psql.1.gz because link group psql.1.gz is broken

Setting up postgresql-10 (10.13-1.pgdg100+1) ...

Creating new PostgreSQL cluster 10/main ...

/usr/lib/postgresql/10/bin/initdb -D /var/lib/postgresql/10/main --auth-local peer --auth-host md5

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 "C.UTF-8".

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/10/main ... ok

creating subdirectories ... ok

selecting default max_connections ... 100

selecting default shared_buffers ... 128MB

selecting default timezone ... Etc/UTC

selecting dynamic shared memory implementation ... posix

creating configuration files ... ok

running bootstrap script ... ok

performing post-bootstrap initialization ... ok

syncing data to disk ... ok

Success. You can now start the database server using:

pg_ctlcluster 10 main start

Warning: The selected stats_temp_directory /var/run/postgresql/10-main.pg_stat_tmp

is not writable for the cluster owner. Not adding this setting in

postgresql.conf.

Ver Cluster Port Status Owner Data directory Log file

10 main 5433 down postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log

update-alternatives: warning: forcing reinstallation of alternative /usr/share/postgresql/12/man/man1/postmaster.1.gz because link group postmaster.1.gz is broken

invoke-rc.d: could not determine current runlevel

invoke-rc.d: policy-rc.d denied execution of start.

Processing triggers for postgresql-common (213.pgdg100+1) ...

Building PostgreSQL dictionaries from installed myspell/hunspell packages...

Removing obsolete dictionary files:

Stopping PostgreSQL 10 database server: main.

Stopping PostgreSQL 12 database server: main.

Performing Consistency Checks

-----------------------------

Checking cluster versions ok

The source cluster was not shut down cleanly.

Failure, exiting

-------------------------------------------------------------------------------------

UPGRADE OF POSTGRES FAILED

Please visit https://meta.discourse.org/t/postgresql-12-update/151236 for support

You can run ./launcher start app to restart your app in the meanwhile

FAILED

--------------------

Pups::ExecError: /root/upgrade_postgres failed with return #<Process::Status: pid 45 exit 1>

Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'

exec failed with the params "/root/upgrade_postgres"

674042fc06e2af0c08a0a09c46406a0b18b1f08b9140e037fffe1053188bd1c0

** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

./discourse-doctor may help diagnose the problem.

root@community:/var/discourse#

Any idea why?

1 Like

Did you review this post?

Yes, i did it before. We couldnt get the update running.

Read the entire faq section here:

1 Like

Already tried the workaround but it did not work.

1 Like

The log is full of:

2020-06-03 16:01:21.074 UTC [693] FATAL: data directory “/shared/postgres_data” has wrong ownership
2020-06-03 16:01:21.074 UTC [693] HINT: The server must be started by the user that owns the data directory.

3 Likes

After loggin into the container i tried to shutdown it by myself:

root@community-app:/etc/postgresql/10/main# service postgresql stop

[FAIL] Stopping PostgreSQL 10 database server: main[…] Error: Config owner (postgres:106) and data owner (Debian-exim:105) do not match, and config owner is not root … failed!

failed!

3 Likes

Running chown -R postgres postgres_data

at /shared after entering the docker container has fixed it.

4 Likes