Updating from 5.39 to 6.0 through helm fails on Postgres

Summary
I get a fatal postgres error when trying to update the helm chart from 5.5.1 to 6.0.0

Steps to reproduce
Using postgres 12.7
Running the command

helm upgrade --install mattermost mattermost/mattermost-team-edition -n default -f helms/mattermost/values.production.yaml --version=6.0.0

Generates the following error

"level":"fatal","msg":"Failed to alter column type.","caller":"sqlstore/store.go:860","error":"pq: must be owner of table posts"

Originally it was running the 5.4.0 chart, upgrading to 5.5.0 then to 5.5.1 went without any problems.

I checked the user privileges :

SELECT grantee, privilege_type 
FROM information_schema.role_table_grants 
WHERE table_name='posts'

And it seems like the user has all the rights on the table :

gitlab,INSERT
gitlab,SELECT
gitlab,UPDATE
gitlab,DELETE
gitlab,TRUNCATE
gitlab,REFERENCES
gitlab,TRIGGER

However the user that connects to the database is not the owner of the table :

select * from pg_tables where tablename = 'posts';

I do not really know how this has happened. Currently the user used to connect to the database for mattermost is gitlab.

To now get this to work what would be the best way ?

  • Changing the user that connects to the database to gitlab_mattermost, in this case do I need to grant all the rights to that user ?
  • Changing the owner of the tables and the database to the gitlab user

I’m not great at PostGre so any help would be greatly appreciated.

Expected behavior
The update pod to succeed and have the new version running

Observed behavior
The update pod keeps restarting on the fatal postgres error

I also created a github issue for this and have looked around quite a bit but have not found any solutions yet.