H-A-150: forget only on the store's own answer, and on the apply's fetch too

A fetch nothing answered for (a bus or store that did not answer, a gateway
saying the store is away) proves nothing about the digest, so it is tried
again as before and the module is not held for it; only an answer of the
store's (a 404, bytes not of the digest) forgets the resolution. The apply's
fetch of a bundle meets the same wrong digest as the take-in's, so it tells
the composer too (apply.WithFetchFailed, set in the node agent's apply).

Builds: design 47 H H-A-150, H-A-146, G A-430a
This commit is contained in:
2026-11-20 16:35:42 +01:00
parent dc95fb5673
commit 132b767043
8 changed files with 91 additions and 9 deletions
+12 -2
View File
@@ -1693,8 +1693,11 @@ func (r reader) Archive(ctx context.Context, url, digest string) ([]byte, error)
defer cancel()
body, err := r.c.env.Fetch(fetching, url)
if r.c.note(err) != nil {
// A resolution whose fetch failed is forgotten, and versions asked again (H-A-146).
r.c.forgetFetched(digest, fmt.Sprintf("the fetch of %s failed: %v", url, err))
// A resolution whose fetch the store answered and failed is forgotten, and versions asked again (H-A-146); a fetch
// nothing answered for is tried again as before, the module not held for it (H-A-150).
if storeAnswered(err) {
r.c.forgetFetched(digest, fmt.Sprintf("the fetch of %s failed: %v", url, err))
}
return nil, err
}
sum := sha256.Sum256(body)
@@ -1707,6 +1710,13 @@ func (r reader) Archive(ctx context.Context, url, digest string) ([]byte, error)
return body, nil
}
// storeAnswered is whether a fetch failed with the store's own answer (the apply's fetch says so by StoreAnswered: a 404, never a
// store nothing answered for), H-A-150.
func storeAnswered(err error) bool {
var a interface{ StoreAnswered() bool }
return errors.As(err, &a) && a.StoreAnswered()
}
// Served reads, of another node's module, the keys named of mesh-config's resolved values, one key each: the node is
// granted those keys alone (buscompose Principal.ServedReads, issue 1126).
func (r reader) Served(ctx context.Context, node, module string, keys []string) (map[string]any, error) {
+3
View File
@@ -160,6 +160,9 @@ func (c *Composer) forgetFetched(digest, why string) {
}
}
// ForgetFetched is forgetFetched for the apply's fetch of a bundle the store answered and that failed (H-A-150, apply.FetchFailed).
func (c *Composer) ForgetFetched(digest, why string) { c.forgetFetched(digest, why) }
// dropForgottenLocked ends the standing of every forgotten resolution (H-A-146), of module alone or, for "", of all: the next
// pass asks the seats' verb versions again. Under mu.
func (c *Composer) dropForgottenLocked(module string) {
+21 -5
View File
@@ -154,13 +154,17 @@ func aResolutionWhoseFetchFailedIsForgotten(t *testing.T) {
then string // what follows the fetch: "" (a pass within the bound), want, compose, bound
asked bool // versions is asked again
forgets bool // the journal says it forgot
failed bool // the fetch fails though nothing is forgotten
}{
"a fetch that succeeded keeps its resolution": {answer: good, then: "bound"},
"a 404, the next pass within the bound": {answer: wrong, fetch: errors.New("404 Not Found"), forgets: true},
"a 404, then the module's next want": {answer: wrong, fetch: errors.New("404 Not Found"), then: "want", asked: true, forgets: true},
"a 404, then a compose by hand": {answer: wrong, fetch: errors.New("404 Not Found"), then: "compose", asked: true, forgets: true},
"a 404, then the bound while it is held": {answer: wrong, fetch: errors.New("404 Not Found"), then: "bound", asked: true, forgets: true},
"a 404, the next pass within the bound": {answer: wrong, fetch: notFound{}, forgets: true},
"a 404, then the module's next want": {answer: wrong, fetch: notFound{}, then: "want", asked: true, forgets: true},
"a 404, then a compose by hand": {answer: wrong, fetch: notFound{}, then: "compose", asked: true, forgets: true},
"a 404, then the bound while it is held": {answer: wrong, fetch: notFound{}, then: "bound", asked: true, forgets: true},
"bytes that are not of the digest": {answer: wrong, then: "want", asked: true, forgets: true},
// H-A-150: a fetch nothing answered for keeps its resolution, and the module is not held for it.
"a bus that did not answer keeps it": {answer: good, fetch: errors.New("nats: timeout"), failed: true},
"a store away keeps it": {answer: good, fetch: storeAway{}, failed: true},
} {
now := time.Date(2026, 11, 20, 16, 0, 0, 0, time.UTC)
var said []string
@@ -179,7 +183,7 @@ func aResolutionWhoseFetchFailedIsForgotten(t *testing.T) {
c.keptEnt[fp] = keptEntry{entry: entry}
parts, _ := c.partsOf("mail", entry, want)
_, err := reader{c: c}.Archive(context.Background(), referenceOf("mail", "files", parts["mail:files"]), parts["mail:files"])
if (err != nil) != row.forgets {
if (err != nil) != (row.forgets || row.failed) {
t.Errorf("%s: the fetch: %v", name, err)
}
switch row.then {
@@ -211,3 +215,15 @@ func aResolutionWhoseFetchFailedIsForgotten(t *testing.T) {
}
}
}
// notFound is the artifact store's answer that it holds no such blob, as the apply's fetch says it (StoreAnswered).
type notFound struct{}
func (notFound) Error() string { return "artifact-store answered 404 Not Found" }
func (notFound) StoreAnswered() bool { return true }
// storeAway is a gateway's answer that the store is away (a 503): no answer of the store's own.
type storeAway struct{}
func (storeAway) Error() string { return "artifact-store answered 503 Service Unavailable" }
func (storeAway) StoreAnswered() bool { return false }