H-A-745: a send that cannot read the builder's own state is left and given again; only the holder's answer ends it
SendFate gains Unread: an unreadable reservation or catalog entry sends and says nothing, and take leaves the item unacknowledged for the ack wait, B11's tenth delivery ending it loud. Builds: design 47 H2 H-A-745 (B-Q1), H-A-606, H-A-613 (4), H-A-653
This commit is contained in:
@@ -155,6 +155,12 @@ func (p *publishItems) take(ctx context.Context, m itemMsg) {
|
||||
if p.send != nil {
|
||||
fate = p.send(ctx, q)
|
||||
}
|
||||
if fate.Unread != "" {
|
||||
// A read of the builder's own state that failed is no answer of a holder: the item is left unacknowledged, given again after the
|
||||
// ack wait, and the queue's tenth delivery ends it loud (design 47 H2 H-A-745, H-A-653).
|
||||
p.logf("%s %s at %s: sent no publish: %s; the item is left, given again after the ack wait", q.Module, q.Version, q.Holder, fate.Unread)
|
||||
return
|
||||
}
|
||||
if fate.Ended != "" {
|
||||
p.logf("%s %s at %s is terminated: %s", q.Module, q.Version, q.Holder, fate.Ended)
|
||||
_ = m.Term()
|
||||
|
||||
@@ -158,6 +158,13 @@ func TestAPublishIsPutOnceAtABuildsEndAndNeverOnATimer(t *testing.T) {
|
||||
if len(sent) != 1 || !slices.Equal(m.settled, []string{"term"}) {
|
||||
t.Fatalf("a failed send: sent %v, settled %v, want one send and the item terminated, never handed back with a pause", sent, m.settled)
|
||||
}
|
||||
// design 47 H2 H-A-745: a read of the builder's own state that failed leaves the item unacknowledged, ended nowhere.
|
||||
fate = versions.SendFate{Unread: "its reservation cannot be read: down"}
|
||||
m = queuedMsg(t, "m", "0.1.2")
|
||||
p.take(ctx, m)
|
||||
if len(sent) != 2 || len(m.settled) != 0 {
|
||||
t.Fatalf("an unread send: sent %v, settled %v, want it left unacknowledged", sent, m.settled)
|
||||
}
|
||||
fate = versions.SendFate{Sent: true}
|
||||
m = queuedMsg(t, "m", "0.1.2")
|
||||
p.take(ctx, m)
|
||||
|
||||
@@ -726,10 +726,11 @@ func (r *Republisher) MoveQueued(ctx context.Context, vals []json.RawMessage) (i
|
||||
|
||||
// SendFate is what SendQueued did with one item (§793): Sent, every artifact sent (its item acknowledged when its publish is
|
||||
// heard or confirmed); Ended, why the version never publishes (its item terminated); Failed, the holder's or the call's words
|
||||
// (its item handed back with the pause).
|
||||
// (its item ended, the version staying reserved); Unread, why a read of the builder's own state failed: nothing was sent, the item is
|
||||
// left unacknowledged and given again after the ack wait (design 47 H2 H-A-745).
|
||||
type SendFate struct {
|
||||
Sent bool
|
||||
Ended, Failed string
|
||||
Sent bool
|
||||
Ended, Failed, Unread string
|
||||
}
|
||||
|
||||
// SendQueued publishes one item's artifacts and says the outcome. Every call it makes honours the one bound it is given,
|
||||
@@ -739,8 +740,8 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate
|
||||
defer cancel()
|
||||
all, err := r.Reserved.All(bound)
|
||||
if err != nil {
|
||||
r.logf("publish again: %s %s is not sent to %s: its reservation cannot be read: %v; it is handed back", q.Module, q.Version, q.Holder, err)
|
||||
return SendFate{Failed: "its reservation cannot be read: " + err.Error()}
|
||||
r.logf("publish again: %s %s is not sent to %s: its reservation cannot be read: %v; it is given again after the ack wait", q.Module, q.Version, q.Holder, err)
|
||||
return SendFate{Unread: "its reservation cannot be read: " + err.Error()}
|
||||
}
|
||||
var v ReservedVersion
|
||||
found := false
|
||||
@@ -768,8 +769,8 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate
|
||||
e, err := r.Entry(bound, v.Fingerprint)
|
||||
if err != nil {
|
||||
words := fmt.Sprintf("the catalog entry %s cannot be read: %v", v.Fingerprint, err)
|
||||
r.say(ctx, v, words)
|
||||
return SendFate{Failed: words}
|
||||
r.logf("publish again: %s %s is not sent to %s: %s; it is given again after the ack wait", q.Module, q.Version, q.Holder, words)
|
||||
return SendFate{Unread: words}
|
||||
}
|
||||
v = r.fillUpstream(ctx, v, e)
|
||||
missing := map[string]bool{}
|
||||
|
||||
@@ -466,6 +466,22 @@ func TestAQueuedItemIsSentWhileItsBuildStands(t *testing.T) {
|
||||
if f := b.SendQueued(ctx, b.queueAt(w, PublishClassLive, b.now)); f.Failed == "" || f.Sent {
|
||||
t.Errorf("a refusal in other words answered %+v, want it failed, handed back", f)
|
||||
}
|
||||
// design 47 H2 H-A-745: a read of the builder's own state that fails is no answer of a holder: nothing is sent or said and the
|
||||
// item is left to be given again, while an answered failure above ended it.
|
||||
x := b.reserve(t, "x")
|
||||
sent, said := len(b.sent), len(b.said)
|
||||
entry := b.Entry
|
||||
b.Entry = func(context.Context, string) (meshcatalog.CatalogEntry, error) {
|
||||
return meshcatalog.CatalogEntry{}, errors.New("the catalog is down")
|
||||
}
|
||||
if f := b.SendQueued(ctx, b.queueAt(x, PublishClassLive, b.now)); f.Unread == "" || f.Failed != "" || f.Ended != "" || f.Sent || len(b.sent) != sent || len(b.said) != said {
|
||||
t.Errorf("an unreadable entry answered %+v, sent %d more, said %d more: want it unread, nothing sent or said", f, len(b.sent)-sent, len(b.said)-said)
|
||||
}
|
||||
b.Entry = entry
|
||||
b.reserved.mem.down = errors.New("the state is down")
|
||||
if f := b.SendQueued(ctx, b.queueAt(x, PublishClassLive, b.now)); f.Unread == "" || f.Failed != "" || f.Ended != "" || f.Sent || len(b.sent) != sent {
|
||||
t.Errorf("an unreadable reservation answered %+v: want it unread", f)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user