carlos / platform Public

hibernate-verify: left-out hosts need proof, and rotate (review round 1)

Astra round 1 (NOT READY, census APPROVE) on the no-database leave-out:

P1, HA ownership. An HA host's database lives on whichever box holds its
lease, so absence on the drilling box proves nothing. An HA route is now
left out only when this box holds the lease, decided by the same lock
read freshness trusts (Drill.holdsLease, factored out of freshness and
used by both; read before the bracket closes). No holder, another
holder, or a lock read error keeps unverified/nothing_replicated. A host
whose prior verdict for the same incarnation shows it once had data
(passed or failed, a TXID, or a LastDecidedAt; an unknown prior identity
counts as the same) is never left out: losing both the file and the
copy stays visible. The run hands the record it loaded to the drill
(Drill.Prior).

P1, starvation. Left-out hosts are now recorded in the record's new
additive left_out field (host -> {at, incarnation}; the record stays v 2
and every reader decodes leniently, metrics.ReadVerify included).
OldestFirst orders a left-out host by its left_out time, so it rotates
behind never-seen and older hosts instead of taking the head of every
run. dbverify.MergeLeftOut keeps a host in hosts or left_out, never
both: this run's leave-outs go to left_out, an unvisited host keeps its
entry, any result (an abandoned attempt included) moves it to hosts,
and hosts gone from the fleet leave both. RemoveHost and PublishOver
clear left_out as they clear hosts.

P2, relative paths. noDatabase is false unless DBPath is absolute.

Tests: HA with and without proven ownership, prior-data cases, relative
path, a two-night --max 1 rotation, five left-out hosts eating the time
budget without starving a database host, a database reappearing, and
left_out in Merge, RemoveHost, PublishOver and ReadVerify.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev f4d861458eef877ebdd1031bb425d4d4e57491c5 parent 3d241ff
7 files changed, +548 −65
  • internal/dbverify/dbverify.go +62 −9
  • internal/dbverify/dbverify_test.go +112 −0
  • internal/metrics/verify_test.go +18 −0
  • internal/ops/hibernate_verify.go +84 −30
  • internal/ops/hibernate_verify_run_test.go +190 −6
  • internal/ops/hibernate_verify_test.go +70 −9
  • internal/ops/ops.go +12 −11

Intent

Human

<task-notification> <task-id>b8ql1j10l</task-id> <tool-use-id>toolu_01D3XuEQHKEXz4qRx3y9MPna</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ab362fc0-f177-4a7f-a92e-4a29ea210aad/tasks/b8ql1j10l.output</output-file> <status>completed</status> <summary>Background command "Astra review of the drill fix branch" completed (exit code 0)</summary> </task-notification>

