diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog.go index 27fe86aab..d70b0543b 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog.go @@ -108,13 +108,15 @@ func WireCatalog(r *views.Reader, call Call, branch string, changed func(module // WireCatalogProcess is WireCatalog for a process's views.ProcessReader: its picture // (`mesh-catalog_catalog-revisions.`) reads the half as a read-only bucket, and the seat's event catalog-revision -// on the module's durable consumer goes to Hear. -func WireCatalogProcess(r *views.ProcessReader, call Call, branch string, changed func(module string, entry json.RawMessage, deleted bool, at time.Time)) (*Catalog, *views.Picture, error) { +// on the module's durable consumer goes to Hear. held is told each revision the view takes in whole, whether or not an entry +// changed, as Catalog.Held is (design 47 H2 H-A-747); it is set before the first ask. A nil held tells nothing. +func WireCatalogProcess(r *views.ProcessReader, call Call, branch string, changed func(module string, entry json.RawMessage, deleted bool, at time.Time), held func(seat.CatalogRevision)) (*Catalog, *views.Picture, error) { c, err := NewCatalog(call, branch) if err != nil { return nil, nil, err } c.Follower.Changed = changed + c.Held = held p, err := r.Adopt(c.Follower, seat.Seat, seat.EventCatalogRevision, c.Hear) if err != nil { return nil, nil, err diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/testruns_integration_test.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/testruns_integration_test.go index 4f20a0fbe..5d58a6a63 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/testruns_integration_test.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/testruns_integration_test.go @@ -147,8 +147,12 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) { } var revision atomic.Int64 revision.Store(1) + var late atomic.Pointer[chan struct{}] // a view's ask of revision 2 answered once this channel is closed if _, err := nc.Subscribe("mesh.seat.mesh-catalog.call.revision.*", func(m *nats.Msg) { r := revision.Load() + if h := late.Load(); h != nil && r == 2 { + <-*h + } raw, _ := json.Marshal(map[string]any{"result": catalog.RevisionAnswer{Revision: &catalog.CatalogRevision{Revision: r, Kind: "trunk", Branch: "main", Source: 2 + r}, Entries: entries}}) _ = m.Respond(raw) }); err != nil { @@ -545,10 +549,16 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) { } // A second revision with the same digests asks its own runs, so a failed test runs again (ยง724). + // design 47 H2 H-A-747 (DQ-56): the view's ask of revision 2, whose entries equal revision 1's, is answered late, after the + // take-in made main.2 with no step: no entry changes, and the view holding revision 2 alone places it. revision.Store(2) + answered := make(chan struct{}) + late.Store(&answered) publish(catalog.SubjectCatalogRevision("main"), catalog.CatalogRevisionEvent{V: 1, Revision: 2, Kind: "trunk", Branch: "main", Source: 4}) const p4 = "main.2" takeIn("app", "c1", "src2:aa", 4, 2) + waitFor(t, ctx, logs, func() bool { return strings.Contains(logs.String(), "main.2 starts with no step") }) + close(answered) placed(p4) run4, r4 := runOfStep(p4, "app:program", "integration") if !strings.HasPrefix(run4, "main.2.") || r4.Ask == integ.Ask { diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go index 9b5b34320..a27356016 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go @@ -132,7 +132,9 @@ func startViews(ctx context.Context, js jetstream.JetStream, conn *nats.Conn, cr // is picked up as readiness is: its pipelines started with no steps are placed then (A-327, A-336). var wired atomic.Pointer[meshcatalogclient.Catalog] var ready pipeline.Readiness - c, _, err := meshcatalogclient.WireCatalogProcess(reader, call, branch, func(string, json.RawMessage, bool, time.Time) { + // A newer revision whose entries equal the one before changes no key, so the follower's Changed never tells it: the view + // holding it is told by Held as well (design 47 H2 H-A-747, DQ-56). + observe := func() { c := wired.Load() if c == nil || onReady == nil { return @@ -148,7 +150,9 @@ func startViews(ctx context.Context, js jetstream.JetStream, conn *nats.Conn, cr go onAdvance(branch) } } - }) + } + c, _, err := meshcatalogclient.WireCatalogProcess(reader, call, branch, func(string, json.RawMessage, bool, time.Time) { observe() }, + func(catalog.CatalogRevision) { observe() }) if err != nil { return nil, err }