mesh-delivery-builder: an older revision's entry stays behind the newest heard (H-A-557, review r1)
An entry heard of an older module graph revision than the one the picture holds for its branch neither replaces it as the newest nor withdraws its build; it is said in the journal. The test hears revision 453's entry with its build running, then 452's, then 454's. Builds: design 47 H2 H-A-557
This commit is contained in:
@@ -300,13 +300,18 @@ func (b *Builder) take(ctx context.Context, o Origin, key string, m meshcatalog.
|
||||
hk := o.Branch + "\x00" + key
|
||||
old, had := b.heard[hk]
|
||||
oldAt := b.heardAt[hk]
|
||||
b.heard[hk], b.heardAt[hk] = m, o
|
||||
if o.First {
|
||||
b.known[key] = m
|
||||
// An entry of an older module graph revision than the one heard before it neither replaces it as the branch's newest nor
|
||||
// withdraws its build (H-A-557): it is still built for the older revision's pipeline.
|
||||
before, known := newerRevision(oldAt, o)
|
||||
older := had && known && before
|
||||
if !older {
|
||||
b.heard[hk], b.heardAt[hk] = m, o
|
||||
if o.First {
|
||||
b.known[key] = m
|
||||
}
|
||||
}
|
||||
var superseded context.CancelCauseFunc
|
||||
// Only an entry of a newer module graph revision withdraws the build of the one heard before it (H-A-557).
|
||||
if newer, known := newerRevision(o, oldAt); had && old.Fp2 != "" && old.Fp2 != m.Fp2 && (newer || !known) {
|
||||
if had && !older && old.Fp2 != "" && old.Fp2 != m.Fp2 {
|
||||
if ok, err := builds.BuilderBuildKey(key, old.Fp2); err == nil {
|
||||
superseded = b.builds[ok]
|
||||
}
|
||||
@@ -318,6 +323,10 @@ func (b *Builder) take(ctx context.Context, o Origin, key string, m meshcatalog.
|
||||
b.edges[bk] = e
|
||||
}
|
||||
b.mu.Unlock()
|
||||
if older {
|
||||
b.logf("%s at %s (revision %d, source %d): older than the entry heard at %s (revision %d, source %d): it stays the newest (H-A-557)",
|
||||
key, m.Fp2, o.Revision, o.Source, old.Fp2, oldAt.Revision, oldAt.Source)
|
||||
}
|
||||
b.pictureMoved()
|
||||
if superseded != nil {
|
||||
// A newer fingerprint of the module: the build of the older one in flight is taken out, and its asks are withdrawn
|
||||
|
||||
@@ -186,6 +186,7 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T)
|
||||
t.Run("H-A-155: past the bound the ask fails naming its revision, and nothing is built", aStepAskPastItsRevisionBoundFails)
|
||||
t.Run("H-A-205: an ask of a revision below the picture's newest is read by number and built", anOlderKeptRevisionIsReadByNumber)
|
||||
t.Run("H-A-557: an entry the picture heard of an older revision supersedes no ask of a newer one", anOlderHeardEntrySupersedesNoNewerAsk)
|
||||
t.Run("H-A-557: an entry heard of an older revision withdraws no running build of a newer one", anOlderHeardEntryWithdrawsNoNewerBuild)
|
||||
t.Run("H-A-162: a revision held that changes no entry wakes the ask", aRevisionHeldWakesTheAsk)
|
||||
t.Run("H-A-165: a package with no pin waits for its release and is built with it", aPackageWithNoPinWaitsForItsRelease)
|
||||
t.Run("H-A-165: past its bound a package with no release fails the step", aPackageWithNoReleaseFailsPastItsBound)
|
||||
@@ -615,6 +616,35 @@ func anOlderHeardEntrySupersedesNoNewerAsk(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// H-A-557 (review round 1): the entry of m at revision 453 (fp1) is heard and its build runs; an entry of revision 452 (fp2)
|
||||
// heard after it is older and withdraws nothing; one of revision 454 withdraws it, naming the newer fingerprint.
|
||||
func anOlderHeardEntryWithdrawsNoNewerBuild(t *testing.T) {
|
||||
var held atomic.Int64
|
||||
held.Store(141)
|
||||
r, _, entry := revisionRig(t, &held, make(chan struct{}, 1))
|
||||
r.b.FirstBranch = func(branch, module string) bool { return branch == "main" && module == "m" }
|
||||
r.b.Entry(context.Background(), Origin{Branch: "main", Source: 141, Revision: 453, First: true}, entry)
|
||||
r.b.Wait()
|
||||
var withdrawn []error
|
||||
r.b.mu.Lock()
|
||||
r.b.builds[r.key] = func(cause error) { withdrawn = append(withdrawn, cause) } // fp1's build runs
|
||||
r.b.mu.Unlock()
|
||||
older := entry
|
||||
older.Fp = fp2
|
||||
r.b.Entry(context.Background(), Origin{Branch: "main", Source: 140, Revision: 452, First: true}, older)
|
||||
r.b.Wait()
|
||||
if len(withdrawn) != 0 {
|
||||
t.Fatalf("an entry of revision 452 withdrew the build of revision 453's fingerprint: %v", withdrawn)
|
||||
}
|
||||
newer := entry
|
||||
newer.Fp = "src2:" + hex64('e')
|
||||
r.b.Entry(context.Background(), Origin{Branch: "main", Source: 142, Revision: 454, First: true}, newer)
|
||||
r.b.Wait()
|
||||
if len(withdrawn) != 1 || !strings.Contains(withdrawn[0].Error(), newer.Fp) {
|
||||
t.Errorf("after revision 454's entry: withdrawn %v; want fp1's build withdrawn once, naming %s", withdrawn, newer.Fp)
|
||||
}
|
||||
}
|
||||
|
||||
func aStepAskPastItsRevisionBoundFails(t *testing.T) {
|
||||
var held atomic.Int64
|
||||
held.Store(40)
|
||||
|
||||
Reference in New Issue
Block a user