mirror of
https://github.com/mattermost/mattermost.git
synced 2026-05-28 04:35:04 -04:00
MM-52009: Fix hub data race (#22925)
After the monorepo integration, the boards product was started before we started the hub. This led to a data race where the GetHubForUserId was actually called before the hub was initialized. To fix this we initialize the platform first, and then the products. https://mattermost.atlassian.net/browse/MM-52009 ```release-note NONE ```
This commit is contained in:
parent
35d3e3e91e
commit
574e61bcc1
1 changed files with 11 additions and 7 deletions
|
|
@ -260,8 +260,17 @@ func NewServer(options ...Option) (*Server, error) {
|
|||
product.CommandKey: app,
|
||||
}
|
||||
|
||||
// Step 4: Initialize products.
|
||||
// Depends on s.httpService.
|
||||
// It is important to initialize the hub only after the global logger is set
|
||||
// to avoid race conditions while logging from inside the hub.
|
||||
// Step 4: Start platform
|
||||
s.platform.Start()
|
||||
|
||||
// NOTE: There should be no call to App.Srv().Channels() before step 5 is done
|
||||
// otherwise it will throw a panic.
|
||||
|
||||
// Step 5: Initialize products.
|
||||
// Depends on s.httpService, and depends on the hub to be initialized.
|
||||
// Otherwise we run into race conditions.
|
||||
err = s.initializeProducts(product.GetProducts(), serviceMap)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to initialize products")
|
||||
|
|
@ -275,11 +284,6 @@ func NewServer(options ...Option) (*Server, error) {
|
|||
}
|
||||
app.ch = channelsWrapper.app.ch
|
||||
|
||||
// It is important to initialize the hub only after the global logger is set
|
||||
// to avoid race conditions while logging from inside the hub.
|
||||
// Step 5: Start hub in platform which the hub depends on s.Channels() (step 4)
|
||||
s.platform.Start()
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Everything below this is not order sensitive and safe to be moved around.
|
||||
// If you are adding a new field that is non-channels specific, please add
|
||||
|
|
|
|||
Loading…
Reference in a new issue