From 950d83f00e1c590a471ea57bbff2db3971a4877e Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 27 Nov 2026 12:51:48 -0800 Subject: [PATCH] filer.sync: count only the not-found sentinel as a missing destination LookupEntry already maps every miss to filer_pb.ErrNotFound, plain-text ones included. Matching the sentinel's text in any error also counted an Unavailable lookup carrying that text as a miss, which let the caller delete and recreate the key. Co-Authored-By: Claude Opus 5.5 --- weed/replication/sink/filersink/filer_sink.go | 10 ++++------ .../sink/filersink/filer_sink_lookup_test.go | 2 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/weed/replication/sink/filersink/filer_sink.go b/weed/replication/sink/filersink/filer_sink.go index d64927a011..2d7cba5968 100644 --- a/weed/replication/sink/filersink/filer_sink.go +++ b/weed/replication/sink/filersink/filer_sink.go @@ -7,7 +7,6 @@ import ( "fmt" "math" "sort" - "strings" "sync" "sync/atomic" @@ -299,12 +298,11 @@ func (fs *FilerSink) entryMissing(key string) (bool, error) { return missing, err } -// isEntryNotFound reports a lookup not-found. The string check is a deliberate -// compatibility fallback: a cross-cluster gRPC error often arrives as a plain -// status string that no longer wraps the filer_pb.ErrNotFound sentinel, so -// errors.Is alone would miss it. +// isEntryNotFound reports a lookup not-found. filer_pb.LookupEntry already maps +// every miss, plain-text ones included, to the sentinel; the same text on any +// other status is a failed read. func isEntryNotFound(err error) bool { - return errors.Is(err, filer_pb.ErrNotFound) || strings.Contains(err.Error(), filer_pb.ErrNotFound.Error()) + return errors.Is(err, filer_pb.ErrNotFound) } func (fs *FilerSink) CreateEntry(key string, entry *filer_pb.Entry, signatures []int32) error { diff --git a/weed/replication/sink/filersink/filer_sink_lookup_test.go b/weed/replication/sink/filersink/filer_sink_lookup_test.go index d00bb25a93..bfbde5211d 100644 --- a/weed/replication/sink/filersink/filer_sink_lookup_test.go +++ b/weed/replication/sink/filersink/filer_sink_lookup_test.go @@ -38,6 +38,8 @@ func TestUpdateEntryRecreatesOnlyOnNotFound(t *testing.T) { {"not found", status.Error(codes.NotFound, filer_pb.ErrNotFound.Error()), false, 1}, {"canceled", status.Error(codes.Canceled, "context canceled"), true, 2}, {"unavailable", status.Error(codes.Unavailable, "connection refused"), true, 2}, + {"unavailable with the not-found text", status.Error(codes.Unavailable, filer_pb.ErrNotFound.Error()), true, 2}, + {"plain-text not found", status.Error(codes.Unknown, filer_pb.ErrNotFound.Error()), false, 1}, } { t.Run(tc.name, func(t *testing.T) { lis, err := net.Listen("tcp", "127.0.0.1:0")