Unable to send message to person that never chat with ( direct mesage)

This happns when we upgrade to 10.x versions
For troubleshooting questions, please post in the following format:

Summary
Unable to send direct message to person that you never chat with
Steps to reproduce
open direct message
Expected behavior
to open direct message
Observed behavior
Not opening direct message

This is erorr from debug log
caller=“web/context.go:124” path=/api/v4/channels/direct request_id=qwma99domf8z9qb1h6x83sq3xa ip_addr=XXXXXXXXX
user_id=sucysajxs3fgbfsssm63fdoikw method=POST err_where=createDirectChannelWithUser http_code=500 error=“createDirectChannelWithUser: Unable to save direct channel., save_channel: id=mrmxwym1xpfexgd9ksar6psf4c: pq: there is no unique or exclusion constraint matching the ON CONFLICT specification”

Hi zulus! Thanks for sharing the details. It seems like this error could be related to database constraints during the direct message creation process. I recommend checking out this guide on troubleshooting common Mattermost issues to see if it helps. If the issue persists, feel free to share more details, and we’ll do our best to assist!

Hello John
as what i see this is really database issue
also what i have notice is that some sequence or index is broken
so i think to dump-> drop-> restore database in order to recreate this sequence and index

STATEMENT: INSERT INTO Channels
(Id, CreateAt, UpdateAt, DeleteAt, TeamId, Type, DisplayName, Name, Header, Purpose, LastPostAt, TotalMsgCount, ExtraUpdateAt, CreatorId, SchemeId, GroupConstrained, Shared, TotalMsgCountRoot, LastRootPostAt)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19)
ON CONFLICT (TeamId, Name) DO NOTHING

after database update and backup and restore is still same issue

Just for update here
was not a problem with database
looks like there is some issue with 10.1.1 version
after downgrade to 9.11.3 everything was working fine
so i think this is some bug

Thank you for following up, @zulus! @matthewbirtch - Is this something we can create a Jira ticket for?

@john.combs we could, but I’m not sure we have enough information to file a ticket. @amy.blais is this possibly something you could help with?

1 Like

I do also have the same problem with version 10.2.0 and a postgres:16-alpine database when I try to chat with a user to whom I have never chat before.
Also creating a new chat with several users at once does create the same error message.
It did probably already exist with version 10.0.1 or 10.1.0 but I had not tried there to create a new direct message channel.

mattermost_db-1  | 2024-11-19 18:21:10.914 UTC [16236] ERROR:  there is no unique or exclusion constraint matching the ON CONFLICT specification
mattermost_db-1  | 2024-11-19 18:21:10.914 UTC [16236] STATEMENT:  INSERT INTO Channels
mattermost_db-1  |                      (Id, CreateAt, UpdateAt, DeleteAt, TeamId, Type, DisplayName, Name, Header, Purpose, LastPostAt, TotalMsgCount, ExtraUpdateAt, CreatorId, SchemeId, GroupConstrained, Shared, TotalMsgCountRoot, LastRootPostAt)
mattermost_db-1  |                      VALUES
mattermost_db-1  |                      ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19)
mattermost_db-1  |                      ON CONFLICT (TeamId, Name) DO NOTHING