No need to wait with the single-node replica set primary
@@ -115,7 +115,7 @@ func (b *Backup) run(bcp pbm.BackupCmd) (err error) {
}
if im.IsLeader() {
- err := b.reconcileStatus(bcp.Name, pbm.StatusRunning, im, &wiatBackupStart)
+ err := b.reconcileStatus(bcp.Name, pbm.StatusRunning, im, &waitBackupStart)
if err != nil {
if errors.Cause(err) == errConvergeTimeOut {
return errors.Wrap(err, "couldn't get response from all shards")
@@ -216,15 +216,16 @@ func NodeSuits(bcp pbm.BackupCmd, node *pbm.Node) (bool, error) {
return false, errors.New("mongod node can not be used to fetch a consistent backup because it has no oplog. Please restart it as a primary in a single-node replicaset to make it compatible with PBM's backup method using the oplog")
}
- if im.IsMaster {
// for the cases when no secondary was good enough for backup or there are no secondaries alive
- // wait for 90% of wiatBackupStart and then try to acquire a lock.
+ // wait for 90% of waitBackupStart and then try to acquire a lock.
// by that time healthy secondaries should have already acquired a lock.
- // TODO there are caveats:
- // 1. there is still a chance that the lock gonna be stolen from the healthy node
- // (due tmp network issues node got the command later than the primary, but it's maybe for the good that the node with the faulty network doesn't start the backup)
- // 2. the single-node-replica-set will always have a delay before the backup start.
- time.Sleep(wiatBackupStart * 9 / 10)
+ //
+ // but no need to wait if this is the only node (the single-node replica set).
+ //
+ // TODO ? there is still a chance that the lock gonna be stolen from the healthy secondary node
+ // TODO ? (due tmp network issues node got the command later than the primary, but it's maybe for the good that the node with the faulty network doesn't start the backup)
+ if im.IsMaster && im.Me == im.Primary && len(im.Hosts) > 1 {
+ time.Sleep(waitBackupStart * 9 / 10)
}
status, err := node.Status()
