mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-23 01:03:32 +08:00
Fix filer sync set offset (#5197)
* fix: compose 2mount with sync * fix: DATA RACE https://github.com/seaweedfs/seaweedfs/issues/5194 https://github.com/seaweedfs/seaweedfs/issues/5195
This commit is contained in:

committed by
GitHub

parent
0e8a54f6f6
commit
1169f94310
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type MetadataProcessor struct {
|
||||
@@ -14,15 +15,16 @@ type MetadataProcessor struct {
|
||||
activeJobsCond *sync.Cond
|
||||
concurrencyLimit int
|
||||
fn pb.ProcessMetadataFunc
|
||||
processedTsWatermark int64
|
||||
processedTsWatermark atomic.Int64
|
||||
}
|
||||
|
||||
func NewMetadataProcessor(fn pb.ProcessMetadataFunc, concurrency int) *MetadataProcessor {
|
||||
func NewMetadataProcessor(fn pb.ProcessMetadataFunc, concurrency int, offsetTsNs int64) *MetadataProcessor {
|
||||
t := &MetadataProcessor{
|
||||
fn: fn,
|
||||
activeJobs: make(map[int64]*filer_pb.SubscribeMetadataResponse),
|
||||
concurrencyLimit: concurrency,
|
||||
}
|
||||
t.processedTsWatermark.Store(offsetTsNs)
|
||||
t.activeJobsCond = sync.NewCond(&t.activeJobsLock)
|
||||
return t
|
||||
}
|
||||
@@ -61,7 +63,7 @@ func (t *MetadataProcessor) AddSyncJob(resp *filer_pb.SubscribeMetadataResponse)
|
||||
}
|
||||
}
|
||||
if isOldest {
|
||||
t.processedTsWatermark = resp.TsNs
|
||||
t.processedTsWatermark.Store(resp.TsNs)
|
||||
}
|
||||
t.activeJobsCond.Signal()
|
||||
}()
|
||||
|
Reference in New Issue
Block a user