Skip to content

Commit 827d30d

Browse files
committed
PBM-1229: skip waitForStatus on the backup leader
the leader only sets the status. no reason to wait for known condition
1 parent 6e0981c commit 827d30d

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

pbm/backup/backup.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,12 @@ func (b *Backup) Run(ctx context.Context, bcp *ctrl.BackupCmd, opid ctrl.OPID, l
348348
}
349349

350350
err = writeMeta(stg, bcpm)
351-
if err != nil {
352-
return errors.Wrap(err, "dump metadata")
353-
}
351+
return errors.Wrap(err, "dump metadata")
352+
} else {
353+
// to be sure the locks released only after the "done" status had written
354+
err = b.waitForStatus(ctx, bcp.Name, defs.StatusDone, nil)
355+
return errors.Wrap(err, "waiting for done")
354356
}
355-
356-
// to be sure the locks released only after the "done" status had written
357-
err = b.waitForStatus(ctx, bcp.Name, defs.StatusDone, nil)
358-
return errors.Wrap(err, "waiting for done")
359357
}
360358

361359
func waitForBalancerOff(ctx context.Context, conn connect.Client, t time.Duration, l log.LogEvent) topo.BalancerMode {
@@ -412,11 +410,11 @@ func (b *Backup) toState(
412410
}
413411
return errors.Wrapf(err, "check cluster for backup `%s`", status)
414412
}
415-
}
416-
417-
err = b.waitForStatus(ctx, bcp, status, wait)
418-
if err != nil {
419-
return errors.Wrapf(err, "waiting for %s", status)
413+
} else {
414+
err = b.waitForStatus(ctx, bcp, status, wait)
415+
if err != nil {
416+
return errors.Wrapf(err, "waiting for %s", status)
417+
}
420418
}
421419

422420
return nil

pbm/backup/logical.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,18 @@ func (b *Backup) doLogical(
8181
return errors.Wrap(err, "check cluster for backup started")
8282
}
8383

84+
// TODO(improve): do setClusterFirstWrite between
85+
// all replsets status are StatusRunning and setting the global status
8486
err = b.setClusterFirstWrite(ctx, bcp.Name)
8587
if err != nil {
8688
return errors.Wrap(err, "set cluster first write ts")
8789
}
88-
}
89-
90-
// Waiting for cluster's StatusRunning to move further.
91-
err = b.waitForStatus(ctx, bcp.Name, defs.StatusRunning, nil)
92-
if err != nil {
93-
return errors.Wrap(err, "waiting for running")
90+
} else {
91+
// Waiting for cluster's StatusRunning to move further.
92+
err = b.waitForStatus(ctx, bcp.Name, defs.StatusRunning, nil)
93+
if err != nil {
94+
return errors.Wrap(err, "waiting for running")
95+
}
9496
}
9597

9698
stopOplogSlicer := startOplogSlicer(ctx,
@@ -195,11 +197,11 @@ func (b *Backup) doLogical(
195197
if err != nil {
196198
return errors.Wrap(err, "check cluster for dump done")
197199
}
198-
}
199-
200-
err = b.waitForStatus(ctx, bcp.Name, defs.StatusDumpDone, nil)
201-
if err != nil {
202-
return errors.Wrap(err, "waiting for dump done")
200+
} else {
201+
err = b.waitForStatus(ctx, bcp.Name, defs.StatusDumpDone, nil)
202+
if err != nil {
203+
return errors.Wrap(err, "waiting for dump done")
204+
}
203205
}
204206

205207
lastSavedTS, oplogSize, err := stopOplogSlicer()

pbm/backup/physical.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,12 @@ func (b *Backup) doPhysical(
330330
if err != nil {
331331
return errors.Wrap(err, "set cluster last write ts")
332332
}
333-
}
334-
335-
// Waiting for cluster's StatusRunning to move further.
336-
err = b.waitForStatus(ctx, bcp.Name, defs.StatusRunning, nil)
337-
if err != nil {
338-
return errors.Wrap(err, "waiting for running")
333+
} else {
334+
// Waiting for cluster's StatusRunning to move further.
335+
err = b.waitForStatus(ctx, bcp.Name, defs.StatusRunning, nil)
336+
if err != nil {
337+
return errors.Wrap(err, "waiting for running")
338+
}
339339
}
340340

341341
_, lwTS, err := b.waitForFirstLastWrite(ctx, bcp.Name)

0 commit comments

Comments
 (0)