mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-24 04:09:59 +08:00
add timestamp inside lock
This commit is contained in:
parent
9fa065f600
commit
bcf37346ef
@ -45,11 +45,11 @@ func (f *Filer) NotifyUpdateEvent(oldEntry, newEntry *Entry, deleteChunks bool)
|
||||
notification.Queue.SendMessage(fullpath, eventNotification)
|
||||
}
|
||||
|
||||
f.logMetaEvent(time.Now(), fullpath, eventNotification)
|
||||
f.logMetaEvent(fullpath, eventNotification)
|
||||
|
||||
}
|
||||
|
||||
func (f *Filer) logMetaEvent(ts time.Time, fullpath string, eventNotification *filer_pb.EventNotification) {
|
||||
func (f *Filer) logMetaEvent(fullpath string, eventNotification *filer_pb.EventNotification) {
|
||||
|
||||
dir, _ := util.FullPath(fullpath).DirAndName()
|
||||
|
||||
@ -63,7 +63,7 @@ func (f *Filer) logMetaEvent(ts time.Time, fullpath string, eventNotification *f
|
||||
return
|
||||
}
|
||||
|
||||
f.metaLogBuffer.AddToBuffer(ts, []byte(dir), data)
|
||||
f.metaLogBuffer.AddToBuffer([]byte(dir), data)
|
||||
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,18 @@ func NewLogBuffer(flushInterval time.Duration, flushFn func(startTime, stopTime
|
||||
return lb
|
||||
}
|
||||
|
||||
func (m *LogBuffer) AddToBuffer(ts time.Time, key, data []byte) {
|
||||
func (m *LogBuffer) AddToBuffer(key, data []byte) {
|
||||
|
||||
m.Lock()
|
||||
defer func() {
|
||||
m.Unlock()
|
||||
if m.notifyFn != nil {
|
||||
m.notifyFn()
|
||||
}
|
||||
}()
|
||||
|
||||
// need to put the timestamp inside the lock
|
||||
ts := time.Now()
|
||||
logEntry := &filer_pb.LogEntry{
|
||||
TsNs: ts.UnixNano(),
|
||||
PartitionKeyHash: util.HashToInt32(key),
|
||||
@ -58,14 +68,6 @@ func (m *LogBuffer) AddToBuffer(ts time.Time, key, data []byte) {
|
||||
|
||||
size := len(logEntryData)
|
||||
|
||||
m.Lock()
|
||||
defer func() {
|
||||
m.Unlock()
|
||||
if m.notifyFn != nil {
|
||||
m.notifyFn()
|
||||
}
|
||||
}()
|
||||
|
||||
if m.pos == 0 {
|
||||
m.startTime = ts
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user