builder: drain every holder a publish again queued at, whatever a later version met
queue() returned on the first version whose catalog entry could not be read, before it started the drain of the holders it had already queued at: on 2026-11-16 17:20 mesh-hand-acts 0.1.13 was queued at distribution, then mesh-delivery-indexer 0.1.14's entry was not kept, and the queued publish was never sent, so no version was released. Now an unreadable entry leaves only its own version unqueued, the error is still answered (heard again), and the drain of every holder given a version is started in all cases (design 47 G section 588). Quick fix and thorough fix are the same here: queue() is the one place that starts a holder's drain.
This commit is contained in:
@@ -316,7 +316,14 @@ func holdersOf(holders map[string][]string, seat string) []string {
|
||||
func (r *Republisher) queue(ctx context.Context, vs []ReservedVersion, holdersOf func(seat string) []string, max int) ([]string, error) {
|
||||
sort.SliceStable(vs, func(i, j int) bool { return vs[i].At.After(vs[j].At) })
|
||||
var queued []string
|
||||
var errs []error
|
||||
started := map[string]bool{}
|
||||
// Every holder given a version is drained, whatever a later version met: a version queued and never drained waits forever.
|
||||
defer func() {
|
||||
for holder := range started {
|
||||
r.drainLater(ctx, holder)
|
||||
}
|
||||
}()
|
||||
for _, v := range vs {
|
||||
if max > 0 && len(queued) >= max {
|
||||
break
|
||||
@@ -327,7 +334,9 @@ func (r *Republisher) queue(ctx context.Context, vs []ReservedVersion, holdersOf
|
||||
}
|
||||
e, err := r.Entry(ctx, v.Fingerprint)
|
||||
if err != nil {
|
||||
return queued, fmt.Errorf("the catalog entry %s of %s %s cannot be read: %w", v.Fingerprint, v.Module, v.Version, err)
|
||||
// One version's unreadable entry leaves only that version unqueued; the others go on.
|
||||
errs = append(errs, fmt.Errorf("the catalog entry %s of %s %s cannot be read: %w", v.Fingerprint, v.Module, v.Version, err))
|
||||
continue
|
||||
}
|
||||
byHolder := map[string]map[string]string{}
|
||||
for _, ref := range v.Missing() {
|
||||
@@ -368,10 +377,7 @@ func (r *Republisher) queue(ctx context.Context, vs []ReservedVersion, holdersOf
|
||||
queued = append(queued, v.Module+" "+v.Version)
|
||||
}
|
||||
}
|
||||
for holder := range started {
|
||||
r.drainLater(ctx, holder)
|
||||
}
|
||||
return queued, nil
|
||||
return queued, errors.Join(errs...)
|
||||
}
|
||||
|
||||
// enqueue puts one holder's artifacts of a version in its queue: not again when it is queued already, and not past the
|
||||
|
||||
@@ -151,6 +151,25 @@ func TestRepublish(t *testing.T) {
|
||||
t.Errorf("sent %+v, want the two newest, m3 then m2", b.sent)
|
||||
}
|
||||
})
|
||||
t.Run("an entry that cannot be read stops neither the other versions nor the drain", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b.reserve(t, "m1")
|
||||
b.reserve(t, "m2") // newest: queued before m1's entry is met
|
||||
entry := b.Entry
|
||||
b.Entry = func(ctx context.Context, fp string) (meshcatalog.CatalogEntry, error) {
|
||||
if fp == "src2:m1" {
|
||||
return meshcatalog.CatalogEntry{}, errors.New("no entry of fingerprint src2:m1 is kept")
|
||||
}
|
||||
return entry(ctx, fp)
|
||||
}
|
||||
subject, data := running("n1", "oci", "src2:holder", false)
|
||||
if _, err := b.Heard(ctx, subject, data, 1); err == nil || !strings.Contains(err.Error(), "src2:m1") {
|
||||
t.Errorf("the unreadable entry is not said: %v", err)
|
||||
}
|
||||
if len(b.sent) != 1 || !strings.HasPrefix(b.sent[0].Name, "m2/") {
|
||||
t.Errorf("sent %+v, want m2 drained though m1's entry cannot be read", b.sent)
|
||||
}
|
||||
})
|
||||
t.Run("an artifact no store holds is said once and not tried again", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b.reserve(t, "m")
|
||||
|
||||
Reference in New Issue
Block a user