diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go index f905ede55..1c07f6844 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go @@ -199,7 +199,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { }{ {"an end naming no revision (H-A-508 as before)", 0, 116, "left"}, {"an older revision's entry", 116, 117, "again"}, - {"the same revision's entry", 117, 117, "again"}, + {"the same revision's entry, the builder's kept revision (H-A-563)", 117, 117, "left"}, {"a newer revision's entry the view does not hold yet", 120, 118, "held"}, {"a newer revision's entry the view holds", 120, 120, "left"}, } { @@ -208,8 +208,19 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { Movers: slices.Clone(movers[:2]), Steps: []seat.StepResult{step("a", seat.StepResultOutcomeRunning, "x1"), step("b", seat.StepResultOutcomeRunning, "x2")}}, rev: 1}} var put []Asked var journal []string + var waits []string // the waits said, by event and what they wait on (H-A-563) view := r.view - h := &Hearer{Store: store, Say: func(string, any) error { return nil }, Now: func() time.Time { return t0 }, + say := func(subject string, body any) error { + if w, ok := body.(seat.Wait); ok { + ev := seat.EventWaitHeld + if strings.Contains(subject, seat.EventWaitEnded) { + ev = seat.EventWaitEnded + } + waits = append(waits, ev+" "+w.Step+" "+w.On+" "+w.Module) + } + return nil + } + h := &Hearer{Store: store, Say: say, Now: func() time.Time { return t0 }, View: func(string) (Half, bool) { return Half{Revision: view, Source: view, Entries: map[string]catalog.CatalogEntry{"a": {Module: "a", Fp: "src2:a2"}}}, true }, @@ -245,6 +256,9 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { len(put) != 0 || p.Outcome != seat.PipelineOutcomeRunning { t.Fatalf("superseded %v, a's build %+v, put %+v; want the build waiting on the revision view for revision 120, nothing asked", p.Superseded, s, put) } + if want := []string{seat.EventWaitHeld + " build revision view a"}; !slices.Equal(waits, want) { + t.Errorf("waits said %q, want %q", waits, want) + } // The view's move to 119 holds it still; at 120 it is judged again and the mover moves out (H-A-562). view = 119 if moved := h.RevisionHeld("main"); len(moved) != 0 { @@ -257,6 +271,9 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { if p, _, _ := store.Get("main.117"); !left(p) || p.Steps[0].On != "" || p.Outcome != seat.PipelineOutcomeRunning { t.Errorf("after the view held 120: superseded %v, a's build %+v, pipeline %s; want a left, b still running", p.Superseded, p.Steps[0], p.Outcome) } + if want := []string{seat.EventWaitHeld + " build revision view a", seat.EventWaitEnded + " build revision view a"}; !slices.Equal(waits, want) { + t.Errorf("waits said %q, want %q", waits, want) + } } }) } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index b018c6dc9..a78936d96 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -347,13 +347,14 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s } // A build ended superseded is judged by the module graph revision of the entry that superseded it, never by the order // the builder heard entries in (H-A-555, H-A-561): one naming no revision (a builder before H-A-561) moves its mover out - // as before (H-A-508); one not newer than the pipeline's own is asked again at once; one newer that the runner's view - // does not hold yet holds the step waiting on the revision view (H-A-562); one newer and held moves the mover out. + // as before (H-A-508); one older than the pipeline's own is asked again at once; one of its own revision (the builder's + // kept-revision path) moves the mover out (H-A-563); one newer that the runner's view does not hold yet holds the step + // waiting on the revision view, said as a wait held (H-A-562, H-A-563); one newer and held moves the mover out. if supersededBuild(*s, ev.Outcome) && superseding > 0 { own := keyRevision(Begin{Revision: p.Revision, Source: p.Source}) switch { - case superseding <= own: - passed := fmt.Sprintf("the superseding entry's revision %d is not newer than the pipeline's %d", superseding, own) + case superseding < own: + passed := fmt.Sprintf("the superseding entry's revision %d is older than the pipeline's %d", superseding, own) old := s.Ask a, why := h.supersededAgain(&p, i, ev, passed, now) if a != nil { @@ -372,7 +373,7 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s } h.logf("%s: %s's build ended superseded (%s), passed over: %s; %s (H-A-555, H-A-561)", ev.Pipeline, s.Module, ev.Said, passed, why) ev.Outcome, ev.Said = nodebuildgo.StepEndedOutcomeCouldNotRun, why - case !h.viewHolds(p.Branch, superseding): + case superseding > own && !h.viewHolds(p.Branch, superseding): old := s.Ask s.Outcome, s.On, s.Revision, s.Node, s.Why = seat.StepResultOutcomeWaiting, seat.WaitOnRevisionView, superseding, node, ev.Said if _, err := h.Store.Update(ev.Pipeline, p, rev); errors.Is(err, ErrChanged) { @@ -383,6 +384,9 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s unmarkAsk(h.Clock, old, h.logf) h.logf("%s: %s's build ended superseded (%s) by an entry of revision %d, which the runner's view of %s does not hold yet: the step waits on the revision view (H-A-561, H-A-562)", ev.Pipeline, s.Module, ev.Said, superseding, p.Branch) + if err := h.say(seat.EventWaitHeld, p, s); err != nil { + return p, fmt.Errorf("pipeline %s's %s waits on the revision view but %s is not said: %w", ev.Pipeline, s.Module, seat.EventWaitHeld, err) + } return p, nil } } @@ -735,6 +739,9 @@ func (h *Hearer) say(event string, p seat.Pipeline, step *seat.StepResult) error if step != nil { m, _ := MoverOf(p, step.Module) w.Module, w.Commit, w.Fingerprint, w.Step, w.Ask = m.Module, m.Commit, m.Fingerprint, step.Step, step.Ask + if step.On == seat.WaitOnRevisionView { // a build waiting for the revision that superseded it (H-A-563) + w.On = step.On + } } return h.Say(runnerclient.RevisionSubject(event, p.Branch, subjectRevision(p)), w) } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go b/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go index c86353083..f2c7858e9 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go @@ -395,12 +395,15 @@ func (h *Hearer) revisionHeldOne(key string, held int64) bool { } now := h.now() var ended []int - var leave, drop []seat.StepResult + var leave, drop, waited []seat.StepResult for i := range p.Steps { st := &p.Steps[i] if !slices.Contains(moved, st.Module) || (!open(*st) && st.Outcome != seat.StepResultOutcomeWaiting) { continue } + if waitsOnRevision(*st, held) { + waited = append(waited, *st) // its wait-ended is said as it was held (H-A-563) + } why := fmt.Sprintf("superseded: its build was superseded and its mover left for the newer revision's pipeline, revision %d now held (H-A-508, H-A-562): %s", held, whys[st.Module]) st.On, st.Revision = "", 0 l, d := supersedeStep(&p, st, why, now) @@ -421,6 +424,11 @@ func (h *Hearer) revisionHeldOne(key string, held int64) bool { if len(again) > 0 { h.logf("%s: %s, not asked on a dependency that left, placed again (H-A-361)", key, strings.Join(again, ", ")) } + for i := range waited { + if err := h.say(seat.EventWaitEnded, p, &waited[i]); err != nil { + h.logf("wait-ended of %s's %s %s on the revision view is not said: %v", key, waited[i].Module, waited[i].Step, err) + } + } for _, i := range ended { if err := h.say(seat.EventStepEnded, p, &p.Steps[i]); err != nil { h.logf("step-ended of %s's %s %s, superseded, is not said: %v", key, p.Steps[i].Module, p.Steps[i].Step, err)