MM-41752: Batch update mention increment (#19596)

Previously, we were incrementing mentions one-by-one
all concurrently in an unbounded fashion.

This would cause a big spike in memory usage if there
were an `@all` mention in a large channel.

We fix this by changing the SQL query to take all userIDs
at once.

https://mattermost.atlassian.net/browse/MM-41752

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Agniva De Sarker
2022-03-03 08:50:19 +05:30
коммит произвёл GitHub
родитель dd100a3a69
Коммит 768fe43d3a
10 изменённых файлов: 69 добавлений и 61 удалений

Просмотреть файл

@@ -1975,11 +1975,11 @@ func (s *RetryLayerChannelStore) GroupSyncedChannelCount() (int64, error) {
}
func (s *RetryLayerChannelStore) IncrementMentionCount(channelID string, userID string, isRoot bool) error {
func (s *RetryLayerChannelStore) IncrementMentionCount(channelID string, userIDs []string, isRoot bool) error {
tries := 0
for {
err := s.ChannelStore.IncrementMentionCount(channelID, userID, isRoot)
err := s.ChannelStore.IncrementMentionCount(channelID, userIDs, isRoot)
if err == nil {
return nil
}