Try the move once before serving and again while serving; read each commit's build once when moving assignments (issue 1095)
The first try of the move to the bus is made before the controller serves, and a failure of the kind that is tried again no longer holds the start: it is tried every half minute while the controller serves from the tables. Moving the assignments looked up the build of each commit by scanning the bucket of builds for each of them; it reads the builds once.
This commit is contained in:
@@ -248,24 +248,39 @@ func (i *Inventory) assignedWithSends(ctx context.Context) ([]chain.Assignment,
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// The build of each commit, read once: the newest successful build of the module at it.
|
||||
type at struct{ module, commit string }
|
||||
var all []Build
|
||||
if _, moved, err := i.ChainReads(ctx, KindBuilds); err != nil {
|
||||
return nil, err
|
||||
} else if moved {
|
||||
if all, err = chainBuilds(ctx, i.attached()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if all, err = i.allBuildRows(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newest := map[at]Build{}
|
||||
for _, b := range all {
|
||||
k := at{b.Module, b.Commit}
|
||||
if b.Failed != "" || b.Module == "" {
|
||||
continue
|
||||
}
|
||||
if had, has := newest[k]; !has || b.At.After(had.At) || (b.At.Equal(had.At) && b.ID > had.ID) {
|
||||
newest[k] = b
|
||||
}
|
||||
}
|
||||
for k := range out {
|
||||
if out[k].Commit == "" {
|
||||
continue
|
||||
}
|
||||
id, err := i.BuildOf(ctx, out[k].Module, out[k].Commit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if id == "" {
|
||||
b, found := newest[at{out[k].Module, out[k].Commit}]
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
out[k].Build = id
|
||||
if b, found, err := i.BuildByID(ctx, id); err != nil {
|
||||
return nil, err
|
||||
} else if found {
|
||||
if published := publishedOf(b.Made); published != nil {
|
||||
out[k].Artifact, out[k].Package = published.Artifact, published.Package
|
||||
}
|
||||
out[k].Build = b.ID
|
||||
if published := publishedOf(b.Made); published != nil {
|
||||
out[k].Artifact, out[k].Package = published.Artifact, published.Package
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
|
||||
Reference in New Issue
Block a user