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

syncer(dm): fix log flood and performance when frequently call Snapshot #4744

Merged
merged 5 commits into from
Mar 8, 2022
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
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