H-A-772 (3) hold-end-words: end only a failed backup's hold, and say an interrupted unchanged move takes no backup (issue 1984)

Review round 1 found that an interrupted backup of a move judged unchanged still said "it is backed up
again" while the apply takes none, and that the start's hold end also matched a revert's hold, which
carries a wait.

- The interrupted backup's line says the move is judged unchanged and applied with no backup when the
  judge finds it unchanged and the want carries no again; its comment says the same.
- The hold end at the start takes only a failed backup's hold (no wait): a revert's hold waits for the
  operator's answer, whatever the judgement. A hold after a failed again stays, as before.

Builds: design 47 H2 H-A-772 (3)
This commit is contained in:
2026-11-26 04:24:59 +01:00
parent 50dffe299f
commit a8f2a9a171
2 changed files with 45 additions and 18 deletions
+13 -5
View File
@@ -1796,10 +1796,17 @@ func (a *Agent) baseline(ctx context.Context, module string, w wantNow, comp com
a.mu.Unlock()
if h.Phase == string(nodeengineclient.PhaseHeld) && h.Detail == BackupInterrupted && w.Want.Backup != meshwants.WantsByWantNodeModuleValueBackupSkip {
// Held only because this node agent stopped while the backup ran (postgres on novox, 2026-10-31): no
// failure and nothing for the operator to answer. It is backed up again and applied (a.prior makes the
// apply back it up first); the want still asking a backup is all the answer needed.
// failure and nothing for the operator to answer; the want still asking a backup is all the answer needed.
// It is applied (a.prior makes the apply take it as a module that ran): backed up again first when the
// judge finds its move changed or the want says again, else with no backup, and the words say which
// (design 47 H2 H-A-771, H-A-772 (1), (3)).
words := fmt.Sprintf("%s's backup was interrupted by this node agent's stop: it is backed up again", module)
if w.Want.Backup != meshwants.WantsByWantNodeModuleValueBackupAgain && !a.moveChanged(module, comp) {
words = fmt.Sprintf("%s's backup was interrupted by this node agent's stop, and its move to %s is judged "+
"unchanged: it is applied with no backup", module, short(comp.Dig))
}
a.mu.Lock()
a.sayOnce("interrupted:"+module, fmt.Sprintf("%s's backup was interrupted by this node agent's stop: it is backed up again", module))
a.sayOnce("interrupted:"+module, words)
a.mu.Unlock()
return false
}
@@ -1833,11 +1840,12 @@ func (a *Agent) baseline(ctx context.Context, module string, w wantNow, comp com
h.Wait = nil
a.writeHave(ctx, h)
}
if h.Phase == string(nodeengineclient.PhaseHeld) && !judgedAgain(h) && recoveryCause(h) == recoveryNone &&
if h.Phase == string(nodeengineclient.PhaseHeld) && h.Wait == nil && !judgedAgain(h) && recoveryCause(h) == recoveryNone &&
!a.moveChanged(module, comp) {
// Held for a failed backup of a move the judge finds unchanged (lidarr on ace, 2026-11-26 03:50): a backup
// H-A-771 no longer asks, so it is applied with no backup and its hold ends, said here; its ask is the
// assigner's to take back, as a stale ask is, once its have runs (design 47 H2 H-A-772 (2)).
// assigner's to take back, as a stale ask is, once its have runs (design 47 H2 H-A-772 (2)). Only a failed
// backup's hold, which carries no wait: a revert's hold carries one and is never ended here (H-A-772 (3)).
a.mu.Lock()
a.sayOnce("unheld:"+module+":"+comp.Dig, fmt.Sprintf("%s's hold for a failed backup (%s) ends at this start: its "+
"move to %s is judged unchanged, so it is applied with no backup", module, h.Detail, short(comp.Dig)))
+32 -13
View File
@@ -1055,12 +1055,23 @@ func testADataModuleIsBackedUpFirstAndHeldWhenItFails(t *testing.T) {
backups int
holdsTill bool // it is held, and said held, before the later revision
unchanged bool // what the machine applied differs from the want's composition in env.MESH_FINGERPRINT alone
// detail is the held have's words ("" a failed backup's) and wait whether it carries a wait of step compose with
// them, as an interrupted backup's and a revert's do; says is what the journal says, never what it must not.
detail string
wait bool
says, never string
}{
{"answered before the start", meshwants.WantsByWantNodeModuleValueBackupAgain, "", 1, false, false},
{"answered while held", "", meshwants.WantsByWantNodeModuleValueBackupAgain, 1, true, false},
{"skipped while held", "", meshwants.WantsByWantNodeModuleValueBackupSkip, 0, true, false},
{"held, its move unchanged", "", "", 0, false, true},
{"again on an unchanged move", meshwants.WantsByWantNodeModuleValueBackupAgain, "", 1, false, true},
{"answered before the start", meshwants.WantsByWantNodeModuleValueBackupAgain, "", 1, false, false, "", false, "", ""},
{"answered while held", "", meshwants.WantsByWantNodeModuleValueBackupAgain, 1, true, false, "", false, "", ""},
{"skipped while held", "", meshwants.WantsByWantNodeModuleValueBackupSkip, 0, true, false, "", false, "", ""},
{"held, its move unchanged", "", "", 0, false, true, "", false, "nats's hold for a failed backup", ""},
{"again on an unchanged move", meshwants.WantsByWantNodeModuleValueBackupAgain, "", 1, false, true, "", false, "", ""},
// H-A-772 (3): every line said names what happens; an interrupted backup of an unchanged move is applied with none.
{"interrupted, its move unchanged", "", "", 0, false, true, BackupInterrupted, true,
"judged unchanged: it is applied with no backup", "it is backed up again"},
// H-A-772 (3): the end is of a failed backup's hold only; a revert's hold carries a wait and waits for the answer.
{"a revert's hold, its move unchanged", "", meshwants.WantsByWantNodeModuleValueBackupSkip, 0, true, true,
"restore point missing: nats's cache has none of form 1 taken before " + fp2, true, "", "nats's hold for a failed backup"},
} {
t.Run(row.name, func(t *testing.T) {
r := newBed(t)
@@ -1088,8 +1099,15 @@ func testADataModuleIsBackedUpFirstAndHeldWhenItFails(t *testing.T) {
return raw
}
r.wants.before(wk, selfWant(row.atStart))
r.haves.stored = map[string]Have{"nats": {Module: "nats", FP: heldFP, Composed: heldDig, Phase: string(nodeengineclient.PhaseHeld),
Detail: "the backup failed: sh: exit status 1"}}
held := Have{Module: "nats", FP: heldFP, Composed: heldDig, Phase: string(nodeengineclient.PhaseHeld),
Detail: "the backup failed: sh: exit status 1"}
if row.detail != "" {
held.Detail = row.detail
}
if row.wait {
held.Wait = &nodeengine.Wait{Owner: nodeengine.Seat, Step: nodeengine.WaitStepCompose, Reason: held.Detail, Words: held.Detail}
}
r.haves.stored = map[string]Have{"nats": held}
stopR := r.run()
defer stopR()
if row.holdsTill {
@@ -1134,12 +1152,13 @@ func testADataModuleIsBackedUpFirstAndHeldWhenItFails(t *testing.T) {
if n != row.backups {
t.Errorf("%d backups for the answer, want %d", n, row.backups)
}
if row.unchanged && row.atStart == "" {
r.mu.Lock()
defer r.mu.Unlock()
if !slices.ContainsFunc(r.said, func(s string) bool { return strings.Contains(s, "nats's hold for a failed backup") }) {
t.Errorf("the hold's end is not said: %q", r.said)
}
r.mu.Lock()
defer r.mu.Unlock()
if row.says != "" && !slices.ContainsFunc(r.said, func(s string) bool { return strings.Contains(s, row.says) }) {
t.Errorf("the journal does not say %q: %q", row.says, r.said)
}
if row.never != "" && slices.ContainsFunc(r.said, func(s string) bool { return strings.Contains(s, row.never) }) {
t.Errorf("the journal says %q: %q", row.never, r.said)
}
})
}