diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 2a2456c0..a83ace65 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -673,6 +673,12 @@ func (a *Agent) NotComposedEach(ctx context.Context, why string, held map[string } } +// composeWait is the wait a hold of the composition carries in its have: step compose, with its reason and its words (design 47 G +// A-453, section 541). Only a hold for a failed backup carries none. +func (a *Agent) composeWait(reason, words string) *nodeengine.Wait { + return &nodeengine.Wait{Owner: nodeengine.Seat, Step: nodeengine.WaitStepCompose, Reason: reason, Since: a.now(), Words: words} +} + // writeHave writes a module's have (the node's own key for NodeModule); on a node composing its own, with the sealed // values of the composition it names when the caller gave none (Have.Sealed): those of the composition the agent applied or holds at that digest, else // those the module's last have said at that digest. @@ -681,12 +687,6 @@ func (a *Agent) NotComposedEach(ctx context.Context, why string, held map[string // module since its start: held by a failed backup, waiting for a yes, not composed) keeps what the module's last have // said runs, its fingerprint, digest and sealed values, rather than a have naming nothing: what runs is not lost, and // the boxes the composer reuses after a restart stay (review of L2, rounds 2 and 3). -// composeWait is the wait a hold of the composition carries in its have: step compose, with its reason and its words (design 47 G -// A-453, section 541). Only a hold for a failed backup carries none. -func (a *Agent) composeWait(reason, words string) *nodeengine.Wait { - return &nodeengine.Wait{Owner: nodeengine.Seat, Step: nodeengine.WaitStepCompose, Reason: reason, Since: a.now(), Words: words} -} - func (a *Agent) writeHave(ctx context.Context, h Have) { if h.Module != NodeModule { a.mu.Lock() @@ -1680,9 +1680,14 @@ func (a *Agent) apply(ctx context.Context, module string, w wantNow, comp compNo a.mu.Lock() a.attempt[module] = attempt{FP: fp, Composed: dig, WantRev: w.Rev, CompRev: comp.Rev, Held: true, AnsweredRev: w.Rev} a.mu.Unlock() - // It keeps running what it has: the have says what it holds and why it waits. + // It keeps running what it has: the have says what it holds and why it waits. A backup interrupted is no failure of it, so + // its hold waits as kept.go's do, with the words as the reason; only a failed backup carries no wait (A-453). + var wait *nodeengine.Wait + if words == BackupInterrupted { + wait = a.composeWait(words, words) + } a.writeHave(ctx, Have{Module: module, FP: prev.Fp, Composed: prev.Composed, Phase: string(nodeengineclient.PhaseHeld), - Detail: words}) + Detail: words, Wait: wait}) return } } diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index c6b39f38..55cc0f87 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -828,8 +828,9 @@ func TestADataModuleIsBackedUpFirstAndHeldWhenItFails(t *testing.T) { stopI := ib.run() <-began stopI() - if h := ib.haves.last("db"); h.Phase != string(nodeengineclient.PhaseHeld) || h.FP != fp1 || h.Composed != dig1 || h.Detail != BackupInterrupted { - t.Errorf("held after an interrupted backup: %+v", h) + if h := ib.haves.last("db"); h.Phase != string(nodeengineclient.PhaseHeld) || h.FP != fp1 || h.Composed != dig1 || h.Detail != BackupInterrupted || + h.Wait == nil || h.Wait.Step != nodeengine.WaitStepCompose || h.Wait.Reason != BackupInterrupted { + t.Errorf("held after an interrupted backup, with its wait (A-453): %+v", h) } // At a start: a backup the node agent's own stop interrupted (postgres on novox, 2026-10-31) is no failure, so it is diff --git a/internal/agent/parts.go b/internal/agent/parts.go index 526903fc..d8792873 100644 --- a/internal/agent/parts.go +++ b/internal/agent/parts.go @@ -31,7 +31,6 @@ func judgedAgain(why string) bool { return strings.HasPrefix(why, PartsDiffer) || heldForEntry(why) } -// heldForEntry says whether why is a hold for the entry a want names. // heldReason is the opening of a detail held for an entry: EntryAsked or EntryMissing. func heldReason(why string) string { if strings.HasPrefix(why, EntryAsked) { @@ -40,6 +39,7 @@ func heldReason(why string) string { return EntryMissing } +// heldForEntry says whether why is a hold for the entry a want names. func heldForEntry(why string) bool { return strings.HasPrefix(why, EntryAsked) || strings.HasPrefix(why, EntryMissing) }