Skip to content

Commit

Permalink
syncer(dm): fix log flood and performance when frequently call Snapsh…
Browse files Browse the repository at this point in the history
…ot (#4744)

close #4619
  • Loading branch information
lance6716 authored Mar 8, 2022
1 parent 444541f commit aacbbcf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dm/syncer/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ type CheckPoint interface {
// SaveGlobalPointForcibly saves the global binlog stream's checkpoint forcibly.
SaveGlobalPointForcibly(location binlog.Location)

// Snapshot make a snapshot of current checkpoint
// Snapshot make a snapshot of current checkpoint. If returns nil, it means nothing has changed since last call.
Snapshot(isSyncFlush bool) *SnapshotInfo

// FlushPointsExcept flushes the global checkpoint and tables'
Expand Down Expand Up @@ -376,6 +376,7 @@ func (cp *RemoteCheckPoint) Snapshot(isSyncFlush bool) *SnapshotInfo {
// make snapshot is visit in single thread, so depend on rlock should be enough
cp.snapshotSeq++
id := cp.snapshotSeq
cp.lastSnapshotCreationTime = time.Now()

tableCheckPoints := make(map[string]map[string]tablePoint, len(cp.points))
for s, tableCps := range cp.points {
Expand Down Expand Up @@ -412,7 +413,6 @@ func (cp *RemoteCheckPoint) Snapshot(isSyncFlush bool) *SnapshotInfo {
}

cp.snapshots = append(cp.snapshots, snapshot)
cp.lastSnapshotCreationTime = time.Now()
return &SnapshotInfo{
id: id,
globalPos: globalPoint.location,
Expand Down
4 changes: 2 additions & 2 deletions dm/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ func (s *Syncer) flushCheckPoints() error {
snapshotInfo, exceptTables, shardMetaSQLs, shardMetaArgs := s.createCheckpointSnapshot(true)

if snapshotInfo == nil {
s.tctx.L().Info("checkpoint has no change, skip sync flush checkpoint")
s.tctx.L().Debug("checkpoint has no change, skip sync flush checkpoint")
return nil
}

Expand Down Expand Up @@ -1204,7 +1204,7 @@ func (s *Syncer) flushCheckPointsAsync(asyncFlushJob *job) {
snapshotInfo, exceptTables, shardMetaSQLs, shardMetaArgs := s.createCheckpointSnapshot(false)

if snapshotInfo == nil {
s.tctx.L().Info("checkpoint has no change, skip async flush checkpoint", zap.Int64("job seq", asyncFlushJob.flushSeq))
s.tctx.L().Debug("checkpoint has no change, skip async flush checkpoint", zap.Int64("job seq", asyncFlushJob.flushSeq))
return
}

Expand Down

0 comments on commit aacbbcf

Please sign in to comment.