Skip to content

Commit

Permalink
Move start bcp lock check just on cluster leader
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-ilijic committed Aug 13, 2024
1 parent b6cde4b commit db74e1b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cmd/pbm-agent/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ func (a *Agent) Backup(ctx context.Context, cmd *ctrl.BackupCmd, opid ctrl.OPID,
l := logger.NewEvent(string(ctrl.CmdBackup), cmd.Name, opid.String(), ep.TS())
ctx = log.SetLogEventToContext(ctx, l)

moveOn, err := a.startBcpLockCheck(ctx)
if err != nil {
l.Error("start backup lock check: %v", err)
return
}
if !moveOn {
l.Error("unable to proceed with the backup, active lock is present")
return
}

nodeInfo, err := topo.GetNodeInfoExt(ctx, a.nodeConn)
if err != nil {
l.Error("get node info: %v", err)
Expand All @@ -76,6 +66,18 @@ func (a *Agent) Backup(ctx context.Context, cmd *ctrl.BackupCmd, opid ctrl.OPID,

isClusterLeader := nodeInfo.IsClusterLeader()

if isClusterLeader {
moveOn, err := a.startBcpLockCheck(ctx)
if err != nil {
l.Error("start backup lock check: %v", err)
return
}
if !moveOn {
l.Error("unable to proceed with the backup, active lock is present")
return
}
}

canRunBackup, err := topo.NodeSuitsExt(ctx, a.nodeConn, nodeInfo, cmd.Type)
if err != nil {
l.Error("node check: %v", err)
Expand Down

0 comments on commit db74e1b

Please sign in to comment.