A-480..A-484a: a held provider's provides, the one place for a running build's manifest, the composition tool's deadlock fix #236

Merged
mesh-tools merged 18 commits from fix/a480-held-provider-provides into main 2026-11-18 01:11:04 +00:00
2 changed files with 69 additions and 4 deletions
Showing only changes of commit 7bfeb466bf - Show all commits
+51
View File
@@ -296,6 +296,14 @@ func (c *Composer) wantedBuilds() map[string]bool {
}
}
}
// The trunk build of a module this node runs without an entry of its wanted or running build is asked too (A-480a).
for module, tb := range c.trunkBuilds {
if tb.fp != "" && c.runsWithoutEntry(module) {
if _, named := out[tb.fp]; !named {
out[tb.fp] = false
}
}
}
// The build each module runs here, as the node's own record of it says: its entry, kept in the composition state, stays held
// for the judgement of a move's data forms though the catalog half dropped it and no event of the stream names it.
for _, r := range running {
@@ -463,6 +471,17 @@ func (c *Composer) layModules() {
}
continue
}
// Running here with no entry of its wanted or running build and none of the newest: it stands, for resolution alone, as its
// trunk build, so the module that requires what it provides is no "nothing provides" (A-480a); its want stays held.
if _, laid := modules[module]; !laid && c.runsWithoutEntry(module) {
if tb := c.trunkBuilds[module]; tb.fp != "" && lay(module, tb.fp) {
m := modules[module]
m.Fp2 = w.Fp
modules[module] = m
said = append(said, fmt.Sprintf("%s runs a build whose manifest the node does not hold, so it counts what the trunk build %s of %s provides; its want stays held", module, tb.fp, module))
continue
}
}
lay(module, w.Fp)
}
// A module an assignment places whose entry is not held (not wanted here, not heard running, or its entry asked and not
@@ -530,6 +549,22 @@ func (c *Composer) needsAddressOf(node, module string) bool {
return false
}
// runsWithoutEntry says this node runs module (heard, not stopped) and holds no entry of its wanted build nor of its running build
// (c.mu held): the case where its provisions are read from its trunk build (A-480a).
func (c *Composer) runsWithoutEntry(module string) bool {
run, ok := c.heard[c.env.Node][module]
w, wanted := c.wants[module]
if !ok || run.stopped || !wanted || w.Fp == "" {
return false
}
for _, fp := range []string{w.Fp, run.fingerprint} {
if k, held := c.keptEnt[fp]; held && k.entry.Module != "" {
return false
}
}
return true
}
// askTrunkBuilds asks, for each module another node runs at a build with no entry and whose placement names no build, the trunk
// build by the seat's verb `module`, once per running build (A-461b). Called before the lock is taken: the verb is a call.
func (c *Composer) askTrunkBuilds() (wait func()) {
@@ -553,6 +588,22 @@ func (c *Composer) askTrunkBuilds() (wait func()) {
}
}
}
// A module this node runs whose wanted build and running build have no entry stands as its trunk build, for resolution alone
// (A-480a): asked once per running build, as another node's is.
for _, pm := range c.assignments[c.env.Node].Modules {
module := pm.Module
if !c.runsWithoutEntry(module) || c.trunkAsking[module] {
continue
}
running := c.heard[c.env.Node][module].fingerprint
if had, asked := c.trunkBuilds[module]; !asked || had.running != running {
asks = append(asks, ask{c.env.Node, module, running})
if c.trunkAsking == nil {
c.trunkAsking = map[string]bool{}
}
c.trunkAsking[module] = true
}
}
c.mu.Unlock()
// Asked beside the pass, a few at a time: no pass waits on the catalog half's answer, and a module that waits for it is only
// the one needing that address (A-461e). An answer asks a pass.
+18 -4
View File
@@ -274,15 +274,25 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) {
holds bool
laid bool
wantFp string
trunk bool // A-480a: the catalog half's trunk build of the module has an entry (the newest build has none)
}{
{"runs, newest entry held", true, newest, true, true, old},
{"not running here", false, newest, true, false, old},
{"names no newer build", true, "", false, false, old},
{"newest entry not held", true, newest, false, false, old},
{"runs, newest entry held", true, newest, true, true, old, false},
{"not running here", false, newest, true, false, old, false},
{"names no newer build", true, "", false, false, old, false},
{"newest entry not held", true, newest, false, false, old, false},
{"runs, no newest build, trunk entry held (A-480a)", true, "", false, true, old, true},
{"not running here, trunk entry held (A-480a)", false, "", false, false, old, true},
} {
t.Run(tc.name, func(t *testing.T) {
env := newFakeBus().env()
env.Node = "n1"
trunkFp := meshcatalogclient.SourcePrefix2 + strings.Repeat("4", 64)
env.Entry = EntryCall(func(_ context.Context, _, verb string, _ any) (json.RawMessage, error) {
if verb == meshcatalog.VerbModule && tc.trunk {
return json.Marshal(meshcatalog.ModuleAnswer{Module: meshcatalog.ModuleAnswerModule{Fp: trunkFp}})
}
return nil, errors.New("not held")
})
c := New(env)
c.mu.Lock()
c.wants["postgres"] = meshwants.WantsByWantNodeModuleValue{Fp: old, Newest: tc.newest}
@@ -294,6 +304,10 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) {
if tc.holds {
c.holdEntry(t, "postgres", newest, body)
}
if tc.trunk {
c.holdEntry(t, "postgres", trunkFp, body)
}
c.askTrunkBuilds()()
if got := c.wantedBuilds()[newest]; tc.newest != "" && got {
t.Errorf("the newest build is named by a want, want only asked")
}