From c08f6d0ff74dddc4fe54bc8bcad057b13d64b5a6 Mon Sep 17 00:00:00 2001 From: LHHDZ Date: Thu, 14 Jul 2022 19:45:01 +0800 Subject: [PATCH 1/3] File upload should succeed should return `ETag` instead of `Etag` at `/go-1.18.1/src/net/textproto/header.go:39`, header is canonicalized by `textproto.CanonicalMIMEHeaderKey` --- weed/s3api/s3api_object_handlers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index 4ad3454ba..e49d613c4 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -445,9 +445,9 @@ func (s3a *S3ApiServer) putToFiler(r *http.Request, uploadUrl string, dataReader func setEtag(w http.ResponseWriter, etag string) { if etag != "" { if strings.HasPrefix(etag, "\"") { - w.Header().Set("ETag", etag) + w.Header()["ETag"] = []string{etag} } else { - w.Header().Set("ETag", "\""+etag+"\"") + w.Header()["ETag"] = []string{"\"" + etag + "\""} } } } From aca20cd9f46d3eb890a7aed2921e35e85fc29dc9 Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 15 Jul 2022 00:42:13 -0700 Subject: [PATCH 2/3] more logging related to filer metadata subscription --- weed/filer/meta_aggregator.go | 2 +- weed/server/filer_grpc_server_sub_meta.go | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/weed/filer/meta_aggregator.go b/weed/filer/meta_aggregator.go index beade3201..c672ce342 100644 --- a/weed/filer/meta_aggregator.go +++ b/weed/filer/meta_aggregator.go @@ -185,7 +185,7 @@ func (ma *MetaAggregator) doSubscribeToOneFiler(f *Filer, self pb.ServerAddress, return nil } - glog.V(4).Infof("subscribing remote %s meta change: %v, clientId:%d", peer, time.Unix(0, lastTsNs), ma.filer.UniqueFileId) + glog.V(0).Infof("subscribing remote %s meta change: %v, clientId:%d", peer, time.Unix(0, lastTsNs), ma.filer.UniqueFileId) err = pb.WithFilerClient(true, peer, ma.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/weed/server/filer_grpc_server_sub_meta.go b/weed/server/filer_grpc_server_sub_meta.go index 6a4a5bb17..82261ca51 100644 --- a/weed/server/filer_grpc_server_sub_meta.go +++ b/weed/server/filer_grpc_server_sub_meta.go @@ -95,12 +95,15 @@ func (fs *FilerServer) SubscribeLocalMetadata(req *filer_pb.SubscribeMetadataReq alreadyKnown, clientName := fs.addClient(req.ClientName, peerAddress, req.ClientId) if alreadyKnown { - return fmt.Errorf("duplicated local subscription detected for client %s id %d", clientName, req.ClientId) + return fmt.Errorf("duplicated local subscription detected for client %s clientId:%d", clientName, req.ClientId) } - defer fs.deleteClient(clientName, req.ClientId) + defer func() { + glog.V(0).Infof(" - %v local subscribe %s clientId:%d", clientName, req.PathPrefix, req.ClientId) + fs.deleteClient(clientName, req.ClientId) + }() lastReadTime := time.Unix(0, req.SinceNs) - glog.V(0).Infof(" %v local subscribe %s from %+v", clientName, req.PathPrefix, lastReadTime) + glog.V(0).Infof(" + %v local subscribe %s from %+v clientId:%d", clientName, req.PathPrefix, lastReadTime, req.ClientId) eachEventNotificationFn := fs.eachEventNotificationFn(req, stream, clientName) From 1db012485f996df0615a1d6a7ece9faace2e536c Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 15 Jul 2022 01:03:17 -0700 Subject: [PATCH 3/3] mount: fix bug during busy writes fix https://github.com/chrislusf/seaweedfs/issues/3315 --- weed/filer/reader_cache.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/weed/filer/reader_cache.go b/weed/filer/reader_cache.go index 4c92f71c8..4f375e764 100644 --- a/weed/filer/reader_cache.go +++ b/weed/filer/reader_cache.go @@ -76,7 +76,9 @@ func (rc *ReaderCache) ReadChunkAt(buffer []byte, fileId string, cipherKey []byt rc.Lock() defer rc.Unlock() if cacher, found := rc.downloaders[fileId]; found { - return cacher.readChunkAt(buffer, offset) + if n, err := cacher.readChunkAt(buffer, offset); n != 0 && err == nil { + return n, err + } } if shouldCache || rc.lookupFileIdFn == nil { n, err := rc.chunkCache.ReadChunkAt(buffer, fileId, uint64(offset)) @@ -176,6 +178,9 @@ func (s *SingleChunkCacher) startCaching() { } func (s *SingleChunkCacher) destroy() { + s.Lock() + defer s.Unlock() + if s.data != nil { mem.Free(s.data) s.data = nil @@ -194,6 +199,10 @@ func (s *SingleChunkCacher) readChunkAt(buf []byte, offset int64) (int, error) { return 0, s.err } + if len(s.data) == 0 { + return 0, nil + } + return copy(buf, s.data[offset:]), nil }