Site down after failed update: permission denied to create extension "unaccent"

Upgrading via web UI failed with this error:

INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
discourse@discourse ERROR:  permission denied to create extension "unaccent"
discourse@discourse HINT:  Must be superuser to create this extension.
discourse@discourse STATEMENT:  CREATE EXTENSION IF NOT EXISTS unaccent
rake aborted!
PG::InsufficientPrivilege: ERROR:  permission denied to create extension "unaccent"
HINT:  Must be superuser to create this extension.

A long time ago I edited my app.yml which might be causing the problem:

templates:
  # commented out to ix disk space issue
  #- "templates/postgres.template.yml"
  - "templates/postgres.10.template.yml"

I made this change a long time ago, so besides that comment, I don’t remember the situation.

I left that alone and tried reverting to the discourse version I had before getting the update error by editing the app.yml version to v2.8.0beta8 but that fails with

Pups::ExecError: cd /var/www/discourse && git checkout v2.8.0.beta8 failed with return #<Process::Status: pid 1843 exit 1>
Location of failure: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"code", "cmd"=>["git reset --hard", "git clean -f", "git remote set-branches --add origin main", "git remote set-branches origin $version", "git fetch --depth 1 origin $version", "git checkout $version", "mkdir -p tmp", "chown discourse:www-data tmp", "mkdir -p tmp/pids", "mkdir -p tmp/sockets", "touch tmp/.gitkeep", "mkdir -p                    /shared/log/rails", "bash -c \"touch -a           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr,sidekiq}.log\"", "bash -c \"ln    -s           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr,sidekiq}.log $home/log\"", "bash -c \"mkdir -p           /shared/{uploads,backups}\"", "bash -c \"ln    -s           /shared/{uploads,backups} $home/public\"", "bash -c \"mkdir -p           /shared/tmp/{backups,restores}\"", "bash -c \"ln    -s           /shared/tmp/{backups,restores} $home/tmp\"", "chown -R discourse:www-data /shared/log/rails /shared/uploads /shared/backups /shared/tmp", "find public/plugins/ -maxdepth 1 -xtype l -delete"]}
bootstrap failed with exit code 1
** 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.
5b66f706de1a3ce8d78f0ed886669095c1a356efd916cb2ae8b02171367b0a01

So I think I either need to upgrade postgres from 10, or downgrade discourse to 2.8.0beta8, both of which fail. What should I do?

How was this server installed?

Have you made any changes to the Postgres configuration?

If you’re still on Postgres 10 try adding this after the hooks: section in your app.yml:


after_postgres:
    - exec: su postgres -c 'psql discourse -c "create extension if not exists unaccent;"'

2 Likes

We moved away from PostgreSQL 10 back in 2020. I urge you to update as soon as possible.

3 Likes

Is there any guidance on how to do that? Is there more to it than reverting that app.yml line?

The link on my post is the guide on that, however we also moved to PostgreSQL 13 update so follow the new one.

4 Likes

This fixed it for me, and then I was able to upgrade postgres based on @Falco’s instructions.

4 Likes

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