mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 19:34:43 +08:00
add signatures to messages to avoid double processing
This commit is contained in:
@@ -25,6 +25,7 @@ type FilerSink struct {
|
||||
ttlSec int32
|
||||
dataCenter string
|
||||
grpcDialOption grpc.DialOption
|
||||
signature int32
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -61,6 +62,7 @@ func (fs *FilerSink) initialize(grpcAddress string, dir string,
|
||||
fs.collection = collection
|
||||
fs.ttlSec = int32(ttlSec)
|
||||
fs.grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||
fs.signature = util.RandomInt32()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -69,7 +71,7 @@ func (fs *FilerSink) DeleteEntry(key string, isDirectory, deleteIncludeChunks bo
|
||||
dir, name := util.FullPath(key).DirAndName()
|
||||
|
||||
glog.V(1).Infof("delete entry: %v", key)
|
||||
err := filer_pb.Remove(fs, dir, name, deleteIncludeChunks, false, false, true)
|
||||
err := filer_pb.Remove(fs, dir, name, deleteIncludeChunks, false, false, true, fs.signature)
|
||||
if err != nil {
|
||||
glog.V(0).Infof("delete entry %s: %v", key, err)
|
||||
return fmt.Errorf("delete entry %s: %v", key, err)
|
||||
@@ -114,6 +116,7 @@ func (fs *FilerSink) CreateEntry(key string, entry *filer_pb.Entry) error {
|
||||
Chunks: replicatedChunks,
|
||||
},
|
||||
IsFromOtherCluster: true,
|
||||
Signatures: []int32{fs.signature},
|
||||
}
|
||||
|
||||
glog.V(1).Infof("create: %v", request)
|
||||
@@ -193,6 +196,7 @@ func (fs *FilerSink) UpdateEntry(key string, oldEntry *filer_pb.Entry, newParent
|
||||
Directory: newParentPath,
|
||||
Entry: existingEntry,
|
||||
IsFromOtherCluster: true,
|
||||
Signatures: []int32{fs.signature},
|
||||
}
|
||||
|
||||
if _, err := client.UpdateEntry(context.Background(), request); err != nil {
|
||||
|
Reference in New Issue
Block a user