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

Check perceived tablet type before taking a backup #4508

Merged
merged 1 commit into from
Jan 9, 2019
Merged
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
12 changes: 11 additions & 1 deletion go/vt/vttablet/tabletmanager/rpc_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ func (agent *ActionAgent) Backup(ctx context.Context, concurrency int, logger lo
return fmt.Errorf("cannot perform backup without my.cnf, please restart vttablet with a my.cnf file specified")
}

// update our type to BACKUP
// Check tablet type current process has.
// During a network partition it is possible that from the topology perspective this is no longer the master,
// but the process didn't find out about this.
// It is not safe to take backups from tablet in this state
currentTablet := agent.Tablet()
if currentTablet.Type == topodatapb.TabletType_MASTER {
return fmt.Errorf("type MASTER cannot take backup, if you really need to do this, restart vttablet in replica mode")
}

tablet, err := agent.TopoServer.GetTablet(ctx, agent.TabletAlias)
if err != nil {
return err
Expand All @@ -49,6 +57,8 @@ func (agent *ActionAgent) Backup(ctx context.Context, concurrency int, logger lo
return fmt.Errorf("type MASTER cannot take backup, if you really need to do this, restart vttablet in replica mode")
}
originalType := tablet.Type

// update our type to BACKUP
if _, err := topotools.ChangeType(ctx, agent.TopoServer, tablet.Alias, topodatapb.TabletType_BACKUP); err != nil {
return err
}
Expand Down