From b948bdac7771a45968296c01a4e4c4ed970ff24f Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 17:55:42 -0800 Subject: [PATCH] chunkstore: an entry time past 2262 is unknown, not a wrapped value Review: the catalog reader converted the entry's seconds to nanoseconds without a range check, so an out-of-range mtime (year 9999) wrapped to a negative time where the HTTP reader had reported it unknown (0). The conversion is guarded; the master reader's refusal table has the out-of-range case again. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/frontend/chunkstore/layout_store.go | 5 ++++- seaweed-block/core/host/master/workspace_layout_head_test.go | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/seaweed-block/core/frontend/chunkstore/layout_store.go b/seaweed-block/core/frontend/chunkstore/layout_store.go index b5c325dfa6..7dfd198506 100644 --- a/seaweed-block/core/frontend/chunkstore/layout_store.go +++ b/seaweed-block/core/frontend/chunkstore/layout_store.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "math" "path" "strconv" "strings" @@ -64,7 +65,9 @@ func (s *LayoutStore) ReadHeadObserved(ctx context.Context) (h layout.Head, mtim if err != nil { return layout.Head{}, 0, false, err } - if sec := e.GetAttributes().GetMtime(); sec > 0 { + // A time not representable in nanoseconds (past 2262) is unknown, as is + // none: it never wraps to a wrong value. + if sec := e.GetAttributes().GetMtime(); sec > 0 && sec <= math.MaxInt64/int64(1e9) { mtimeNS = sec * int64(1e9) } return h, mtimeNS, true, nil diff --git a/seaweed-block/core/host/master/workspace_layout_head_test.go b/seaweed-block/core/host/master/workspace_layout_head_test.go index 0bbd426508..3d61be18a4 100644 --- a/seaweed-block/core/host/master/workspace_layout_head_test.go +++ b/seaweed-block/core/host/master/workspace_layout_head_test.go @@ -123,6 +123,7 @@ func TestWorkspaceLayoutHEADRefusalsAndStates(t *testing.T) { {name: "detached", valid: true}, {name: "live", state: "live", valid: true}, {name: "unknown mtime", valid: true, alter: func(e *filerpb.Entry) { e.Attributes = nil }}, + {name: "out-of-range mtime", valid: true, alter: func(e *filerpb.Entry) { e.Attributes = &filerpb.FuseAttributes{Mtime: 253402300799} }}, // year 9999 {name: "unclaimed", state: "unclaimed", sentinel: authority.ErrWorkspaceHeadUnclaimed}, {name: "deleted", state: layout.StateDeleted, sentinel: authority.ErrWorkspaceHeadDeleting}, {name: "missing generation", alter: func(e *filerpb.Entry) { delete(e.Extended, "swb.layout.gen") }}, @@ -182,7 +183,7 @@ func TestWorkspaceLayoutHEADRefusalsAndStates(t *testing.T) { } got, err := read(ctx, "v") wantTime := int64(100e9) - if tc.name == "unknown mtime" { + if tc.name == "unknown mtime" || tc.name == "out-of-range mtime" { wantTime = 0 } switch {