Mattermost-server: ThreadMemberships warning in log on 5.29.0

Created on 16 Nov 2020  路  5Comments  路  Source: mattermost/mattermost-server

Summary

Warnings are showing up in our Mattermost v5.29.0 log about thread memberships

Steps to reproduce

With a PGSQL backing, have a user comment in a thread (my repro is to just reply to an existing post, which creates a new thread).

Expected behavior

No warning

Observed behavior (that appears unintentional)

The following log (example) appears in the server log:
{"level":"warn","ts":1605555785.367588,"caller":"app/notification.go:284","msg":"Failed to update thread autofollow from mention","post_id":"1yswr5sgjpy98qu5gmzyptefrh","channel_id":"n3hwq1qyepdg9kkx35ss8okrih","error":"SendNotifications: Failed to update thread membership for mentioned user, failed to save thread membership with postid=j3x31r79ybfm3qcyihe3o7bbsy userid=u63ytfmwmjfxjnubsthj5pxpnh: pq: duplicate key value violates unique constraint \"threadmemberships_pkey\""}

Possible fixes

Unclear. All the code responsible for this lives in store\sqlstore\thread_store.go, but it doesn't seem like it's doing anything out of the ordinary. I have verified by manually running the SQL query in question that the entries are there:

mattermost=# select * from mattermost.ThreadMemberships where UserId='u63ytfmwmjfxjnubsthj5pxpnh' and PostId='j3x31r79ybfm3qcyihe3o7bbsy';
           postid           |           userid           | following |  lastviewed   |  lastupdated
----------------------------+----------------------------+-----------+---------------+---------------
 j3x31r79ybfm3qcyihe3o7bbsy | u63ytfmwmjfxjnubsthj5pxpnh | t         | 1605555947171 | 1605555947171
(1 row)
Bug ReporOpen

Most helpful comment

All 5 comments

Just came here to say "me too".

Release 5.29.0, PostgreSQL backend, graceful upgrade from the previous version(s):

{"level":"warn","ts":1605645110.6566632,"caller":"sqlstore/upgrade.go:211","msg":"Attempting to upgrade the database schema version","current_version":"5.28.0","new_version":"5.28.1"}
{"level":"warn","ts":1605645110.6930423,"caller":"sqlstore/upgrade.go:206","msg":"The database schema version has been upgraded","version":"5.28.1"}
{"level":"warn","ts":1605645110.693489,"caller":"sqlstore/upgrade.go:211","msg":"Attempting to upgrade the database schema version","current_version":"5.28.1","new_version":"5.29.0"}
{"level":"warn","ts":1605645110.74935,"caller":"sqlstore/upgrade.go:206","msg":"The database schema version has been upgraded","version":"5.29.0"}

and same errors in the logs for the replied threads:

{"level":"warn","ts":1605645917.6955028,"caller":"app/notification.go:284","msg":"Failed to update thread autofollow from mention","post_id":"x684tmcxoffbtmwh5k5rkrmt7e","channel_id":"j6fke47xjjdi5rggigi1hgdzaw","error":"SendNotifications: Failed to update thread membership for mentioned user, failed to save thread membership with postid=qj38m94pd7dq7xgkuocuhrgyzr userid=tjps9rj79byktb7xtb4xxyrywo: pq: duplicate key value violates unique constraint \"threadmemberships_pkey\""}

@reflog Do you know if this is just an error in the logs or something more concerning?

@amyblais - this is just a warning, due to a small bug that is already being fixed in new thread-related PR. It's caused by having the same userId twice in a list. No functionality degradation should be expected from this.
@b-a-t @parnic-sks thanks for reporting, we are on it!

Closing as this was fixed in v5.29.1,

Was this page helpful?
0 / 5 - 0 ratings