diff --git a/modules/mesh-delivery-indexer/internal/index/behind_test.go b/modules/mesh-delivery-indexer/internal/index/behind_test.go index f2f58131..c7192b9e 100644 --- a/modules/mesh-delivery-indexer/internal/index/behind_test.go +++ b/modules/mesh-delivery-indexer/internal/index/behind_test.go @@ -114,7 +114,17 @@ func TestASourceRevisionHeardDuringACatchUpIsComparedWhenItEnds(t *testing.T) { } return inner(c, r, m, n) } - b.ix.CatchUp(ctx) + got := b.ix.CatchUp(ctx) + // A-490k: the catch-up tool's own path says take-in.taken for the module it wrote. + said := false + for _, s := range b.said { + if s.Kind == takein.TakeInTaken && len(s.Entries) == 1 && s.Entries[0].Module == "avahi" && s.Source > 0 { + said = true + } + } + if !got.Stored || !said { + t.Errorf("the catch-up answered %+v and said %+v, want a take-in.taken naming avahi", got, b.said) + } b.ix.catchUpWG.Wait() v, _, _, _ := b.ix.Taken.Get(ctx, key) if got, _ := takein.DecodeTaken(v); got.Merge != h2 { diff --git a/modules/mesh-delivery-indexer/internal/index/source.go b/modules/mesh-delivery-indexer/internal/index/source.go index 8b2b361d..ca2eb58e 100644 --- a/modules/mesh-delivery-indexer/internal/index/source.go +++ b/modules/mesh-delivery-indexer/internal/index/source.go @@ -220,7 +220,9 @@ func (ix *Indexer) takeInHeadsWritten(ctx context.Context, heads map[string]stri if err == nil { var a Applied a, err = ix.ApplyMessage(ctx, f) - written = append(written, a.Written...) + if err == nil { + written = append(written, a.Written...) + } } if err != nil { unread = append(unread, repository) @@ -250,8 +252,19 @@ func (ix *Indexer) sayCaughtUp(ctx context.Context, written []string, heads map[ if len(merges) == 0 { return } + ix.mu.Lock() + was, had := ix.saidSource[TrunkBranch] + ix.mu.Unlock() branch, src, took := ix.takenWhat(ctx, claimed, Applied{Written: written}) if len(took) == 0 { + // Nothing is said, so the source number is not spent (takenWhat took it). + ix.mu.Lock() + if had { + ix.saidSource[branch] = was + } else { + delete(ix.saidSource, branch) + } + ix.mu.Unlock() return } revision := ix.PinPipelines(ctx, branch, src, took) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go index 373903b6..e3bdc590 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go @@ -354,4 +354,22 @@ func TestATakeInBehindTheViewAsksTheViewAgainAndStartsTheHeldModulesWhenItReache if n, err := s.StartHeld("main", half); n != 0 || err != nil { t.Errorf("the held start ran twice: %d (%v)", n, err) } + // The view reaching the revision while the take-in is read (its second read answers 12) starts the held modules inside + // TakenIn, not at an advance that already came. + mem2 := memStore{} + s2 := &Starter{Pipelines: memCreated{mem2}, Store: mem2, Say: func(string, any) error { return nil }} + reads := 0 + view2 := func(string) (Half, bool) { + reads++ + if reads >= 2 { + return Half{Revision: 12, Source: 9, Entries: entries}, true + } + return Half{Revision: 11, Source: 8, Entries: entries}, true + } + if n, err := s2.TakenIn(ev, view2); err != nil || n != 2 { + t.Fatalf("the take-in whose view reached 12 meanwhile started %d (%v), want moved and batched", n, err) + } + if _, _, err := mem2.Get("main.9.batched"); err != nil { + t.Errorf("main.9.batched is not started inside the take-in: %v", err) + } }