Update fails with error postgres already running stop container

I tried to update discourse from web admin first, which failed then I’m trying to do it from the command line and it is getting stuck at postgres already running…

I’ve digital ocean droplet with ubuntu.

I’ve read other threads where they said to reboot and try again. I’ve rebooted few times but still getting this error.

How to fix it?

cd /var/discourse; ./launcher rebuild app
x86_64 arch detected.
WARNING: containers/app.yml file is world-readable. You can secure this file by running: chmod o-rwx containers/app.yml
Ensuring launcher is up to date
Fetching origin
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Total 5 (delta 4), reused 5 (delta 4), pack-reused 0 (from 0)
Unpacking objects: 100% (5/5), 708 bytes | 354.00 KiB/s, done.
From https://github.com/discourse/discourse_docker
 * [new branch]      use_ruby_base_iamge -> origin/use_ruby_base_iamge
Launcher is up-to-date
2.0.20240825-0027: Pulling from discourse/base
Digest: sha256:6de68cb49198b5281f79ed9401b3fe818c854d220dcf0238549fe2f2adb19146
Status: Image is up to date for discourse/base:2.0.20240825-0027
docker.io/discourse/base:2.0.20240825-0027
/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
/usr/local/bin/pups --stdin
I, [2024-08-30T10:43:08.137867 #1]  INFO -- : Reading from stdin
I, [2024-08-30T10:43:08.153896 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown: 
I, [2024-08-30T10:43:08.158658 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown: 
I, [2024-08-30T10:43:08.163738 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown: 
I, [2024-08-30T10:43:08.168052 #1]  INFO -- : File > /root/install_postgres  chmod: +x  chown: 
I, [2024-08-30T10:43:08.172457 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown: 
I, [2024-08-30T10:43:08.174093 #1]  INFO -- : Replacing data_directory = '/var/lib/postgresql/13/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/13/main/postgresql.conf
I, [2024-08-30T10:43:08.175183 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/13/main/postgresql.conf
I, [2024-08-30T10:43:08.176038 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/13/main/postgresql.conf
I, [2024-08-30T10:43:08.176655 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/13/main/postgresql.conf
I, [2024-08-30T10:43:08.177311 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/13/main/postgresql.conf
I, [2024-08-30T10:43:08.177951 #1]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' in /etc/postgresql/13/main/postgresql.conf
I, [2024-08-30T10:43:08.178500 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/13/main/postgresql.conf
I, [2024-08-30T10:43:08.179353 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/13/main/postgresql.conf
I, [2024-08-30T10:43:08.179971 #1]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/13/main/postgresql.conf
I, [2024-08-30T10:43:08.180883 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/13/main/pg_hba.conf
I, [2024-08-30T10:43:08.181605 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/13/main/pg_hba.conf
I, [2024-08-30T10:43:08.182323 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*::1\/128.*$) with host all all ::/0 md5 in /etc/postgresql/13/main/pg_hba.conf
I, [2024-08-30T10:43:08.182939 #1]  INFO -- : > if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi

2024/08/30 10:43:08 socat[28] E connect(, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): Connection refused
I, [2024-08-30T10:43:08.270928 #1]  INFO -- : Generating locales (this might take a while)...
Generation complete.

I, [2024-08-30T10:43:08.271543 #1]  INFO -- : > HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main
I, [2024-08-30T10:43:08.272933 #1]  INFO -- : Terminating async processes
2024-08-30 10:43:08.352 UTC [30] LOG:  starting PostgreSQL 13.16 (Debian 13.16-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2024-08-30 10:43:08.355 UTC [30] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-08-30 10:43:08.356 UTC [30] LOG:  listening on IPv6 address "::", port 5432
2024-08-30 10:43:08.358 UTC [30] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-08-30 10:43:08.368 UTC [31] LOG:  database system was interrupted; last known up at 2024-08-30 10:27:21 UTC
2024-08-30 10:43:08.515 UTC [31] LOG:  database system was not properly shut down; automatic recovery in progress
2024-08-30 10:43:08.519 UTC [31] LOG:  redo starts at 4/6422E078
2024-08-30 10:43:08.519 UTC [31] LOG:  invalid record length at 4/6422E0B0: wanted 24, got 0
2024-08-30 10:43:08.520 UTC [31] LOG:  redo done at 4/6422E078
2024-08-30 10:43:08.536 UTC [30] LOG:  database system is ready to accept connections

Here’s what I recommend

3 Likes

I’ll close this one off to concentrate the discussion in one topic. :+1:

2 Likes