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

(release/v20.07) fix(Dgraph): make backups cancel other tasks #6243

Merged
merged 2 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions worker/backup_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func backupCurrentGroup(ctx context.Context, req *pb.BackupRequest) (*pb.Status,
return nil, err
}

closer, err := g.Node.startTask(opBackup)
if err != nil {
return nil, errors.Wrapf(err, "cannot start backup operation")
}
defer closer.Done()
bp := NewBackupProcessor(pstore, req)
return bp.WriteBackup(ctx)
}
Expand Down
14 changes: 14 additions & 0 deletions worker/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ func (id op) String() string {
return "opIndexing"
case opRestore:
return "opRestore"
case opBackup:
return "opBackup"
default:
return "opUnknown"
}
Expand All @@ -96,6 +98,7 @@ const (
opSnapshot
opIndexing
opRestore
opBackup
)

// startTask is used to check whether an op is already running. If a rollup is running,
Expand Down Expand Up @@ -141,6 +144,17 @@ func (n *node) startTask(id op) (*y.Closer, error) {
delete(n.ops, otherId)
otherCloser.SignalAndWait()
}
case opBackup:
// Backup cancels all other operations, except for other backups since
// only one restore operation should be active any given moment.
for otherId, otherCloser := range n.ops {
if otherId == opBackup {
return nil, errors.Errorf("another backup operation is already running")
}
// Remove from map and signal the closer to cancel the operation.
delete(n.ops, otherId)
otherCloser.SignalAndWait()
}
case opSnapshot, opIndexing:
for otherId, otherCloser := range n.ops {
if otherId == opRollup {
Expand Down