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

fix(backup/restore): fixes backup and restore with DROP operations (GRAPHQL-735) #6844

Merged
merged 16 commits into from
Nov 9, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix review comments
abhimanyusinghgaur committed Nov 5, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 9377a817d5ca4a98d7b903720ac9ed1158d3d1fe
22 changes: 14 additions & 8 deletions worker/backup_ee.go
Original file line number Diff line number Diff line change
@@ -170,25 +170,31 @@ func ProcessBackupRequest(ctx context.Context, req *pb.BackupRequest, forceFull
ctx, cancel := context.WithCancel(ctx)
defer cancel()

errCh := make(chan error, len(state.Groups))
var dropOperations []*pb.DropOperation
resOrErrCh := make(chan interface{}, len(state.Groups))
for _, gid := range groups {
br := proto.Clone(req).(*pb.BackupRequest)
br.GroupId = gid
br.Predicates = predMap[gid]
go func(req *pb.BackupRequest) {
res, err := BackupGroup(ctx, req)
if res != nil && len(res.DropOperations) > 0 {
dropOperations = append(dropOperations, res.DropOperations...)
if err != nil {
resOrErrCh <- err
} else {
resOrErrCh <- res
}
errCh <- err
}(br)
}

var dropOperations []*pb.DropOperation
for range groups {
if err := <-errCh; err != nil {
glog.Errorf("Error received during backup: %v", err)
return err
if resOrErr := <-resOrErrCh; resOrErr != nil {
switch val := resOrErr.(type) {
case error:
glog.Errorf("Error received during backup: %v", val)
return val
case *pb.BackupResponse:
dropOperations = append(dropOperations, val.DropOperations...)
}
}
}

6 changes: 4 additions & 2 deletions worker/backup_processor.go
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ import (
"fmt"
"io"
"net/url"
"reflect"
"strings"

"github.com/dgraph-io/badger/v2"
@@ -342,7 +343,8 @@ func checkAndGetDropOp(key []byte, l *posting.List, readTs uint64) (*pb.DropOper
case 1:
val, ok := vals[0].Value.([]byte)
if !ok {
return nil, errors.Errorf("cannot convert value of dgraph.drop.op to byte array")
return nil, errors.Errorf("cannot convert value of dgraph.drop.op to byte array, "+
"got type: %s", reflect.TypeOf(vals[0].Value))
}
// A dgraph.drop.op record can have values in only one of the following formats:
// * DROP_ALL;
@@ -366,6 +368,6 @@ func checkAndGetDropOp(key []byte, l *posting.List, readTs uint64) (*pb.DropOper
return dropOp, nil
default:
// getting more than one values for a non-list predicate is an error
return nil, errors.Errorf("found multiple values for dgraph.drop.op")
return nil, errors.Errorf("found multiple values for dgraph.drop.op: %v", vals)
}
}