Skip to content

Commit

Permalink
vtbackup: Stop replication after reaching goal position. (vitessio#5437)
Browse files Browse the repository at this point in the history
In xtrabackup mode, we would normally leave replication running when
taking a backup on a tablet. However, since this is not a serving
tablet, we stop replication in advance to help make xtrabackup's job
easier.

Signed-off-by: Anthony Yeh <enisoc@planetscale.com>
  • Loading branch information
enisoc authored Nov 15, 2019
1 parent bd7cb8a commit 0b3de7c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go/cmd/vtbackup/vtbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,17 @@ func takeBackup(ctx context.Context, topoServer *topo.Server, backupStorage back
}
}

// Stop replication and see where we are.
if err := mysqld.StopSlave(nil); err != nil {
return fmt.Errorf("can't stop replication: %v", err)
}

// Did we make any progress?
status, err := mysqld.SlaveStatus()
if err != nil {
return fmt.Errorf("can't get replication status: %v", err)
}
log.Infof("Replication caught up to at least %v", status.Position)
log.Infof("Replication caught up to %v", status.Position)
if !status.Position.AtLeast(masterPos) && status.Position.Equal(restorePos) {
return fmt.Errorf("not taking backup: replication did not make any progress from restore point: %v", restorePos)
}
Expand Down

0 comments on commit 0b3de7c

Please sign in to comment.