Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [cp24]Change memoryCheck write lock to read lock #37526

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions internal/datacoord/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ func (s *Server) Flush(ctx context.Context, req *datapb.FlushRequest) (*datapb.F
zap.Int64s("sealSegments", sealedSegmentIDs),
zap.Int("flushedSegmentsCount", len(flushSegmentIDs)),
zap.Time("timeOfSeal", timeOfSeal),
zap.Time("flushTs", tsoutil.PhysicalTime(ts)))
zap.Uint64("flushTs", ts),
zap.Time("flushTs in time", tsoutil.PhysicalTime(ts)))

return &datapb.FlushResponse{
Status: merr.Success(),
Expand Down Expand Up @@ -1227,7 +1228,8 @@ func (s *Server) WatchChannels(ctx context.Context, req *datapb.WatchChannelsReq
// GetFlushState gets the flush state of the collection based on the provided flush ts and segment IDs.
func (s *Server) GetFlushState(ctx context.Context, req *datapb.GetFlushStateRequest) (*milvuspb.GetFlushStateResponse, error) {
log := log.Ctx(ctx).With(zap.Int64("collection", req.GetCollectionID()),
zap.Time("flushTs", tsoutil.PhysicalTime(req.GetFlushTs()))).
zap.Uint64("flushTs", req.GetFlushTs()),
zap.Time("flushTs in time", tsoutil.PhysicalTime(req.GetFlushTs()))).
WithRateGroup("dc.GetFlushState", 1, 60)
if err := merr.CheckHealthy(s.GetStateCode()); err != nil {
return &milvuspb.GetFlushStateResponse{
Expand Down
2 changes: 1 addition & 1 deletion internal/datanode/syncmgr/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (t *SyncTask) Run() (err error) {
log.Info("segment removed", zap.Int64("segmentID", t.segment.SegmentID()), zap.String("channel", t.channelName))
}

log.Info("task done", zap.Float64("flushedSize", totalSize))
log.Info("task done", zap.Float64("flushedSize", totalSize), zap.Duration("timeTaken", t.tr.ElapseSpan()))

if !t.isFlush {
metrics.DataNodeAutoFlushBufferCount.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.SuccessLabel, t.level.String()).Inc()
Expand Down
11 changes: 9 additions & 2 deletions internal/datanode/writebuffer/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,16 @@
if !paramtable.Get().DataNodeCfg.MemoryForceSyncEnable.GetAsBool() {
return
}
startTime := time.Now()
m.mut.RLock()
defer func() {
dur := time.Since(startTime)
if dur > 30*time.Second {
log.Warn("memory check takes too long", zap.Duration("time", dur))
}

Check warning on line 101 in internal/datanode/writebuffer/manager.go

View check run for this annotation

Codecov / codecov/patch

internal/datanode/writebuffer/manager.go#L100-L101

Added lines #L100 - L101 were not covered by tests
m.mut.RUnlock()
}()

m.mut.Lock()
defer m.mut.Unlock()
for {
var total int64
var candidate WriteBuffer
Expand Down
Loading