diff --git a/internal/dbverify/dbverify.go b/internal/dbverify/dbverify.go
index 84ce3d015..f911ca8f7 100644
--- a/internal/dbverify/dbverify.go
+++ b/internal/dbverify/dbverify.go
@@ -164,11 +164,27 @@ func (v Verdict) OK() bool { return v.Result == ResultPassed }
func (v Verdict) Unverified() bool { return v.Result == ResultUnverified }
// Record is one box's standing at CheckedAt, at KeyFor(Box).
+//
+// LeftOut is the hosts the drill left out for having no database to back
+// up (nothing replicated, and no database where the drill can prove its
+// absence). It is scheduling history, not a verdict: no alert rule reads
+// it, and a host is in Hosts or in LeftOut, never both. It is additive:
+// the record stays v 2, every reader decodes it leniently, and a record
+// with none omits it.
type Record struct {
V int `json:"v"` // 2
Box string `json:"box"`
CheckedAt time.Time `json:"checked_at"`
Hosts map[string]Verdict `json:"hosts"`
+ LeftOut map[string]LeftOut `json:"left_out,omitempty"`
+}
+
+// LeftOut is when a run last left a host out, and the incarnation it found.
+// The drill orders the host by At, as if it had been decided then, so it
+// rotates behind hosts never seen or decided longer ago.
+type LeftOut struct {
+ At time.Time `json:"at"`
+ Incarnation string `json:"incarnation,omitempty"`
}
// Merge folds a run's verdicts into the prior record of box ref. prior may
@@ -200,15 +216,41 @@ type Record struct {
// three over. A result with no identity (zero) keeps the prior verdict's
// last known one; a prior with none is never "different".
func Merge(prior *Record, ref string, now time.Time, fleet []string, results map[string]Verdict) *Record {
+ return MergeLeftOut(prior, ref, now, fleet, results, nil)
+}
+
+// MergeLeftOut is Merge with the hosts this run left out (no database to
+// back up). A fleet host in leftOut goes to the record's LeftOut and out
+// of Hosts, whatever its prior verdict. A fleet host the run did not
+// visit keeps what it had: its verdict, or else its LeftOut entry. Any
+// result this run, an abandoned attempt included, puts the host in Hosts
+// and takes it out of LeftOut, so a host that has a database again, or
+// that no run can finish, is counted rather than hidden. Hosts no longer
+// in fleet leave LeftOut as they leave Hosts.
+func MergeLeftOut(prior *Record, ref string, now time.Time, fleet []string, results map[string]Verdict, leftOut map[string]LeftOut) *Record {
now = now.UTC()
rec := &Record{V: 2, Box: ref, CheckedAt: now, Hosts: map[string]Verdict{}}
+ addLeftOut := func(host string, lo LeftOut) {
+ if rec.LeftOut == nil {
+ rec.LeftOut = map[string]LeftOut{}
+ }
+ lo.At = lo.At.UTC()
+ rec.LeftOut[host] = lo
+ }
for _, host := range fleet {
var p Verdict
had := false
+ var plo LeftOut
+ wasLeftOut := false
if prior != nil {
p, had = prior.Hosts[host]
+ plo, wasLeftOut = prior.LeftOut[host]
}
r, visited := results[host]
+ if lo, out := leftOut[host]; out {
+ addLeftOut(host, lo)
+ continue
+ }
switch {
case visited && r.Result == ResultUnverified && r.Reason == ReasonNotReached:
v := p
@@ -224,6 +266,8 @@ func Merge(prior *Record, ref string, now time.Time, fleet []string, results map
rec.Hosts[host] = mergeOne(p, had, r, now)
case had:
rec.Hosts[host] = p
+ case wasLeftOut:
+ addLeftOut(host, plo)
default:
rec.Hosts[host] = Verdict{Result: ResultUnverified, Reason: ReasonNotReached, FirstSeen: now}
}
@@ -314,9 +358,9 @@ func Load(ctx context.Context, s release.Store, ref string) (*Record, error) {
return &rec, nil
}
-// RemoveHost drops host's verdict from box ref's own record: a moved
-// instance's replica is no longer this box's to verify (moves spec §6.3,
-// §7.6 local). Other boxes' records are never touched; their verdicts for
+// RemoveHost drops host's verdict, or its LeftOut entry, from box ref's
+// own record: a moved instance's replica is no longer this box's to
+// verify (moves spec §6.3, §7.6 local). Other boxes' records are never touched; their verdicts for
// the host leave at their next run, when Merge drops hosts no longer in
// their fleet. The load, the delete and the put run inside each CAS
// attempt (moves Plan 2 ruling G31), so a record changed between the read
@@ -339,10 +383,13 @@ func RemoveHost(ctx context.Context, s release.Store, ref, host string) error {
if err := json.Unmarshal(body, &rec); err != nil {
return fmt.Errorf("parse %s: %w", key, err)
}
- if _, ok := rec.Hosts[host]; !ok {
+ _, inHosts := rec.Hosts[host]
+ _, inLeftOut := rec.LeftOut[host]
+ if !inHosts && !inLeftOut {
return nil
}
delete(rec.Hosts, host)
+ delete(rec.LeftOut, host)
next, err := json.Marshal(&rec)
if err != nil {
return err
@@ -365,9 +412,10 @@ func Publish(ctx context.Context, s release.Store, rec *Record) error {
}
// PublishOver is Publish for a writer whose rec was built from an earlier
-// read of the record: known is the hosts that read held. Inside each CAS
-// attempt it reads the record now in the bucket, and every host in known
-// that the record no longer has was removed by someone else since (a
+// read of the record: known is the hosts that read held, in Hosts or
+// LeftOut (a removal clears either). Inside each CAS attempt it reads the
+// record now in the bucket, and every host in known that the record no
+// longer has, in either, was removed by someone else since (a
// landing move's RemoveHost, the record's only other writer): it is
// deleted from rec, so the publish does not put it back, and returned in
// dropped. Hosts not in known are rec's own news and are kept. A record
@@ -389,11 +437,16 @@ func PublishOver(ctx context.Context, s release.Store, rec *Record, known map[st
var now Record
if json.Unmarshal(cur, &now) == nil {
for _, h := range sortedHosts(known) {
- if _, still := now.Hosts[h]; still {
+ _, still := now.Hosts[h]
+ _, stillOut := now.LeftOut[h]
+ if still || stillOut {
continue
}
- if _, ok := rec.Hosts[h]; ok {
+ _, inHosts := rec.Hosts[h]
+ _, inLeftOut := rec.LeftOut[h]
+ if inHosts || inLeftOut {
delete(rec.Hosts, h)
+ delete(rec.LeftOut, h)
dropped = append(dropped, h)
}
}
diff --git a/internal/dbverify/dbverify_test.go b/internal/dbverify/dbverify_test.go
index 5caf92150..43229bc8f 100644
--- a/internal/dbverify/dbverify_test.go
+++ b/internal/dbverify/dbverify_test.go
@@ -3,6 +3,7 @@ package dbverify
import (
"bytes"
"context"
+ "encoding/json"
"errors"
"slices"
"strings"
@@ -677,3 +678,114 @@ func TestMergeUnknownIdentityKeepsTheLastKnown(t *testing.T) {
t.Fatalf("A, unknown, B kept A's history for B: %+v", v)
}
}
+
+// TestMergeLeftOut: a host the run left out (no database to back up) is
+// recorded under LeftOut, never in Hosts, whatever the prior verdict was.
+// An unvisited host keeps what it had, a verdict or a LeftOut entry; a
+// host with a verdict this run leaves LeftOut; a host started and
+// abandoned is an attempt like any other, so it goes to Hosts as
+// not_reached rather than staying hidden; and a host no longer in the
+// fleet leaves LeftOut as it leaves Hosts.
+func TestMergeLeftOut(t *testing.T) {
+ night1 := at("2026-11-13T03:00:00Z")
+ night2 := night1.Add(24 * time.Hour)
+ fleet := []string{"was-unverified.example.com", "still-out.example.com", "came-back.example.com",
+ "abandoned.example.com", "new.example.com"}
+ prior := &Record{V: 2, Box: "box-a", CheckedAt: night1,
+ Hosts: map[string]Verdict{
+ "was-unverified.example.com": {Result: ResultUnverified, Reason: "nothing_replicated", UnverifiedRuns: 2, FirstSeen: night1},
+ },
+ LeftOut: map[string]LeftOut{
+ "still-out.example.com": {At: night1, Incarnation: "s1"},
+ "came-back.example.com": {At: night1, Incarnation: "c1"},
+ "abandoned.example.com": {At: night1, Incarnation: "a1"},
+ "gone.example.com": {At: night1, Incarnation: "g1"},
+ }}
+ rec := MergeLeftOut(prior, "box-a", night2, fleet,
+ map[string]Verdict{
+ "came-back.example.com": passed(Identity{Incarnation: "c1"}, night2),
+ "abandoned.example.com": {Result: ResultUnverified, Reason: ReasonNotReached, AttemptedAt: night2},
+ },
+ map[string]LeftOut{"was-unverified.example.com": {At: night2, Incarnation: "w1"}})
+
+ if want := []string{"abandoned.example.com", "came-back.example.com", "new.example.com"}; !slices.Equal(sortedKeys(rec.Hosts), want) {
+ t.Fatalf("Hosts %v, want %v", sortedKeys(rec.Hosts), want)
+ }
+ if got := sortedLeftOut(rec.LeftOut); !slices.Equal(got, []string{"still-out.example.com", "was-unverified.example.com"}) {
+ t.Fatalf("LeftOut %v", got)
+ }
+ if lo := rec.LeftOut["was-unverified.example.com"]; !lo.At.Equal(night2) || lo.Incarnation != "w1" {
+ t.Fatalf("this run's entry: %+v", lo)
+ }
+ if lo := rec.LeftOut["still-out.example.com"]; !lo.At.Equal(night1) || lo.Incarnation != "s1" {
+ t.Fatalf("an unvisited host's entry was not carried: %+v", lo)
+ }
+ if v := rec.Hosts["came-back.example.com"]; !v.OK() {
+ t.Fatalf("came-back: %+v", v)
+ }
+ if v := rec.Hosts["abandoned.example.com"]; v.Reason != ReasonNotReached || !v.AttemptedAt.Equal(night2) {
+ t.Fatalf("abandoned: %+v", v)
+ }
+
+ // Merge is MergeLeftOut with nothing left out this run: it still
+ // carries an unvisited host's entry.
+ if lo, ok := Merge(prior, "box-a", night2, fleet, nil).LeftOut["still-out.example.com"]; !ok || !lo.At.Equal(night1) {
+ t.Fatalf("Merge dropped an unvisited LeftOut entry: %+v", lo)
+ }
+ // And a record with none says nothing about it on the wire.
+ body, err := json.Marshal(Merge(nil, "box-a", night2, []string{"a.example.com"}, nil))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if bytes.Contains(body, []byte("left_out")) {
+ t.Fatalf("an empty LeftOut was written: %s", body)
+ }
+}
+
+func sortedLeftOut(m map[string]LeftOut) []string {
+ out := make([]string, 0, len(m))
+ for k := range m {
+ out = append(out, k)
+ }
+ slices.Sort(out)
+ return out
+}
+
+// A landing move clears a left-out host from the landing box's record as
+// it clears a verdict, and a publish built before the landing does not put
+// it back.
+func TestRemoveHostAndPublishOverClearLeftOut(t *testing.T) {
+ ctx := context.Background()
+ s := release.NewDirStore(t.TempDir())
+ now := at("2026-11-13T03:00:00Z")
+ start := MergeLeftOut(nil, "box-a", now, []string{"a.example.com", "site.example.com"},
+ map[string]Verdict{"a.example.com": passed(idA, now)},
+ map[string]LeftOut{"site.example.com": {At: now, Incarnation: "s1"}})
+ if err := Publish(ctx, s, start); err != nil {
+ t.Fatal(err)
+ }
+ known := map[string]bool{"a.example.com": true, "site.example.com": true}
+ if err := RemoveHost(ctx, s, "box-a", "site.example.com"); err != nil {
+ t.Fatal(err)
+ }
+ got, err := Load(ctx, s, "box-a")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, ok := got.LeftOut["site.example.com"]; ok {
+ t.Fatalf("RemoveHost left the LeftOut entry: %+v", got.LeftOut)
+ }
+ later := now.Add(10 * time.Minute)
+ rec := MergeLeftOut(start, "box-a", later, []string{"a.example.com", "site.example.com"}, nil,
+ map[string]LeftOut{"site.example.com": {At: later, Incarnation: "s1"}})
+ dropped, err := PublishOver(ctx, s, rec, known)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !slices.Equal(dropped, []string{"site.example.com"}) {
+ t.Fatalf("dropped %v, want the removed left-out host", dropped)
+ }
+ if got, err = Load(ctx, s, "box-a"); err != nil || len(got.LeftOut) != 0 || !slices.Equal(sortedKeys(got.Hosts), []string{"a.example.com"}) {
+ t.Fatalf("published %+v, %v; want a alone and nothing left out", got, err)
+ }
+}
diff --git a/internal/metrics/verify_test.go b/internal/metrics/verify_test.go
index 1b4d41171..42d808711 100644
--- a/internal/metrics/verify_test.go
+++ b/internal/metrics/verify_test.go
@@ -252,3 +252,21 @@ func TestReadVerifyMissingAndBroken(t *testing.T) {
t.Fatalf("unknown version = %+v, %v", v, err)
}
}
+
+// TestReadVerifyIgnoresLeftOut: a host the drill left out for having no
+// database is recorded under left_out, which the rules do not read: it is
+// in no list, has no streak and is never behind. The field is additive
+// (the record stays v 2), so the reading of the hosts is unchanged.
+func TestReadVerifyIgnoresLeftOut(t *testing.T) {
+ now := time.Date(2026, 11, 20, 3, 0, 0, 0, time.UTC)
+ long := now.Add(-30 * 24 * time.Hour)
+ rec := &dbverify.Record{V: 2, Box: "b", CheckedAt: now,
+ Hosts: map[string]dbverify.Verdict{
+ "a.example.com": {Result: dbverify.ResultPassed, FirstSeen: long, LastDecidedAt: now},
+ },
+ LeftOut: map[string]dbverify.LeftOut{"site.example.com": {At: long, Incarnation: "s1"}}}
+ v := writeVerify(t, rec, now)
+ if !reflect.DeepEqual(v.Hosts, []string{"a.example.com"}) || len(v.UnverifiedStreak) != 0 || len(v.Behind) != 0 || len(v.Failed) != 0 {
+ t.Fatalf("reading %+v, want a.example.com alone, nothing behind", v)
+ }
+}
diff --git a/internal/ops/hibernate_verify.go b/internal/ops/hibernate_verify.go
index d1d711fe8..e6fb77162 100644
--- a/internal/ops/hibernate_verify.go
+++ b/internal/ops/hibernate_verify.go
@@ -25,6 +25,7 @@ import (
"net"
"net/url"
"os"
+ "path/filepath"
"slices"
"sort"
"strings"
@@ -193,6 +194,10 @@ type Drill struct {
Budget time.Duration
Max int
PublishEvery time.Duration
+ // Prior is the record this box published last (nil when none): a host
+ // whose verdict there, for the same incarnation, shows it once had data
+ // is never left out for having none now.
+ Prior *dbverify.Record
// staging is the data bucket the staged-copy check lists, opened once
// by VerifyHibernating; stagingErr is why it could not be.
@@ -231,10 +236,11 @@ type Drill struct {
// the live lease (P-14).
//
// A host whose bracket closed clean with nothing replicated, and whose
-// live database file is absent from this box, has no database to back up
-// (a static site, an instance that never opened one): it gets no verdict
-// and is left out (RunResults.LeftOut), so the record does not carry it at
-// all.
+// live database is proven absent (noDatabase, and for an HA host this box
+// holds its lease), has no database to back up (a static site, an
+// instance that never opened one): it gets no verdict and is left out
+// (RunResults.LeftOut), unless the prior record shows this incarnation
+// once had data. The record lists it under LeftOut, never in Hosts.
func VerifyHibernating(ctx context.Context, d Drill, hosts []HibernatingRoute, now func() time.Time, publish func(RunResults) bool) RunResults {
start := now()
runCtx, cancel := ctx, context.CancelFunc(func() {})
@@ -296,7 +302,7 @@ func VerifyHibernating(ctx context.Context, d Drill, hosts []HibernatingRoute, n
Prefix: activator.HibernatePrefix(d.Cfg.Prefix, rt.Host), AttemptedAt: now().UTC()})
case drillNoDatabase:
fmt.Printf("left out %s: no database here (nothing replicated, and no file at %s)\n", rt.Host, rt.DBPath)
- res.leaveOut(rt.Host)
+ res.leaveOut(rt.Host, dbverify.LeftOut{At: v.VerifiedAt, Incarnation: v.Identity.Incarnation})
default:
res.add(rt.Host, v)
printVerdict(rt.Host, v)
@@ -307,12 +313,12 @@ func VerifyHibernating(ctx context.Context, d Drill, hosts []HibernatingRoute, n
// RunResults is what a run has finished: a verdict per host it decided
// (or abandoned, as not_reached), and the hosts it left out because they
-// have no database to back up. A host left out has no verdict, and the
-// publisher keeps it out of the record: no streak, no coverage, and no
-// carry-over of an earlier verdict.
+// have no database to back up. A host left out has no verdict: the
+// publisher records it under the record's LeftOut, out of Hosts, so it
+// has no streak, no coverage, and no carry-over of an earlier verdict.
type RunResults struct {
Verdicts map[string]dbverify.Verdict
- LeftOut map[string]bool
+ LeftOut map[string]dbverify.LeftOut
}
// runResults is a run's verdicts so far, shared by the drill and the
@@ -320,7 +326,7 @@ type RunResults struct {
type runResults struct {
mu sync.Mutex
out map[string]dbverify.Verdict
- leftOut map[string]bool
+ leftOut map[string]dbverify.LeftOut
version int // bumped by every add and leaveOut
published int // the version the last successful ticker publish carried
}
@@ -336,13 +342,13 @@ func (r *runResults) add(host string, v dbverify.Verdict) {
}
// leaveOut records a host with no database to back up.
-func (r *runResults) leaveOut(host string) {
+func (r *runResults) leaveOut(host string, lo dbverify.LeftOut) {
r.mu.Lock()
defer r.mu.Unlock()
if r.leftOut == nil {
- r.leftOut = map[string]bool{}
+ r.leftOut = map[string]dbverify.LeftOut{}
}
- r.leftOut[host] = true
+ r.leftOut[host] = lo
r.version++
}
@@ -366,9 +372,9 @@ func (r *runResults) unpublished() (RunResults, int, bool) {
// snapshot copies the results; the caller holds mu.
func (r *runResults) snapshot() RunResults {
- left := make(map[string]bool, len(r.leftOut))
- for h := range r.leftOut {
- left[h] = true
+ left := make(map[string]dbverify.LeftOut, len(r.leftOut))
+ for h, lo := range r.leftOut {
+ left[h] = lo
}
return RunResults{Verdicts: cloneVerdicts(r.out), LeftOut: left}
}
@@ -430,8 +436,9 @@ const (
// drillDecided: the host has a verdict.
drillDecided
// drillNoDatabase: the bracket closed clean, the replica holds
- // nothing, and the live database file is absent from this box: there
- // is no database to back up, so the host is left out of the record.
+ // nothing, and the live database is proven absent: there is no
+ // database to back up, so the host is left out of the record. The
+ // verdict returned carries only the identity and VerifiedAt.
drillNoDatabase
)
@@ -501,6 +508,17 @@ func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() tim
return dbverify.Verdict{}, drillAbandoned
}
}
+ // An HA host's database lives on whichever box holds its lease, so
+ // absence here proves nothing unless that is this box: the same lease
+ // read freshness trusts, read before the bracket closes for the same
+ // reason.
+ ownsLease := false
+ if res.kind == restoreNothing && rt.HA {
+ ownsLease = d.holdsLease(ctx, prefix)
+ if ctx.Err() != nil {
+ return dbverify.Verdict{}, drillAbandoned
+ }
+ }
code, err = confirmDrillIdentity(ctx, d.Store, rt, id)
if err != nil {
@@ -529,9 +547,10 @@ func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() tim
case restoreNothing:
// Only here, with the bracket and the staging closed clean, and only
// on a proven absence: a file that is there is a database with
- // nothing replicated, a real gap.
- if noDatabase(rt.DBPath) {
- return dbverify.Verdict{}, drillNoDatabase
+ // nothing replicated, a real gap; so is a database this incarnation
+ // once had, now lost with its copy.
+ if noDatabase(rt.DBPath) && (!rt.HA || ownsLease) && !d.hadData(rt.Host, v.Identity) {
+ return v, drillNoDatabase
}
v.Result, v.Reason, v.Detail = dbverify.ResultUnverified, ReasonNothingReplicated, "no replica yet"
return v, drillDecided
@@ -558,15 +577,35 @@ func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() tim
// noDatabase reports whether the live database at path is proven absent
// from this box: lstat answers that nothing at all is there. Any other
// answer (a file, a dangling symlink, a permission or path error) is not
-// proof, and neither is a route with no path recorded.
+// proof, and neither is a route with no path recorded, or a relative one,
+// which would be looked up from the drill's working directory rather than
+// where the instance keeps it.
func noDatabase(path string) bool {
- if path == "" {
+ if path == "" || !filepath.IsAbs(path) {
return false
}
_, err := os.Lstat(path)
return errors.Is(err, fs.ErrNotExist)
}
+// hadData reports whether the prior record's verdict for host, about the
+// same incarnation as id, shows the instance once had data: passed or
+// failed, a restored position, or a decision ever. A prior verdict whose
+// identity is unknown is not proof of another incarnation, so it counts.
+func (d Drill) hadData(host string, id dbverify.Identity) bool {
+ if d.Prior == nil {
+ return false
+ }
+ p, ok := d.Prior.Hosts[host]
+ if !ok {
+ return false
+ }
+ if p.Identity != (dbverify.Identity{}) && p.Identity.Incarnation != id.Incarnation {
+ return false
+ }
+ return p.Result == dbverify.ResultPassed || p.Result == dbverify.ResultFailed || p.TXID != 0 || !p.LastDecidedAt.IsZero()
+}
+
// stagedCopy reports whether a move's staged copy of host waits under
// moves/<host>/ in this box's data bucket (member backups 2a, R1). That is
// what the activator's first wake trusts (promoteStagedReplica): any
@@ -714,11 +753,7 @@ func (d Drill) plan(ctx context.Context, prefix string) (dbdoor.RestorePlan, dbd
// box's sleeping host carries a release marker, which ParseOwner refuses:
// unknown, as the plan expects.
func (d Drill) freshness(ctx context.Context, rt HibernatingRoute, prefix string, counter uint32) (fresh string, stale bool, detail string) {
- held, owner, _, err := lockState(ctx, d.Cfg.Bucket, prefix, d.Cfg.Region)
- if err != nil || !held {
- return dbverify.FreshnessUnknown, false, ""
- }
- if o, ok := hafresh.ParseOwner(owner); !ok || o.Ref != d.SelfRef {
+ if !d.holdsLease(ctx, prefix) {
return dbverify.FreshnessUnknown, false, ""
}
switch f, detail := localFreshness(rt.DBPath, counter); f {
@@ -739,6 +774,19 @@ func (d Drill) freshness(ctx context.Context, rt HibernatingRoute, prefix string
}
}
+// holdsLease reports whether this box provably holds the live lease on the
+// replica at prefix (P-14): the lock read without error, held, and owned
+// by this box's reference. A group box's sleeping host carries a release
+// marker, which ParseOwner refuses: not held.
+func (d Drill) holdsLease(ctx context.Context, prefix string) bool {
+ held, owner, _, err := lockState(ctx, d.Cfg.Bucket, prefix, d.Cfg.Region)
+ if err != nil || !held {
+ return false
+ }
+ o, ok := hafresh.ParseOwner(owner)
+ return ok && o.Ref == d.SelfRef
+}
+
// drillSet is a run's hosts as this box records them: Drill to test, and
// NoAssignment verdicts for the group box's hosts no usable assignment
// gave it. Fleet is every host the box's record keeps, the two together;
@@ -802,11 +850,17 @@ func selectHosts(self boxself.Self, dataDir string, now time.Time, hosts []Hiber
// attempted (the later of VerifiedAt and AttemptedAt), most stale first,
// so a run that runs out of budget works through the fleet instead of
// drilling the same alphabetical prefix every night, and a host that was
-// started and abandoned waits behind the others. Hosts with no verdict at
-// all sort first — never verified is staler than any timestamp.
+// started and abandoned waits behind the others. A host left out for
+// having no database is ordered by when (LeftOut.At), as if decided then,
+// so it rotates rather than taking the head of every run. Hosts with no
+// verdict and no LeftOut entry sort first — never verified is staler than
+// any timestamp.
func OldestFirst(hosts []HibernatingRoute, prior *dbverify.Record) []HibernatingRoute {
stamp := map[string]time.Time{}
if prior != nil {
+ for h, lo := range prior.LeftOut {
+ stamp[h] = lo.At
+ }
for h, v := range prior.Hosts {
stamp[h] = v.VerifiedAt
if v.AttemptedAt.After(v.VerifiedAt) {
diff --git a/internal/ops/hibernate_verify_run_test.go b/internal/ops/hibernate_verify_run_test.go
index 96dcd2678..6d353db61 100644
--- a/internal/ops/hibernate_verify_run_test.go
+++ b/internal/ops/hibernate_verify_run_test.go
@@ -15,6 +15,7 @@ import (
"github.com/carlosframework/platform/internal/dbverify"
"github.com/carlosframework/platform/internal/metrics"
+ "github.com/carlosframework/platform/internal/registry"
)
// A failed periodic upload is not acknowledged: the next tick publishes
@@ -409,6 +410,7 @@ func TestRunHibernateVerifyLeavesOutHostsWithNoDatabase(t *testing.T) {
fx.writeSelf(fxSelf, false)
fx.replicaFor[fx.prefix(site)] = fx.empty
fx.replicaFor[fx.prefix(gap)] = fx.empty
+ fx.holdLease(site) // the rows are HA: absence proves nothing elsewhere
if err := os.WriteFile(filepath.Join(fx.dataDir, gap+".db"), []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
@@ -437,12 +439,18 @@ func TestRunHibernateVerifyLeavesOutHostsWithNoDatabase(t *testing.T) {
if !rec.Hosts[app].OK() {
t.Fatalf("%s: %+v", app, rec.Hosts[app])
}
+ if lo, ok := rec.LeftOut[site]; !ok || lo.Incarnation != fx.identity(site).Incarnation || !lo.At.Equal(fx.clock.Now()) {
+ t.Fatalf("left_out %+v, want %s at %s", rec.LeftOut, site, fx.clock.Now())
+ }
+ if len(rec.LeftOut) != 1 {
+ t.Fatalf("left_out %+v, want %s alone", rec.LeftOut, site)
+ }
local, err := fx.localCopy()
if err != nil {
t.Fatal(err)
}
- if got := sortedHosts(local); !slices.Equal(got, sortedHosts(rec)) {
- t.Fatalf("local copy names %v, the bucket's %v", got, sortedHosts(rec))
+ if got := sortedHosts(local); !slices.Equal(got, sortedHosts(rec)) || len(local.LeftOut) != 1 {
+ t.Fatalf("local copy names %v and left out %v, the bucket's %v", got, local.LeftOut, sortedHosts(rec))
}
// The alert rules read the local copy: nothing there for the host, a
// week on or not.
@@ -462,12 +470,13 @@ func TestRunHibernateVerifyLeavesOutHostsWithNoDatabase(t *testing.T) {
}
// TestRunHibernateVerifyLastHostLeftOutClearsTheRecord: when every host is
-// left out, the record published is empty, not the prior one.
+// left out, the record published has no verdicts, not the prior one's.
func TestRunHibernateVerifyLastHostLeftOutClearsTheRecord(t *testing.T) {
const site = "site.example.com"
fx := newRunFx(t, site)
fx.writeSelf(fxSelf, false)
fx.replicaFor[fx.prefix(site)] = fx.empty
+ fx.holdLease(site)
prior := &dbverify.Record{V: 2, Box: fxSelf, CheckedAt: at("2026-11-11T03:00:00Z"), Hosts: map[string]dbverify.Verdict{
site: {Result: dbverify.ResultUnverified, Reason: ReasonNothingReplicated, Identity: fx.identity(site),
UnverifiedRuns: 2, FirstSeen: at("2026-11-02T03:00:00Z"), VerifiedAt: at("2026-11-11T03:00:00Z")},
@@ -480,11 +489,11 @@ func TestRunHibernateVerifyLastHostLeftOutClearsTheRecord(t *testing.T) {
if code != 0 {
t.Fatalf("exited %d: %s", code, fx.logs)
}
- if rec := fx.published(fxSelf); rec == nil || len(rec.Hosts) != 0 {
- t.Fatalf("published %+v, want an empty record", rec)
+ if rec := fx.published(fxSelf); rec == nil || len(rec.Hosts) != 0 || len(rec.LeftOut) != 1 {
+ t.Fatalf("published %+v, want no verdicts and %s left out", rec, site)
}
if local, err := fx.localCopy(); err != nil || len(local.Hosts) != 0 {
- t.Fatalf("local copy %+v, %v; want an empty record", local, err)
+ t.Fatalf("local copy %+v, %v; want no verdicts", local, err)
}
}
@@ -545,3 +554,178 @@ func TestRunHibernateVerifyFleetBoxWithoutDeploymentStore(t *testing.T) {
})
}
}
+
+// holdLease makes this box the lease holder of host's replica, as
+// freshness reads it, and nobody the holder of any other.
+func (fx *runFx) holdLease(host string) {
+ fx.t.Helper()
+ swap(fx.t, &lockState, func(_ context.Context, _, location, _ string) (bool, string, time.Time, error) {
+ if location == fx.prefix(host) {
+ return true, selfOwner(fxSelf), time.Now().Add(time.Minute), nil
+ }
+ return false, "", time.Time{}, nil
+ })
+}
+
+// addPlain puts non-HA sleeping rows and their records in the run fixture:
+// a host on this box alone, whose absence here is proof.
+func (fx *runFx) addPlain(hosts ...string) {
+ fx.t.Helper()
+ for _, h := range hosts {
+ fx.addRoute(registry.Route{Host: h, Hibernate: true})
+ fx.putRecord(fxAccount, h, time.Date(2026, 9, 1, 0, 0, 0, 0, time.UTC), nil)
+ }
+}
+
+// night runs the drill once, a day after the last, and returns what it
+// printed and the hosts it restored.
+func (fx *runFx) night(r hibernateRun) (out string, restored []string) {
+ fx.t.Helper()
+ fx.clock.Advance(24 * time.Hour)
+ fx.writeSelf(fxSelf, false)
+ fx.stubVerify(func(_ context.Context, prefix, _ string, _ uint64) (uint32, error) {
+ restored = append(restored, filepath.Base(prefix))
+ return 1, nil
+ })
+ var code int
+ out = captureStdout(fx.t, func() { code = r.run(context.Background()) })
+ if code != 0 {
+ fx.t.Fatalf("exited %d: %s\n%s", code, fx.logs, out)
+ }
+ return out, restored
+}
+
+// TestRunHibernateVerifyLeftOutHostsRotate: a host left out is recorded
+// with when, and the next run orders it as if decided then, so under a
+// cap of one the host with a database is drilled on the second night
+// rather than never (Astra P1: a host with no prior verdict sorted first
+// every night and took the only visit).
+func TestRunHibernateVerifyLeftOutHostsRotate(t *testing.T) {
+ const site, db = "a-site.example.com", "b-db.example.com"
+ fx := newRunFx(t)
+ fx.addPlain(site, db)
+ fx.replicaFor[fx.prefix(site)] = fx.empty
+ r := fx.runner()
+ r.Max = 1
+
+ if _, restored := fx.night(r); len(restored) != 0 {
+ t.Fatalf("night 1 restored %v, want the site (alphabetically first) alone, which restores nothing", restored)
+ }
+ rec := fx.published(fxSelf)
+ if _, ok := rec.LeftOut[site]; !ok || rec.Hosts[db].Reason != dbverify.ReasonNotReached {
+ t.Fatalf("after night 1: %+v", rec)
+ }
+ if _, restored := fx.night(r); !slices.Equal(restored, []string{db}) {
+ t.Fatalf("night 2 restored %v, want %s", restored, db)
+ }
+ rec = fx.published(fxSelf)
+ if !rec.Hosts[db].OK() {
+ t.Fatalf("%s after night 2: %+v", db, rec.Hosts[db])
+ }
+ if _, ok := rec.LeftOut[site]; !ok {
+ t.Fatalf("the unvisited site lost its entry: %+v", rec.LeftOut)
+ }
+ if _, ok := rec.Hosts[site]; ok {
+ t.Fatalf("the unvisited site gained a verdict: %+v", rec.Hosts[site])
+ }
+}
+
+// TestRunHibernateVerifyManyLeftOutHostsDoNotStarve: hosts with no
+// database that eat the run's time budget every night still leave room,
+// within two nights, for the one host with a database, and the run goes
+// on rotating through all of them.
+func TestRunHibernateVerifyManyLeftOutHostsDoNotStarve(t *testing.T) {
+ sites := []string{"s1.example.com", "s2.example.com", "s3.example.com", "s4.example.com", "s5.example.com"}
+ const db = "z-db.example.com"
+ fx := newRunFx(t)
+ fx.addPlain(append(slices.Clone(sites), db)...)
+ for _, h := range sites {
+ fx.replicaFor[fx.prefix(h)] = fx.empty
+ // Each listing of an empty replica takes 20 minutes of the run's
+ // 45-minute budget: three hosts a night.
+ fx.onList[fx.prefix(h)] = func() { fx.clock.Advance(20 * time.Minute) }
+ }
+ r := fx.runner()
+ drilled := 0
+ first := 0
+ for n := 1; n <= 6; n++ {
+ if _, restored := fx.night(r); slices.Contains(restored, db) {
+ drilled++
+ if first == 0 {
+ first = n
+ }
+ }
+ }
+ if first == 0 || first > 2 {
+ t.Fatalf("%s first drilled on night %d, want by night 2", db, first)
+ }
+ if drilled < 2 {
+ t.Fatalf("%s drilled %d times in six nights, want the rotation to come back to it", db, drilled)
+ }
+ rec := fx.published(fxSelf)
+ if want := slices.Clone(sites); !slices.Equal(sortedLeftOutHosts(rec), want) {
+ t.Fatalf("left out %v, want %v", sortedLeftOutHosts(rec), want)
+ }
+ if got := sortedHosts(rec); !slices.Equal(got, []string{db}) {
+ t.Fatalf("record names %v, want %s alone", got, db)
+ }
+}
+
+func sortedLeftOutHosts(rec *dbverify.Record) []string {
+ var out []string
+ for h := range rec.LeftOut {
+ out = append(out, h)
+ }
+ slices.Sort(out)
+ return out
+}
+
+// TestRunHibernateVerifyDatabaseReappears: a host left out on one night
+// whose replica holds a database on the next is drilled as any other: it
+// leaves left_out and gets its verdict.
+func TestRunHibernateVerifyDatabaseReappears(t *testing.T) {
+ const site = "site.example.com"
+ fx := newRunFx(t)
+ fx.addPlain(site)
+ fx.replicaFor[fx.prefix(site)] = fx.empty
+ r := fx.runner()
+ fx.night(r)
+ if rec := fx.published(fxSelf); len(rec.LeftOut) != 1 || len(rec.Hosts) != 0 {
+ t.Fatalf("after night 1: %+v", rec)
+ }
+ delete(fx.replicaFor, fx.prefix(site)) // the instance opened a database, and it replicated
+ if _, restored := fx.night(r); !slices.Equal(restored, []string{site}) {
+ t.Fatalf("night 2 restored %v", restored)
+ }
+ rec := fx.published(fxSelf)
+ if len(rec.LeftOut) != 0 || !rec.Hosts[site].OK() {
+ t.Fatalf("after night 2: hosts %+v, left out %+v; want a pass and nothing left out", rec.Hosts, rec.LeftOut)
+ }
+}
+
+// TestRunHibernateVerifyPriorDataIsNeverLeftOut: a host whose record, for
+// this incarnation, shows it once restored, and which now has neither a
+// replica nor a file, is a loss, not a host without a database: it stays
+// unverified, nothing_replicated, and its streak moves. The run hands the
+// record it loaded to the drill.
+func TestRunHibernateVerifyPriorDataIsNeverLeftOut(t *testing.T) {
+ const site = "site.example.com"
+ fx := newRunFx(t)
+ fx.addPlain(site)
+ fx.replicaFor[fx.prefix(site)] = fx.empty
+ prior := &dbverify.Record{V: 2, Box: fxSelf, CheckedAt: fx.clock.Now(), Hosts: map[string]dbverify.Verdict{
+ site: {Result: dbverify.ResultPassed, Identity: fx.identity(site), TXID: 9, FirstSeen: at("2026-11-02T03:00:00Z"),
+ VerifiedAt: fx.clock.Now(), LastDecidedAt: fx.clock.Now()},
+ }}
+ if err := dbverify.Publish(context.Background(), fx.store, prior); err != nil {
+ t.Fatal(err)
+ }
+ fx.night(fx.runner())
+ rec := fx.published(fxSelf)
+ if v := rec.Hosts[site]; !v.Unverified() || v.Reason != ReasonNothingReplicated || v.UnverifiedRuns != 1 {
+ t.Fatalf("%s: %+v, want unverified/nothing_replicated, streak 1", site, v)
+ }
+ if len(rec.LeftOut) != 0 {
+ t.Fatalf("left out %+v", rec.LeftOut)
+ }
+}
diff --git a/internal/ops/hibernate_verify_test.go b/internal/ops/hibernate_verify_test.go
index a3c1fe5d6..fd3905c04 100644
--- a/internal/ops/hibernate_verify_test.go
+++ b/internal/ops/hibernate_verify_test.go
@@ -439,11 +439,15 @@ func TestVerifyHibernatingVerdicts(t *testing.T) {
// TestVerifyHibernatingLeavesOutAHostWithNoDatabase: a host whose replica
// holds nothing and whose live database file is absent from this box has
// no database to back up (a static site, an instance that never opened
-// one). It gets no verdict: the run leaves it out. Only a proven absence
-// counts: a file that is there, any other answer from the disk, and a
-// route with no database path keep nothing_replicated. And the leave-out
-// comes last: a host the bracket refused, or whose bracket did not close
-// clean, keeps the verdict that says so.
+// one). It gets no verdict: the run leaves it out, with when and the
+// incarnation. Only a proven absence counts: a file that is there, any
+// other answer from the disk, a relative path, and a route with no
+// database path keep nothing_replicated. Absence here proves nothing for
+// an HA host unless this box holds its lease (the evidence freshness
+// trusts); nor for a host whose prior verdict, for this incarnation,
+// shows it once had data. And the leave-out comes last: a host the
+// bracket refused, or whose bracket did not close clean, keeps the
+// verdict that says so.
func TestVerifyHibernatingLeavesOutAHostWithNoDatabase(t *testing.T) {
const host = "site.example.com"
dir := t.TempDir()
@@ -459,9 +463,29 @@ func TestVerifyHibernatingLeavesOutAHostWithNoDatabase(t *testing.T) {
if err := os.Symlink(filepath.Join(dir, "nowhere.db"), dangling); err != nil {
t.Fatal(err)
}
+ lock := func(held bool, owner string, err error) func(fx *drillFx) {
+ return func(fx *drillFx) {
+ swap(fx.t, &lockState, func(_ context.Context, _, location, _ string) (bool, string, time.Time, error) {
+ if location != fx.prefix(host) {
+ fx.t.Errorf("lock read at %s, want %s", location, fx.prefix(host))
+ }
+ return held, owner, time.Now().Add(time.Minute), err
+ })
+ }
+ }
+ prior := func(mutate func(fx *drillFx, v *dbverify.Verdict)) func(fx *drillFx) dbverify.Verdict {
+ return func(fx *drillFx) dbverify.Verdict {
+ v := dbverify.Verdict{Result: dbverify.ResultUnverified, Reason: ReasonNothingReplicated, Identity: fx.identity(host),
+ UnverifiedRuns: 2, FirstSeen: at("2026-11-01T03:00:00Z"), VerifiedAt: at("2026-11-11T03:00:00Z")}
+ mutate(fx, &v)
+ return v
+ }
+ }
cases := map[string]struct {
dbPath string
+ ha bool
setup func(fx *drillFx)
+ prior func(fx *drillFx) dbverify.Verdict
leftOut bool
reason string
}{
@@ -470,6 +494,7 @@ func TestVerifyHibernatingLeavesOutAHostWithNoDatabase(t *testing.T) {
"stat fails another way": {dbPath: filepath.Join(notADir, "x.db"), reason: ReasonNothingReplicated},
"a dangling symlink": {dbPath: dangling, reason: ReasonNothingReplicated},
"no database path recorded": {dbPath: "", reason: ReasonNothingReplicated},
+ "a relative database path": {dbPath: filepath.Join("no-such-dir", "site.db"), reason: ReasonNothingReplicated},
"no record": {dbPath: absent, reason: dbverify.ReasonNoRecord,
setup: func(fx *drillFx) { fx.deleteRecord(fxAccount, host) }},
"a staged copy waits": {dbPath: absent, reason: ReasonMoving,
@@ -480,6 +505,35 @@ func TestVerifyHibernatingLeavesOutAHostWithNoDatabase(t *testing.T) {
setup: func(fx *drillFx) {
fx.onList[fx.prefix(host)] = func() { fx.deleteRecord(fxAccount, host) }
}},
+
+ "HA, this box holds the lease": {dbPath: absent, ha: true, leftOut: true,
+ setup: lock(true, selfOwner(fxSelf), nil)},
+ "HA, no lease holder": {dbPath: absent, ha: true, reason: ReasonNothingReplicated,
+ setup: lock(false, "", nil)},
+ "HA, another box holds the lease": {dbPath: absent, ha: true, reason: ReasonNothingReplicated,
+ setup: lock(true, selfOwner("box-b"), nil)},
+ "HA, the lease cannot be read": {dbPath: absent, ha: true, reason: ReasonNothingReplicated,
+ setup: lock(true, selfOwner(fxSelf), errors.New("SlowDown"))},
+
+ "prior unverified, never decided": {dbPath: absent, leftOut: true,
+ prior: prior(func(*drillFx, *dbverify.Verdict) {})},
+ "prior passed, same incarnation": {dbPath: absent, reason: ReasonNothingReplicated,
+ prior: prior(func(_ *drillFx, v *dbverify.Verdict) { v.Result, v.Reason = dbverify.ResultPassed, "" })},
+ "prior failed, same incarnation": {dbPath: absent, reason: ReasonNothingReplicated,
+ prior: prior(func(_ *drillFx, v *dbverify.Verdict) { v.Result, v.Reason = dbverify.ResultFailed, ReasonRestoreError })},
+ "prior restored a position": {dbPath: absent, reason: ReasonNothingReplicated,
+ prior: prior(func(_ *drillFx, v *dbverify.Verdict) { v.TXID = 7 })},
+ "prior was decided once": {dbPath: absent, reason: ReasonNothingReplicated,
+ prior: prior(func(_ *drillFx, v *dbverify.Verdict) { v.LastDecidedAt = at("2026-11-05T03:00:00Z") })},
+ "prior passed, identity unknown": {dbPath: absent, reason: ReasonNothingReplicated,
+ prior: prior(func(_ *drillFx, v *dbverify.Verdict) {
+ v.Result, v.Reason, v.Identity = dbverify.ResultPassed, "", dbverify.Identity{}
+ })},
+ "prior passed, another incarnation": {dbPath: absent, leftOut: true,
+ prior: prior(func(_ *drillFx, v *dbverify.Verdict) {
+ v.Result, v.Reason = dbverify.ResultPassed, ""
+ v.Identity.Incarnation = "an-earlier-one"
+ })},
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
@@ -489,13 +543,20 @@ func TestVerifyHibernatingLeavesOutAHostWithNoDatabase(t *testing.T) {
c.setup(fx)
}
rt := fx.routes(host)
- rt[0].DBPath = c.dbPath
- res := fx.runAll(context.Background(), fx.drill(), rt, nil)
+ rt[0].DBPath, rt[0].HA = c.dbPath, c.ha
+ d := fx.drill()
+ if c.prior != nil {
+ d.Prior = &dbverify.Record{V: 2, Box: fxSelf, Hosts: map[string]dbverify.Verdict{host: c.prior(fx)}}
+ }
+ res := fx.runAll(context.Background(), d, rt, nil)
v, decided := res.Verdicts[host]
+ lo, left := res.LeftOut[host]
switch {
- case c.leftOut && (decided || !res.LeftOut[host]):
+ case c.leftOut && (decided || !left):
t.Fatalf("verdict %+v (decided %v), left out %v; want no verdict, left out", v, decided, res.LeftOut)
- case !c.leftOut && (!decided || res.LeftOut[host]):
+ case c.leftOut && (!lo.At.Equal(fx.clock.Now()) || lo.Incarnation != fx.identity(host).Incarnation):
+ t.Fatalf("left out as %+v, want at %s, incarnation %s", lo, fx.clock.Now(), fx.identity(host).Incarnation)
+ case !c.leftOut && (!decided || left):
t.Fatalf("left out %v, verdict %v; want unverified/%s", res.LeftOut, decided, c.reason)
case !c.leftOut && (!v.Unverified() || v.Reason != c.reason):
t.Fatalf("verdict %s/%s, want unverified/%s (%+v)", v.Result, v.Reason, c.reason, v)
diff --git a/internal/ops/ops.go b/internal/ops/ops.go
index 14a325de0..93951c754 100644
--- a/internal/ops/ops.go
+++ b/internal/ops/ops.go
@@ -553,7 +553,7 @@ func (r hibernateRun) run(ctx context.Context) int {
defer os.RemoveAll(tmp)
d := Drill{Cfg: r.Cfg, Store: store, Region: r.Region, SelfRef: ref, TmpDir: tmp,
- Budget: r.Budget, Max: r.Max, PublishEvery: r.PublishEvery}
+ Budget: r.Budget, Max: r.Max, PublishEvery: r.PublishEvery, Prior: prior}
results := VerifyHibernating(ctx, d, OldestFirst(set.Drill, prior), r.Now, pub.publish)
rec := pub.last
left := len(results.LeftOut)
@@ -643,6 +643,9 @@ func newVerifyPublisher(ctx context.Context, store release.Store, ref string, pr
for h := range prior.Hosts {
p.known[h] = true
}
+ for h := range prior.LeftOut {
+ p.known[h] = true
+ }
}
return p
}
@@ -654,9 +657,9 @@ func newVerifyPublisher(ctx context.Context, store release.Store, ref string, pr
// whether or not the publish succeeded, so the box's own alerts see it.
// It reports whether the bucket took the record.
//
-// A host the run left out (no database to back up) is taken out of the
-// fleet before the merge, so neither its verdict from the run-start record
-// nor a not_reached is carried for it.
+// A host the run left out (no database to back up) goes to the record's
+// LeftOut (dbverify.MergeLeftOut), so neither its verdict from the
+// run-start record nor a not_reached is carried for it.
func (p *verifyPublisher) publish(results RunResults) bool {
all := make(map[string]dbverify.Verdict, len(results.Verdicts)+len(p.extra))
for h, v := range p.extra {
@@ -665,15 +668,10 @@ func (p *verifyPublisher) publish(results RunResults) bool {
for h, v := range results.Verdicts {
all[h] = v
}
- fleet := make([]string, 0, len(p.fleet))
- for _, h := range p.fleet {
- if !results.LeftOut[h] {
- fleet = append(fleet, h)
- }
- }
- rec := dbverify.Merge(p.prior, p.ref, p.now(), fleet, all)
+ rec := dbverify.MergeLeftOut(p.prior, p.ref, p.now(), p.fleet, all, results.LeftOut)
for h := range p.dropped {
delete(rec.Hosts, h)
+ delete(rec.LeftOut, h)
}
ctx, cancel := context.WithTimeout(context.WithoutCancel(p.ctx), publishTimeout)
defer cancel()
@@ -689,6 +687,9 @@ func (p *verifyPublisher) publish(results RunResults) bool {
for h := range rec.Hosts {
p.known[h] = true
}
+ for h := range rec.LeftOut {
+ p.known[h] = true
+ }
fmt.Printf("hibernate-verify: published %s (%d hosts, %d unverified%s)\n", dbverify.KeyFor(p.ref), len(rec.Hosts), rec.Unverified(), leftOutNote(len(results.LeftOut)))
} else {
p.logf("hibernate-verify: NOT PUBLISHED: %v; the verdicts exist only in this log and %s", err, localVerifyPath(p.dataDir))