Report newer pending work when list retirement is skipped

This commit is contained in:
pingqiu committed 2026-12-02 05:20:35 -08:00
1 parent 4c90321088
commit 9a4fc847a6
7 files changed
+58 -17

No files matched your search

@@ -58,7 +58,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, HeadGenError: diagnostic})
durable.ReportMaintenance(ctx, durable.MaintenancePassStatus{SkipReason: head.ListRetirementSkipReason(), 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)
@@ -67,7 +67,7 @@ func maintenanceJSON(t *testing.T, p *durable.DurableProvider) map[string]any {
}
func TestMaintenanceStatusRealPassAndTimeout(t *testing.T) {
for _, kind := range []string{"completed", "reachable", "metadata-only", "head-unread", "head-absent", "retention-only", "timeout"} {
for _, kind := range []string{"completed", "reachable", "metadata-only", "head-unread", "head-absent", "retention-only", "newer-pending-work", "timeout"} {
t.Run(kind, func(t *testing.T) {
timeout := kind == "timeout"
ctx := context.Background()
@@ -175,6 +175,22 @@ func TestMaintenanceStatusRealPassAndTimeout(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if kind == "newer-pending-work" {
// Simulate bytes persisted by a future producer, not a v1.1 producer path.
st, e := fixture.Catalog.Store(fixture.Ref)
if e != nil {
t.Fatal(e)
}
before.Version = layout.HeadVersion1
before.Lists = []layout.ListCursor{{Ref: layout.ListRef{Hash: layout.Sum([]byte("future pending page")).String(), Pages: 1}, Kind: layout.ListUploadIntent, Producer: "future", Generation: 1}}
if e = st.UpdateHead(ctx, before.Gen, before, layout.CauseCommit); e != nil {
t.Fatal(e)
}
before, _, err = fixture.Catalog.ReadHead(ctx, fixture.Ref)
if err != nil {
t.Fatal(err)
}
}
if !p.KickMaintenance("v1") {
t.Fatal("kick refused")
}
@@ -245,6 +261,13 @@ func TestMaintenanceStatusRealPassAndTimeout(t *testing.T) {
}
return
}
if kind == "newer-pending-work" {
if last["skipReason"] != "newer_pending_work" || !reflect.DeepEqual(before.Lists, after.Lists) {
t.Fatalf("reserved work silently skipped or consumed: status=%v lists=%v", last, after.Lists)
}
} else if _, present := last["skipReason"]; present {
t.Fatalf("unexpected skip reason: %v", last)
}
expectedGen := before.Gen + 1
if kind == "head-unread" || kind == "head-absent" {
expectedGen = 0
@@ -40,6 +40,18 @@ type RemovalResult struct {
After string
}
// ListRetirementSkipReason reports opaque work that this binary must preserve.
type ListRetirementSkipReason string
const SkipNewerPendingWork ListRetirementSkipReason = "newer_pending_work"
func (h Head) ListRetirementSkipReason() ListRetirementSkipReason {
if len(h.Lists) != 0 {
return SkipNewerPendingWork
}
return ""
}
// Page removes unreferenced metadata (RootDir or SegDir) or chunks (PoolDir,
// with shard). Every name is validated before any store effect. Metadata pages
// must be visited roots first, then segments, before chunk pages.
@@ -164,7 +176,7 @@ func (c *Cleaner) removePlanned(ctx context.Context, rels []string, kind string,
// Reserved producer chains are opaque to this binary. Do not retire
// list metadata while any are present: absence from List is not proof
// of abandonment. Serving and the existing List consumer continue.
if len(h.Lists) != 0 {
if h.ListRetirementSkipReason() != "" {
if len(rels) != 0 {
out.After = rels[len(rels)-1]
}
@@ -5,6 +5,8 @@ import (
"strings"
"sync"
"time"
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
)
// MaintenanceStatus is process-local observation of the holder's maintenance loop.
@@ -17,18 +19,19 @@ type MaintenanceStatus struct {
// MaintenancePassStatus describes the last completed or failed pass.
type MaintenancePassStatus struct {
AtNs int64 `json:"atNs"` // unix ns when the pass ended
Planned int64 `json:"planned"` // all objects considered for removal
Removed int64 `json:"removed"` // all objects removed
PlannedChunks int64 `json:"plannedChunks"` // chunk objects considered for removal
PlannedRoots int64 `json:"plannedRoots"` // root objects considered for removal
PlannedSegments int64 `json:"plannedSegments"` // segment objects considered for removal
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 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
SkipReason layout.ListRetirementSkipReason `json:"skipReason,omitempty"` // conservative list-page retirement skip; never changes serving or the pass outcome
AtNs int64 `json:"atNs"` // unix ns when the pass ended
Planned int64 `json:"planned"` // all objects considered for removal
Removed int64 `json:"removed"` // all objects removed
PlannedChunks int64 `json:"plannedChunks"` // chunk objects considered for removal
PlannedRoots int64 `json:"plannedRoots"` // root objects considered for removal
PlannedSegments int64 `json:"plannedSegments"` // segment objects considered for removal
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 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
}
type maintenanceSlot struct {
@@ -13,7 +13,9 @@ may repeat within the array or across `list` and `lists`. Version 0 refuses
this field. Every existing HEAD transition preserves the array byte-for-byte,
including the target identities, without consuming it or refusing serving.
When reserved chains are present, the compatibility cleaner retains all list
pages rather than interpreting their future ownership. Ordinary `list`
pages rather than interpreting their future ownership. Maintenance status
reports typed `lastPass.skipReason = newer_pending_work` for that conservative
skip; the reason is omitted normally and does not change the pass outcome. Ordinary `list`
continuation still works. No producer append, upload or handoff is enabled.
The page format needs no additional field: a later chain extension prepends
+1 -1
View File
@@ -1302,7 +1302,7 @@ Notes:
| ID | Statement | Transition | Enforced in | Guard | Model | Status |
|---|---|---|---|---|---|---|
| `INV-LIST-RESERVED-001` | Version-1 HEAD preserves at most three additional checked list cursors without consuming them or refusing serving; list-page retirement remains conservative while they are present. | M9 all existing HEAD updates | `core/frontend/chunkstore/layout/head.go` `check`, `clone`; `core/frontend/chunkstore/layout/remove.go` `Cleaner.Page` | `TestReservedListsGoldenBytes`, `TestReservedListsValidationAndClone`, `TestReservedListsCloneDoesNotAlias`, `TestReservedListsDoNotBecomeCompatibilitySweepCandidates`, `TestMachineReadableHeadCensusCoversRealTransitionFieldSets`, `TestListWritesMatchExportedCensus` | ProducerSeam r1 E1-E3: Bounded, NoLeak, NoDangling (encoding only; producer deferred) | DORMANT |
| `INV-LIST-RESERVED-001` | Version-1 HEAD preserves at most three additional checked list cursors without consuming them or refusing serving; list-page retirement remains conservative while they are present and reports newer_pending_work. | M9 all existing HEAD updates | `core/frontend/chunkstore/layout/head.go` `check`, `clone`; `core/frontend/chunkstore/layout/remove.go` `Cleaner.Page` | `TestMaintenanceStatusRealPassAndTimeout/newer-pending-work`, `TestReservedListsGoldenBytes`, `TestReservedListsValidationAndClone`, `TestReservedListsCloneDoesNotAlias`, `TestReservedListsDoNotBecomeCompatibilitySweepCandidates`, `TestMachineReadableHeadCensusCoversRealTransitionFieldSets`, `TestListWritesMatchExportedCensus` | ProducerSeam r1 E1-E3: Bounded, NoLeak, NoDangling (encoding only; producer deferred) | DORMANT |
| `INV-LIST-PUBLISH-001` | A list publication names only durable authenticated pages of its open session; an unknown reply never abandons their protection. | M9 snap -> snap | `list_chain.go` `StageListPage`, `RunPublishList` | `TestPublishList_Closure`, `TestRunPublishList_InterruptAtEveryStep`, `TestListSessionEndedDuringPageWriteCannotPublish` | PageChain 246-250; NoDangling | DORMANT |
| `INV-LIST-CURSOR-001` | The persisted list cursor advances only after its authenticated page's idempotent effects finish; a missing page never completes work. | M9 clean -> clean | `list_chain.go` `RunAdvanceList` | `TestAdvanceList_Closure`, `TestRunAdvanceList_InterruptAtEveryStep`, `TestListMissingConsumerPageNeverCompletes` | PageChain 246,251-253; NoLostWork | DORMANT |
| `INV-LIST-RETIRE-001` | List-page removal requires a clean session and the existing conditional mark/delete order; every page reached by HEAD is spared, including shared tails. | M9 clean removal | `remove.go` `Cleaner.removePlanned` | `TestListSweepSpareSessionAndReachableTail`, `TestListSharedTailSurvivesAbandonedChainAndResumes`, `TestLayoutStoreListPublishConsumeAndRetire` | PageChain 246,248-251; NoDangling | DORMANT |
+1
View File
@@ -240,6 +240,7 @@ Durable store state of the served volume. Go type `volume.durableStatusBody`.
| `Volumes[].Chunk.Maintenance.inProgress` | bool | a maintenance callback is running |
| `Volumes[].Chunk.Maintenance.currentStartNs` | int64 | unix ns start of the running pass; zero when idle |
| `Volumes[].Chunk.Maintenance.lastPass` | object | absent until a pass ends (omitted when empty) |
| `Volumes[].Chunk.Maintenance.lastPass.skipReason` | string | omitted normally; `newer_pending_work` means list-page retirement is conservatively skipped while reserved `lists` remain; serving and the pass outcome are unchanged |
| `Volumes[].Chunk.Maintenance.lastPass.atNs` | int64 | unix ns when the pass ended |
| `Volumes[].Chunk.Maintenance.lastPass.planned` | int64 | all objects considered for removal |
| `Volumes[].Chunk.Maintenance.lastPass.removed` | int64 | all objects removed |