Summary
We upgraded from 6.3.1
to ‘7.1.0’ yesterday.
We observe significant slowness in our Mattermost and a lot of log messages indicating problems with counting files and posts.
Steps to reproduce
Use 7.1.1 version, with PostgreSQL 13.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-12), 64-bit (Amazon RDS)
Expected behavior
Smooth work
Observed behavior
We observe huge noise in the logs with similar messages:
{"timestamp":"2022-08-12 11:24:06.467 Z","level":"error","msg":"Unable to get the file count for the channel","caller":"web/context.go:105","path":"/api/v4/channels/9c8ez3ag1jfitkefs6hu8gw3sh/stats","request_id":"z7xi6ac1bjbum8kswthj69hohe","ip_addr":"212.160.172.85","user_id":"7zjfgetha7r9m8bsgxsyt86tgc","method":"GET","err_where":"SqlChannelStore.GetFileCount","http_code":500,"err_details":"failed to count files with channelId=9c8ez3ag1jfitkefs6hu8gw3sh: pq: canceling statement due to user request"}
In postgres logs a lot of errors::
2022-08-12 11:48:18 UTC:192.168.122.58(43480):mattermost@mattermost:[26046]:ERROR: canceling statement due to user request
2022-08-12 11:48:18 UTC:192.168.122.58(43480):mattermost@mattermost:[26046]:STATEMENT:
SELECT
COUNT(*)
FROM
FileInfo
LEFT JOIN Posts as P ON FileInfo.PostId=P.Id
LEFT JOIN Channels as C on C.Id=P.ChannelId
WHERE
FileInfo.DeleteAt = 0
AND C.Id = $1
which probably relates to this part of the code: mattermost-server/channel_store.go at master · mattermost/mattermost-server · GitHub
We store our config in the database. SQL settings part:
"SqlSettings": {
"DriverName": "postgres",
"DataSource": "postgres://mattermost:pass@dbname.eu-central-1.rds.amazonaws.com:5432/mattermost?sslmode=disable\u0026connect_timeout=10",
"DataSourceReplicas": [],
"DataSourceSearchReplicas": [],
"MaxIdleConns": 20,
"ConnMaxLifetimeMilliseconds": 3600000,
"ConnMaxIdleTimeMilliseconds": 300000,
"MaxOpenConns": 300,
"Trace": false,
"AtRestEncryptKey": "redacted",
"QueryTimeout": 30,
"DisableDatabaseSearch": false,
"MigrationsStatementTimeoutSeconds": 100000,
"ReplicaLagSettings": []
}
Please advise how to fix it.