MM-55655: Fix unbounded concurrency in outgoing webhooks (#25511)
We were simply spawning goroutines within goroutines. For each post, we would spawn one goroutine per hook, and then one goroutine per callback URL within that hook. And to top it off, this whole thing was itself within a goroutine. To fix it, we remove the goroutine spawning at a per hook level. And then use a waitgroup to wait until all hooks from each callback URL is complete. While here, some other optimizations that we do: 1. We already had the channel object, but inspite of that, we were calling channel.get again in CreatePostMissingChannel. We just use CreatePost now and pass the channel. 2. We pre-compile the regex. 3. We store the http.Client in the server to reuse TCP connections. https://mattermost.atlassian.net/browse/MM-55655 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b946dad78d
Коммит
45ba1dc196
@@ -508,7 +508,7 @@ func (a *App) DoCommandRequest(cmd *model.Command, p url.Values) (*model.Command
|
||||
}
|
||||
|
||||
// Send the request
|
||||
resp, err := a.HTTPService().MakeClient(false).Do(req)
|
||||
resp, err := a.Srv().outgoingWebhookClient.Do(req)
|
||||
if err != nil {
|
||||
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]any{"Trigger": cmd.Trigger}, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user