Browse Source

reduce busy waiting when reading metadata logs

pull/3103/head
chrislu 3 years ago
parent
commit
7e25a2d416
  1. 1
      weed/messaging/broker/broker_grpc_server_subscribe.go
  2. 2
      weed/server/filer_grpc_server_sub_meta.go
  3. 1
      weed/util/log_buffer/log_read.go

1
weed/messaging/broker/broker_grpc_server_subscribe.go

@ -128,7 +128,6 @@ func (broker *MessageBroker) Subscribe(stream messaging_pb.SeaweedMessaging_Subs
continue continue
} }
glog.Errorf("processed to %v: %v", lastReadTime, err) glog.Errorf("processed to %v: %v", lastReadTime, err)
time.Sleep(3127 * time.Millisecond)
if err != log_buffer.ResumeError { if err != log_buffer.ResumeError {
break break
} }

2
weed/server/filer_grpc_server_sub_meta.go

@ -63,7 +63,6 @@ func (fs *FilerServer) SubscribeMetadata(req *filer_pb.SubscribeMetadataRequest,
}, eachLogEntryFn) }, eachLogEntryFn)
if readInMemoryLogErr != nil { if readInMemoryLogErr != nil {
if readInMemoryLogErr == log_buffer.ResumeFromDiskError { if readInMemoryLogErr == log_buffer.ResumeFromDiskError {
time.Sleep(1127 * time.Millisecond)
continue continue
} }
glog.Errorf("processed to %v: %v", lastReadTime, readInMemoryLogErr) glog.Errorf("processed to %v: %v", lastReadTime, readInMemoryLogErr)
@ -127,7 +126,6 @@ func (fs *FilerServer) SubscribeLocalMetadata(req *filer_pb.SubscribeMetadataReq
return true return true
}, eachLogEntryFn) }, eachLogEntryFn)
if readInMemoryLogErr != nil { if readInMemoryLogErr != nil {
time.Sleep(1127 * time.Millisecond)
if readInMemoryLogErr == log_buffer.ResumeFromDiskError { if readInMemoryLogErr == log_buffer.ResumeFromDiskError {
continue continue
} }

1
weed/util/log_buffer/log_read.go

@ -34,6 +34,7 @@ func (logBuffer *LogBuffer) LoopProcessLogData(readerName string, startTreadTime
} }
bytesBuf, err = logBuffer.ReadFromBuffer(lastReadTime) bytesBuf, err = logBuffer.ReadFromBuffer(lastReadTime)
if err == ResumeFromDiskError { if err == ResumeFromDiskError {
time.Sleep(1127 * time.Millisecond)
return lastReadTime, ResumeFromDiskError return lastReadTime, ResumeFromDiskError
} }
// glog.V(4).Infof("%s ReadFromBuffer by %v", readerName, lastReadTime) // glog.V(4).Infof("%s ReadFromBuffer by %v", readerName, lastReadTime)

Loading…
Cancel
Save