Skip to content

Commit

Permalink
chore: fix panic from dependency creation race (#2233)
Browse files Browse the repository at this point in the history
This change fixes a bug where restored experiments would attempt to send an ExperimentCreated message to the hp importance actor prior to its creation, resulting in a panic from a send on a nil actor.
  • Loading branch information
stoksc authored Apr 15, 2021
1 parent 782d095 commit 8de19c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions master/internal/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,12 @@ func (m *Master) Run(ctx context.Context) error {

m.system.MustActorOf(actor.Addr("allocation-aggregator"), &allocationAggregator{db: m.db})

hpi, err := hpimportance.NewManager(m.db, m.system, m.config.HPImportance, m.config.Root)
if err != nil {
return err
}
m.hpImportance, _ = m.system.ActorOf(actor.Addr(hpimportance.RootAddr), hpi)

// Initialize the HTTP server and listen for incoming requests.
m.echo = echo.New()
m.echo.Use(middleware.Recover())
Expand Down Expand Up @@ -791,11 +797,5 @@ func (m *Master) Run(ctx context.Context) error {
log.Info("telemetry reporting is disabled")
}

hpi, err := hpimportance.NewManager(m.db, m.system, m.config.HPImportance, m.config.Root)
if err != nil {
return err
}
m.hpImportance, _ = m.system.ActorOf(actor.Addr(hpimportance.RootAddr), hpi)

return m.startServers(ctx, cert)
}
2 changes: 1 addition & 1 deletion master/internal/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ func (e *experiment) Receive(ctx *actor.Context) error {
e.restoreTrialsFromPriorOperations(ctx, e.searcher.TrialOperations)
} else {
e.processOperations(ctx, e.searcher.TrialOperations, nil)
ctx.Tell(e.hpImportance, hpimportance.ExperimentCreated{ID: e.ID})
}
ctx.Tell(e.hpImportance, hpimportance.ExperimentCreated{ID: e.ID})
// Since e.searcher.TrialOperations should have all trials that were previously
// allocated, we can stop trying to restore new trials after processing these.
e.restored = false
Expand Down

0 comments on commit 8de19c0

Please sign in to comment.