Error when upgrading discourse from 1.7

Since I encountered encoding issues I skipped upgrading the DB so I used “templates/postgres.9.3.template.yml” instead of “templates/postgres.template.yml”. Now when I try to rebuild I get this:

The following packages will be REMOVED:
  postgresql-9.5 postgresql-client-9.5 postgresql-contrib-9.5
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
After this operation, 26.1 MB disk space will be freed.
(Reading database ... 34533 files and directories currently installed.)
Removing postgresql-contrib-9.5 (9.5.5-1.pgdg16.04+1) ...
update-alternatives: warning: forcing reinstallation of alternative /usr/share/postgresql/9.5/man/man1/postmaster.1.gz because link group postmaster.1.gz is broken
update-alternatives: error: error creating symbolic link '/usr/share/man/man1/postmaster.1.gz.dpkg-tmp': No such file or directory
dpkg: error processing package postgresql-contrib-9.5 (--remove):
 subprocess installed pre-removal script returned error exit status 2
dpkg: postgresql-9.5: dependency problems, but removing anyway as you requested:
 postgresql-contrib-9.5 depends on postgresql-9.5 (= 9.5.5-1.pgdg16.04+1).

Removing postgresql-9.5 (9.5.5-1.pgdg16.04+1) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of stop.
Removing postgresql-client-9.5 (9.5.5-1.pgdg16.04+1) ...
Processing triggers for postgresql-common (178.pgdg16.04+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Errors were encountered while processing:
 postgresql-contrib-9.5

FAILED
--------------------
Pups::ExecError: apt-get remove -y postgresql-9.5 postgresql-client-9.5 postgresql-contrib-9.5 failed with return #<Process::Status: pid 17 exit 100>
Location of failure: /pups/lib/pups/exec_command.rb:108:in `spawn'

So I tried to change the line back to “templates/postgres.template.yml” and try with that. However I see this error:

Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok

*failure*
Consult the last few lines of "pg_upgrade_server.log" for
the probable cause of the failure.

connection to database failed: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/lib/postgresql/.s.PGSQL.50432"?


could not connect to old postmaster started with the command:
"/usr/lib/postgresql/9.3/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/shared/postgres_data" -o "-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/postgresql'" start
Failure, exiting
-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES FAILED

You are going to need to export your data and import into a clean instance:

In containers/app.yml: Change "templates/postgres.template.yml" TO "templates/postgres.9.3.template.yml"

Run ./launcher rebuild app again
...
...

I tried to enter the docker container to see why the command failed. I run the /usr/lib/postgresql/9.3/bin/pg_ctl ... command manually, and I saw that the command (which, I think, starts up a new postgres 9.3 server) failed because there was already an instance of postgres 9.3 running. So I tried to stop that instance but, everytime I rebuild, postgres is automatically restarted.

So I tried to do systemctl disable postgresql (or update-rc.d postgresql disable) but it doesn’t work. It just says:

insserv: warning: current start runlevel(s) (empty) of script `postgresql' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `postgresql' overrides LSB defaults (0 1 6).

but on the next rebuild, postgres is running again.

I can’t get postgres to not run at startup… any ideas?

3 Likes

Do you have any recommendations here @falco? I know I skipped pg upgrade on a few older sites as well…

1 Like

The easiest way is to move/rename the shared folder, bootstrap a new site and then restore from last backup. Can you afford this disk space?

4 Likes

Thanks :slight_smile:

When I upload the backup file, I see it in the backup list, but the “restore” button is greyed out. What should I do?

EDIT: nevermind, I had to enable backup recovery from the admin settings.

4 Likes