Fix racy test TestViewChannelCollapsedThreadsTurnedOff (#18233)
The followers slice was being read before all goroutines finished. We fix this by waiting till all goroutines are done before reading from the slice. ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
74518ea165
Коммит
d5160ab59d
@@ -287,6 +287,32 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
updateMentionChans = append(updateMentionChans, umc)
|
||||
}
|
||||
|
||||
// Make sure all mention updates are complete to prevent race conditions.
|
||||
// Probably better to batch these DB updates in the future
|
||||
// MUST be completed before push notifications send
|
||||
for _, umc := range updateMentionChans {
|
||||
if err := <-umc; err != nil {
|
||||
mlog.Warn(
|
||||
"Failed to update mention count",
|
||||
mlog.String("post_id", post.Id),
|
||||
mlog.String("channel_id", post.ChannelId),
|
||||
mlog.Err(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Log the problems that might have occurred while auto following the thread
|
||||
for _, mac := range mentionAutofollowChans {
|
||||
if err := <-mac; err != nil {
|
||||
mlog.Warn(
|
||||
"Failed to update thread autofollow from mention",
|
||||
mlog.String("post_id", post.Id),
|
||||
mlog.String("channel_id", post.ChannelId),
|
||||
mlog.Err(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
notificationsForCRT := &CRTNotifiers{}
|
||||
if isCRTAllowed && post.RootId != "" {
|
||||
for _, uid := range followers {
|
||||
@@ -376,31 +402,6 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure all mention updates are complete to prevent race
|
||||
// Probably better to batch these DB updates in the future
|
||||
// MUST be completed before push notifications send
|
||||
for _, umc := range updateMentionChans {
|
||||
if err := <-umc; err != nil {
|
||||
mlog.Warn(
|
||||
"Failed to update mention count",
|
||||
mlog.String("post_id", post.Id),
|
||||
mlog.String("channel_id", post.ChannelId),
|
||||
mlog.Err(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Log the problems that might have occurred while auto following the thread
|
||||
for _, mac := range mentionAutofollowChans {
|
||||
if err := <-mac; err != nil {
|
||||
mlog.Warn(
|
||||
"Failed to update thread autofollow from mention",
|
||||
mlog.String("post_id", post.Id),
|
||||
mlog.String("channel_id", post.ChannelId),
|
||||
mlog.Err(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
sendPushNotifications := false
|
||||
if *a.Config().EmailSettings.SendPushNotifications {
|
||||
pushServer := *a.Config().EmailSettings.PushNotificationServer
|
||||
|
||||
Ссылка в новой задаче
Block a user