Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

lock on append metadata operation

chrisluf193942adce8
diff --git a/weed/server/filer_grpc_server.go b/weed/server/filer_grpc_server.go
index d79df1d2e4..d67bd425e6 100644
--- a/weed/server/filer_grpc_server.go
+++ b/weed/server/filer_grpc_server.go
@@ -3,6 +3,7 @@ package weed_server
import (
"context"
"fmt"
+ "github.com/seaweedfs/seaweedfs/weed/cluster"
"os"
"path/filepath"
"strconv"
@@ -240,8 +241,12 @@ func (fs *FilerServer) cleanupChunks(fullpath string, existingEntry *filer.Entry
func (fs *FilerServer) AppendToEntry(ctx context.Context, req *filer_pb.AppendToEntryRequest) (*filer_pb.AppendToEntryResponse, error) {
glog.V(4).Infof("AppendToEntry %v", req)
-
fullpath := util.NewFullPath(req.Directory, req.EntryName)
+
+ lockClient := cluster.NewLockClient(fs.grpcDialOption)
+ lock := lockClient.NewLock(fs.option.Host, string(fullpath))
+ defer lock.Unlock()
+
var offset int64 = 0
entry, err := fs.filer.FindEntry(ctx, fullpath)
if err == filer_pb.ErrNotFound {