fix: separate maintenance diagnostics from callback failures

This commit is contained in:
pingqiu committed 2026-11-29 00:13:36 -08:00
1 parent 99edd52df7
commit b7a33f4f56
6 files changed
+11 -8

No files matched your search

@@ -57,7 +57,7 @@ func newChunkMaintenance(cat *chunkstore.BCatalog, ref chunkstore.VolumeRef, cle
diagnostic = "HEAD generation not read: HEAD absent"
}
defer func() {
durable.ReportMaintenance(ctx, durable.MaintenancePassStatus{Planned: int64(res.Planned), Removed: int64(res.Removed), PlannedChunks: int64(res.PlannedChunks), PlannedRoots: int64(res.PlannedRoots), PlannedSegments: int64(res.PlannedSegments), RemovedChunks: int64(res.Removed - res.Roots - res.Segments), RemovedRoots: int64(res.Roots), RemovedSegments: int64(res.Segments), HeadGen: head.Gen, Error: diagnostic})
durable.ReportMaintenance(ctx, durable.MaintenancePassStatus{Planned: int64(res.Planned), Removed: int64(res.Removed), PlannedChunks: int64(res.PlannedChunks), PlannedRoots: int64(res.PlannedRoots), PlannedSegments: int64(res.PlannedSegments), RemovedChunks: int64(res.Removed - res.Roots - res.Segments), RemovedRoots: int64(res.Roots), RemovedSegments: int64(res.Segments), HeadGen: head.Gen, HeadGenError: diagnostic})
}()
var rerr error
res, rerr = cat.RemoveUnreachableAll(ctx, ref, me, s)
@@ -244,10 +244,10 @@ func TestMaintenanceStatusRealPassAndTimeout(t *testing.T) {
expectedGen := before.Gen + 1
if kind == "head-unread" {
expectedGen = 0
if !strings.Contains(last["error"].(string), "HEAD generation not read") {
if last["error"] != "" || !strings.Contains(last["headGenError"].(string), "HEAD generation not read") {
t.Fatalf("missing diagnostic: %v", last)
}
} else if last["error"] != "" {
} else if last["error"] != "" || last["headGenError"] != "" {
t.Fatalf("unexpected error: %v", last)
}
if after.Gen != before.Gen+2 || m["passesOk"] != float64(1) || last["headGen"].(float64) != float64(expectedGen) {
@@ -13,6 +13,7 @@
"removedRoots": 0,
"removedSegments": 0,
"error": "",
"headGenError": "",
"headGen": 0
}
}
@@ -26,7 +26,8 @@ type MaintenancePassStatus struct {
RemovedChunks int64 `json:"removedChunks"` // chunk objects removed
RemovedRoots int64 `json:"removedRoots"` // root objects removed
RemovedSegments int64 `json:"removedSegments"` // segment objects removed
Error string `json:"error"` // one-line pass/observation error; empty when both succeeded
Error string `json:"error"` // one-line callback error; empty when the callback completed
HeadGenError string `json:"headGenError"` // diagnostic HEAD read error; empty when read
HeadGen uint64 `json:"headGen"` // observed cleaning HEAD generation; diagnostic only
}
@@ -59,12 +60,12 @@ func (m *maintenanceSlot) end(err error) {
defer m.mu.Unlock()
m.result.AtNs = time.Now().UnixNano()
if err != nil {
m.result.Error = strings.TrimSpace(m.result.Error + "; " + err.Error())
m.result.Error = strings.TrimPrefix(m.result.Error, "; ")
m.result.Error = err.Error()
} else {
m.s.PassesOK++
}
m.result.Error = strings.Join(strings.Fields(m.result.Error), " ")
m.result.HeadGenError = strings.Join(strings.Fields(m.result.HeadGenError), " ")
last := m.result
m.s.LastPass, m.s.InProgress, m.s.CurrentStartNs = &last, false, 0
}
@@ -37,7 +37,7 @@ breakdown. `removedChunks`, `removedRoots`, and `removedSegments` give the delet
breakdown; metadata is included in the total. A metadata-only pass therefore
never reports `removed: 0` when it reclaimed roots or segments. A pass that fails before entering
cleaning has zero counts and generation; these zeros do not prove a clean store.
An unreadable HEAD generation is named as "not read" in `error`; its zero
An unreadable HEAD generation is named as "not read" in `headGenError`; its zero
generation is unavailable, not a storage fact. This diagnostic does not fail the
cleaning callback or suppress its success count. A timed-out pass is recorded as an error and does not increment `passesOk`.
These are process-local observations, not authority or a safety decision.
+2 -1
View File
@@ -232,7 +232,8 @@ Durable store state of the served volume. Go type `volume.durableStatusBody`.
| `Volumes[].Chunk.Maintenance.lastPass.removedChunks` | int64 | chunk objects removed |
| `Volumes[].Chunk.Maintenance.lastPass.removedRoots` | int64 | root objects removed |
| `Volumes[].Chunk.Maintenance.lastPass.removedSegments` | int64 | segment objects removed |
| `Volumes[].Chunk.Maintenance.lastPass.error` | string | one-line pass/observation error; empty when both succeeded |
| `Volumes[].Chunk.Maintenance.lastPass.error` | string | one-line callback error; empty when the callback completed |
| `Volumes[].Chunk.Maintenance.lastPass.headGenError` | string | diagnostic HEAD read error; empty when read |
| `Volumes[].Chunk.Maintenance.lastPass.headGen` | uint64 | observed cleaning HEAD generation; diagnostic only |
| `Volumes[].Chunk.Attached` | bool | the chunk layer is attached to the remote |
| `Volumes[].Chunk.AwaitingAuthority` | bool | recovered; the layer waits for master authority to attach |