H-A-480 a: the composer's mark is a compare-and-set on the have's revision

Under load, a rank wait settle wrote between the composer's read of a have and its
mark was overwritten by the mark and never written again. The mark and its clear
now write over the revision they read (a lost race reads again and keeps the other
cause), a module waiting for its rank is never marked, and a mark on a module that
never ran is cleared at the next pass that composes it.

Builds: design 47 H2 H-A-480 (and its addendum), H §771, H-A-59
This commit is contained in:
2026-11-22 16:12:10 +01:00
parent e90872d852
commit cb5eddeba8
5 changed files with 388 additions and 59 deletions
+21 -5
View File
@@ -104,12 +104,23 @@ func (h sessionHaves) ReadErr(ctx context.Context, module string) (agent.Have, b
}
return agent.Have{Module: module, Composed: got.Composed, Sealed: got.SealedAt}, true, nil
}
got, ok, err := h.session.ReadHaveErr(ctx, module)
got, _, ok, err := h.ReadAt(ctx, module)
return got, ok, err
}
// ReadAt is ReadErr with the revision of the module's key (agent.HavesAt).
func (h sessionHaves) ReadAt(ctx context.Context, module string) (agent.Have, uint64, bool, error) {
got, revision, ok, err := h.session.ReadHaveAt(ctx, module)
if !ok || err != nil {
return agent.Have{}, false, err
return agent.Have{}, revision, false, err
}
return agent.Have{Module: module, FP: got.Fp, Composed: got.Composed, Phase: string(got.Phase), Detail: got.Detail,
Sealed: got.SealedAt, Wait: got.Wait, Run: got.Run, Pipeline: got.Pipeline}, true, nil
Sealed: got.SealedAt, Wait: got.Wait, Run: got.Run, Pipeline: got.Pipeline}, revision, true, nil
}
// WriteAt writes a module's have only while its key is at the revision read (agent.HavesAt, H-A-480).
func (h sessionHaves) WriteAt(ctx context.Context, x agent.Have, revision uint64) (bool, error) {
return h.session.NoteModuleAt(ctx, moduleFact(x), revision)
}
func (h sessionHaves) Write(ctx context.Context, x agent.Have) {
@@ -120,13 +131,18 @@ func (h sessionHaves) Write(ctx context.Context, x agent.Have) {
}
return
}
h.session.NoteModule(ctx, moduleFact(x))
}
// moduleFact is a module's have as the session writes it.
func moduleFact(x agent.Have) link.ModuleFact {
phase := x.Phase
if phase == string(nodeengineclient.PhaseRunning) {
phase = ""
}
h.session.NoteModule(ctx, link.ModuleFact{Module: x.Module, FP: x.FP, Composed: x.Composed, Phase: phase,
return link.ModuleFact{Module: x.Module, FP: x.FP, Composed: x.Composed, Phase: phase,
Failed: phase == string(nodeengineclient.PhaseFailed), Detail: shorten(x.Detail), Judgement: x.Judgement, Waits: x.Waits,
BuildAlone: x.BuildAlone, Kept: x.Kept, Sealed: x.Sealed, PullWait: x.PullWait, Wait: x.Wait, Run: x.Run, Pipeline: x.Pipeline})
BuildAlone: x.BuildAlone, Kept: x.Kept, Sealed: x.Sealed, PullWait: x.PullWait, Wait: x.Wait, Run: x.Run, Pipeline: x.Pipeline}
}
func (h sessionHaves) Removed(ctx context.Context, module string) {