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(restore): Handle MaxUid=0 appropriately #7258

Merged
merged 1 commit into from
Jan 8, 2021
Merged
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
21 changes: 11 additions & 10 deletions ee/backup/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ package backup
import (
"context"
"fmt"
"google.golang.org/grpc/credentials"
"os"
"time"

"google.golang.org/grpc/credentials"

"github.com/dgraph-io/dgraph/ee/enc"
"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/worker"
Expand Down Expand Up @@ -236,19 +237,19 @@ func runRestoreCmd() error {
ctx, cancelTs := context.WithTimeout(context.Background(), time.Minute)
defer cancelTs()

_, err := zc.Timestamps(ctx, &pb.Num{Val: result.Version})
if err != nil {
if _, err := zc.Timestamps(ctx, &pb.Num{Val: result.Version}); err != nil {
fmt.Printf("Failed to assign timestamp %d in Zero: %v", result.Version, err)
return err
}

ctx, cancelUid := context.WithTimeout(context.Background(), time.Minute)
defer cancelUid()

_, err = zc.AssignUids(ctx, &pb.Num{Val: result.MaxLeaseUid})
if err != nil {
fmt.Printf("Failed to assign maxLeaseId %d in Zero: %v\n", result.MaxLeaseUid, err)
return err
// MaxLeaseUid can be zero if the backup was taken on an empty DB.
if result.MaxLeaseUid > 0 {
ctx, cancelUid := context.WithTimeout(context.Background(), time.Minute)
defer cancelUid()
if _, err = zc.AssignUids(ctx, &pb.Num{Val: result.MaxLeaseUid}); err != nil {
fmt.Printf("Failed to assign maxLeaseId %d in Zero: %v\n", result.MaxLeaseUid, err)
return err
}
}
}

Expand Down