Mattermost, Inc.

[SOLVED] 502 Bad Gateway after 4.4.5 Update, Failed To Create Index Error in Mattermost

Hi all,

I upgraded Mattermost to 4.4.5 (via GitLab 10.3.3’s Omnibus Upgrade) and now the Mattermost web interface is returning a 502 Bad Gateway error.

I’m looking in the Mattermost logs and see this repeatedly:
[2018/01/10 15:38:51 MST] [CRIT] Failed to create index pq: relation “idx_posts_channel_id_delete_at_create_at” does not exist
[2018/01/10 15:38:51 MST] [CRIT] Failed to create index pq: canceling statement due to user request

My guess is a database update failed at some point? Any ideas on what I can do to fix the underlying issue?

For anyone referencing this, I was able to fix this. I logged into the Mattermost database (sudo gitlab-psql -d mattermost_production) and ran the following query to create the missing index:

CREATE INDEX idx_posts_channel_id_delete_at_create_at ON Posts (ChannelId,DeleteAt,CreateAt)

1 Like

Hello, I have a similar error:

Failed to create index pq: relation “idx_channel_search_txt” does not exist, pq: invalid multibyte character for locale

Where did you find the query to run?

In the Mattermost repository. For your index, I found it here:

So your index you need to create is likely:
CREATE INDEX idx_channel_search_txt ON Channels (Name, DisplayName, Purpose)

Thank you for the quick reply!!

In my case, the error was actually the symptom for another issue. Here are the details if it can help someone else: https://github.com/mattermost/mattermost-server/issues/9409