mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
filer.sync: limit concurrency when fetching file chunks
fix https://github.com/seaweedfs/seaweedfs/issues/3787
This commit is contained in:
parent
ec46a34f33
commit
0452ae6a6c
|
@ -24,15 +24,17 @@ func (fs *FilerSink) replicateChunks(sourceChunks []*filer_pb.FileChunk, path st
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for chunkIndex, sourceChunk := range sourceChunks {
|
for chunkIndex, sourceChunk := range sourceChunks {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(chunk *filer_pb.FileChunk, index int) {
|
fs.executor.Execute(func() {
|
||||||
defer wg.Done()
|
func(chunk *filer_pb.FileChunk, index int) {
|
||||||
replicatedChunk, e := fs.replicateOneChunk(chunk, path)
|
defer wg.Done()
|
||||||
if e != nil {
|
replicatedChunk, e := fs.replicateOneChunk(chunk, path)
|
||||||
err = e
|
if e != nil {
|
||||||
return
|
err = e
|
||||||
}
|
return
|
||||||
replicatedChunks[index] = replicatedChunk
|
}
|
||||||
}(sourceChunk, chunkIndex)
|
replicatedChunks[index] = replicatedChunk
|
||||||
|
}(sourceChunk, chunkIndex)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ type FilerSink struct {
|
||||||
address string
|
address string
|
||||||
writeChunkByFiler bool
|
writeChunkByFiler bool
|
||||||
isIncremental bool
|
isIncremental bool
|
||||||
|
executor *util.LimitedConcurrentExecutor
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -53,6 +54,7 @@ func (fs *FilerSink) IsIncremental() bool {
|
||||||
func (fs *FilerSink) Initialize(configuration util.Configuration, prefix string) error {
|
func (fs *FilerSink) Initialize(configuration util.Configuration, prefix string) error {
|
||||||
fs.isIncremental = configuration.GetBool(prefix + "is_incremental")
|
fs.isIncremental = configuration.GetBool(prefix + "is_incremental")
|
||||||
fs.dataCenter = configuration.GetString(prefix + "dataCenter")
|
fs.dataCenter = configuration.GetString(prefix + "dataCenter")
|
||||||
|
fs.executor = util.NewLimitedConcurrentExecutor(32)
|
||||||
return fs.DoInitialize(
|
return fs.DoInitialize(
|
||||||
"",
|
"",
|
||||||
configuration.GetString(prefix+"grpcAddress"),
|
configuration.GetString(prefix+"grpcAddress"),
|
||||||
|
|
Loading…
Reference in a new issue