diff --git a/ee/updatemanifest/run.go b/ee/updatemanifest/run.go new file mode 100644 index 00000000000..8e03dbd885d --- /dev/null +++ b/ee/updatemanifest/run.go @@ -0,0 +1,133 @@ +// +build !oss + +/* + * Copyright 2021 Dgraph Labs, Inc. and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package updatemanifest + +import ( + "encoding/binary" + "log" + "net/url" + "os" + "strings" + + "github.com/dgraph-io/dgraph/ee" + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/worker" + "github.com/dgraph-io/dgraph/x" + "github.com/pkg/errors" + "github.com/spf13/cobra" +) + +var ( + logger = log.New(os.Stderr, "", 0) + // UpdateManifest is the sub-command invoked when running "dgraph update_manifest". + UpdateManifest x.SubCommand +) + +var opt struct { + location string + key []byte +} + +func init() { + UpdateManifest.Cmd = &cobra.Command{ + Use: "update_manifest", + Short: "Run the Dgraph update tool to update the manifest from v21.03 to latest.", + Run: func(cmd *cobra.Command, args []string) { + if err := run(); err != nil { + logger.Fatalf("%v\n", err) + } + }, + Annotations: map[string]string{"group": "tool"}, + } + UpdateManifest.EnvPrefix = "DGRAPH_UPDATE_MANIFEST" + UpdateManifest.Cmd.SetHelpTemplate(x.NonRootTemplate) + + flag := UpdateManifest.Cmd.Flags() + flag.StringVarP(&opt.location, "location", "l", "", + `Sets the location of the backup. Both file URIs and s3 are supported. + This command will take care of all the full + incremental backups present in the location.`) + ee.RegisterEncFlag(flag) +} + +// Invalid bytes are replaced with the Unicode replacement rune. +// See https://golang.org/pkg/encoding/json/#Marshal +const replacementRune = rune('\ufffd') + +func parseNsAttr(attr string) (uint64, string, error) { + if strings.ContainsRune(attr, replacementRune) { + return 0, "", errors.New("replacement char found") + } + return binary.BigEndian.Uint64([]byte(attr[:8])), attr[8:], nil +} + +func run() error { + keys, err := ee.GetKeys(UpdateManifest.Conf) + if err != nil { + return err + } + opt.key = keys.EncKey + uri, err := url.Parse(opt.location) + if err != nil { + return errors.Wrapf(err, "while parsing location") + } + handler, err := worker.NewUriHandler(uri, nil) + if err != nil { + return errors.Wrapf(err, "while creating uri handler") + } + masterManifest, err := worker.GetManifestNoUpgrade(handler, uri) + if err != nil { + return errors.Wrapf(err, "while getting manifest") + } + + update := func(manifest *worker.Manifest) { + for gid, preds := range manifest.Groups { + parsedPreds := preds[:0] + for _, pred := range preds { + ns, attr, err := parseNsAttr(pred) + if err != nil { + logger.Printf("Unable to parse the pred: %v", pred) + continue + } + parsedPreds = append(parsedPreds, x.NamespaceAttr(ns, attr)) + } + manifest.Groups[gid] = parsedPreds + } + for _, op := range manifest.DropOperations { + if op.DropOp == pb.DropOperation_ATTR { + ns, attr, err := parseNsAttr(op.DropValue) + if err != nil { + logger.Printf("Unable to parse the drop operation %+v pred: %v", + op, []byte(op.DropValue)) + continue + } + op.DropValue = x.NamespaceAttr(ns, attr) + } + } + } + + // Update the master manifest with the changes for drop operations and group predicates. + for _, manifest := range masterManifest.Manifests { + if manifest.Version == 2103 { + update(manifest) + } + } + + // Rewrite the master manifest. + return errors.Wrap(worker.CreateManifest(handler, uri, masterManifest), "rewrite failed") +} diff --git a/systest/backup/filesystem/backup_test.go b/systest/backup/filesystem/backup_test.go index 3da1a5080dd..88d16c055fd 100644 --- a/systest/backup/filesystem/backup_test.go +++ b/systest/backup/filesystem/backup_test.go @@ -48,6 +48,7 @@ var ( alphaBackupDir = "/data/backups" oldBackupDir1 = "/data/to_restore/1" oldBackupDir2 = "/data/to_restore/2" + oldBackupDir3 = "/data/to_restore/3" alphaContainers = []string{ "alpha1", "alpha2", @@ -85,6 +86,44 @@ func sendRestoreRequest(t *testing.T, location string) { return } +// This test restores the old backups. +// The backup dir contains: +// - Full backup with pred "p1", "p2", "p3". (insert k1, k2, k3). +// - Incremental backup after drop data was called and "p2", "p3", "p4" inserted. --> (insert k4,k5) +// - Incremental backup after "p3" was dropped. +func TestRestoreOfOldBackup(t *testing.T) { + test := func(dir string) { + common.DirSetup(t) + common.CopyOldBackupDir(t) + + conn, err := grpc.Dial(testutil.SockAddr, + grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) + require.NoError(t, err) + dg := dgo.NewDgraphClient(api.NewDgraphClient(conn)) + require.NoError(t, err) + + testutil.DropAll(t, dg) + time.Sleep(2 * time.Second) + + sendRestoreRequest(t, dir) + testutil.WaitForRestore(t, dg) + + queryAndCheck := func(pred string, cnt int) { + q := fmt.Sprintf(`{ me(func: has(%s)) { count(uid) } }`, pred) + r := fmt.Sprintf("{\"me\":[{\"count\":%d}]}", cnt) + resp, err := dg.NewTxn().Query(context.Background(), q) + require.NoError(t, err) + require.JSONEq(t, r, string(resp.Json)) + } + queryAndCheck("p1", 0) + queryAndCheck("p2", 2) + queryAndCheck("p3", 0) + queryAndCheck("p4", 2) + } + t.Run("backup of 20.11", func(t *testing.T) { test(oldBackupDir2) }) + t.Run("backup of 21.03", func(t *testing.T) { test(oldBackupDir3) }) +} + // This test takes a backup and then restores an old backup in a cluster incrementally. // Next, cleans up the cluster and tries restoring the backups above. // Regression test for DGRAPH-2775 @@ -92,7 +131,8 @@ func TestBackupOfOldRestore(t *testing.T) { common.DirSetup(t) common.CopyOldBackupDir(t) - conn, err := grpc.Dial(testutil.SockAddr, grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) + conn, err := grpc.Dial(testutil.SockAddr, + grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) require.NoError(t, err) dg := dgo.NewDgraphClient(api.NewDgraphClient(conn)) require.NoError(t, err) @@ -105,7 +145,8 @@ func TestBackupOfOldRestore(t *testing.T) { sendRestoreRequest(t, oldBackupDir1) testutil.WaitForRestore(t, dg) - resp, err := dg.NewTxn().Query(context.Background(), `{ authors(func: has(Author.name)) { count(uid) } }`) + q := `{ authors(func: has(Author.name)) { count(uid) } }` + resp, err := dg.NewTxn().Query(context.Background(), q) require.NoError(t, err) require.JSONEq(t, "{\"authors\":[{\"count\":1}]}", string(resp.Json)) @@ -117,7 +158,7 @@ func TestBackupOfOldRestore(t *testing.T) { sendRestoreRequest(t, alphaBackupDir) testutil.WaitForRestore(t, dg) - resp, err = dg.NewTxn().Query(context.Background(), `{ authors(func: has(Author.name)) { count(uid) } }`) + resp, err = dg.NewTxn().Query(context.Background(), q) require.NoError(t, err) require.JSONEq(t, "{\"authors\":[{\"count\":1}]}", string(resp.Json)) } @@ -160,7 +201,8 @@ func TestRestoreOfOldBackup(t *testing.T) { } func TestBackupFilesystem(t *testing.T) { - conn, err := grpc.Dial(testutil.SockAddr, grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) + conn, err := grpc.Dial(testutil.SockAddr, + grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) require.NoError(t, err) dg := dgo.NewDgraphClient(api.NewDgraphClient(conn)) @@ -432,7 +474,8 @@ func runBackupInternal(t *testing.T, forceFull bool, numExpectedFiles, var data interface{} require.NoError(t, json.NewDecoder(resp.Body).Decode(&data)) - require.Equal(t, "Success", testutil.JsonGet(data, "data", "backup", "response", "code").(string)) + require.Equal(t, "Success", + testutil.JsonGet(data, "data", "backup", "response", "code").(string)) taskId := testutil.JsonGet(data, "data", "backup", "taskId").(string) testutil.WaitForTask(t, taskId, true) @@ -440,7 +483,8 @@ func runBackupInternal(t *testing.T, forceFull bool, numExpectedFiles, common.CopyToLocalFs(t) files := x.WalkPathFunc(copyBackupDir, func(path string, isdir bool) bool { - return !isdir && strings.HasSuffix(path, ".backup") && strings.HasPrefix(path, "data/backups_copy/dgraph.") + return !isdir && strings.HasSuffix(path, ".backup") && + strings.HasPrefix(path, "data/backups_copy/dgraph.") }) require.Equal(t, numExpectedFiles, len(files)) diff --git a/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095641.969/r9-g1.backup b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095641.969/r9-g1.backup new file mode 100644 index 00000000000..2a3070c33b4 Binary files /dev/null and b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095641.969/r9-g1.backup differ diff --git a/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095641.969/r9-g2.backup b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095641.969/r9-g2.backup new file mode 100644 index 00000000000..45c0a95038f Binary files /dev/null and b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095641.969/r9-g2.backup differ diff --git a/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095641.969/r9-g3.backup b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095641.969/r9-g3.backup new file mode 100644 index 00000000000..45c0a95038f Binary files /dev/null and b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095641.969/r9-g3.backup differ diff --git a/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095716.130/r21-g1.backup b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095716.130/r21-g1.backup new file mode 100644 index 00000000000..353cc3af855 Binary files /dev/null and b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095716.130/r21-g1.backup differ diff --git a/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095716.130/r21-g2.backup b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095716.130/r21-g2.backup new file mode 100644 index 00000000000..45c0a95038f Binary files /dev/null and b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095716.130/r21-g2.backup differ diff --git a/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095716.130/r21-g3.backup b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095716.130/r21-g3.backup new file mode 100644 index 00000000000..45c0a95038f Binary files /dev/null and b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095716.130/r21-g3.backup differ diff --git a/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095726.320/r26-g1.backup b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095726.320/r26-g1.backup new file mode 100644 index 00000000000..cf1f5adf0fc Binary files /dev/null and b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095726.320/r26-g1.backup differ diff --git a/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095726.320/r26-g2.backup b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095726.320/r26-g2.backup new file mode 100644 index 00000000000..45c0a95038f Binary files /dev/null and b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095726.320/r26-g2.backup differ diff --git a/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095726.320/r26-g3.backup b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095726.320/r26-g3.backup new file mode 100644 index 00000000000..45c0a95038f Binary files /dev/null and b/systest/backup/filesystem/data/to_restore/3/dgraph.20210517.095726.320/r26-g3.backup differ diff --git a/systest/backup/filesystem/data/to_restore/3/manifest.json b/systest/backup/filesystem/data/to_restore/3/manifest.json new file mode 100644 index 00000000000..8b2efaa23bb --- /dev/null +++ b/systest/backup/filesystem/data/to_restore/3/manifest.json @@ -0,0 +1 @@ +{"Manifests":[{"type":"full","since":0,"read_ts":9,"groups":{"1":["\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p1","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.graphql.p_query","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.graphql.xid","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.graphql.schema","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.drop.op","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.type","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p3","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p2"],"2":[],"3":[]},"backup_id":"quirky_kapitsa4","backup_num":1,"version":2103,"path":"dgraph.20210517.095641.969","encrypted":false,"drop_operations":null,"compression":"snappy"},{"type":"incremental","since":0,"read_ts":21,"groups":{"1":["\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.drop.op","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p1","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.graphql.schema","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.graphql.p_query","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p3","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.graphql.xid","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p4","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p2","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.type"],"2":[],"3":[]},"backup_id":"quirky_kapitsa4","backup_num":2,"version":2103,"path":"dgraph.20210517.095716.130","encrypted":false,"drop_operations":[{"drop_op":1}],"compression":"snappy"},{"type":"incremental","since":0,"read_ts":26,"groups":{"1":["\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p4","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p2","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.type","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p1","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.graphql.schema","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.graphql.p_query","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p3","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.drop.op","\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000dgraph.graphql.xid"],"2":[],"3":[]},"backup_id":"quirky_kapitsa4","backup_num":3,"version":2103,"path":"dgraph.20210517.095726.320","encrypted":false,"drop_operations":[{"drop_op":2,"drop_value":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000p3"}],"compression":"snappy"}]} diff --git a/worker/backup.go b/worker/backup.go index b25af95302e..22c248b12db 100644 --- a/worker/backup.go +++ b/worker/backup.go @@ -89,10 +89,6 @@ func (m *Manifest) getPredsInGroup(gid uint32) predicateSet { predSet := make(predicateSet) for _, pred := range preds { - if m.Version == 0 { - // For older versions, preds set will contain attribute without namespace. - pred = x.NamespaceAttr(x.GalaxyNamespace, pred) - } predSet[pred] = struct{}{} } return predSet diff --git a/worker/backup_ee.go b/worker/backup_ee.go index 11db8d8d5f1..a0ac1e01fee 100644 --- a/worker/backup_ee.go +++ b/worker/backup_ee.go @@ -227,7 +227,7 @@ func ProcessBackupRequest(ctx context.Context, req *pb.BackupRequest) error { m := Manifest{ ReadTs: req.ReadTs, Groups: predMap, - Version: x.DgraphVersion, + Version: x.ManifestVersion, DropOperations: dropOperations, Path: dir, Compression: "snappy", @@ -550,13 +550,13 @@ func (pr *BackupProcessor) CompleteBackup(ctx context.Context, m *Manifest) erro return err } - manifest, err := GetManifest(handler, uri) + manifest, err := GetManifestNoUpgrade(handler, uri) if err != nil { return err } manifest.Manifests = append(manifest.Manifests, m) - if err := createManifest(handler, uri, manifest); err != nil { + if err := CreateManifest(handler, uri, manifest); err != nil { return errors.Wrap(err, "Complete backup failed") } glog.Infof("Backup completed OK.") diff --git a/worker/backup_manifest.go b/worker/backup_manifest.go index 51b27184229..864ea65b2b9 100644 --- a/worker/backup_manifest.go +++ b/worker/backup_manifest.go @@ -14,7 +14,9 @@ package worker import ( + "encoding/binary" "encoding/json" + "fmt" "net/url" "path/filepath" "sort" @@ -57,14 +59,9 @@ func verifyManifests(manifests []*Manifest) error { func getManifestsToRestore( h UriHandler, uri *url.URL, req *pb.RestoreRequest) ([]*Manifest, error) { - - if !h.DirExists("") { - return nil, errors.Errorf("getManifestsToRestore: The uri path: %q doesn't exists", - uri.Path) - } - manifest, err := getConsolidatedManifest(h, uri) + manifest, err := GetManifest(h, uri) if err != nil { - return nil, errors.Wrap(err, "failed to get consolidated manifest") + return manifest.Manifests, err } return getFilteredManifests(h, manifest.Manifests, req) } @@ -165,6 +162,74 @@ func getConsolidatedManifest(h UriHandler, uri *url.URL) (*MasterManifest, error return &MasterManifest{Manifests: mlist}, nil } +// Invalid bytes are replaced with the Unicode replacement rune. +// See https://golang.org/pkg/encoding/json/#Marshal +const replacementRune = rune('\ufffd') + +func parseNsAttr(attr string) (uint64, string, error) { + if strings.ContainsRune(attr, replacementRune) { + return 0, "", errors.Errorf("replacement rune found while parsing attr: %s (%+v)", + attr, []byte(attr)) + } + return binary.BigEndian.Uint64([]byte(attr[:8])), attr[8:], nil +} + +// upgradeManifest updates the in-memory manifest from various versions to the latest version. +// If the manifest version is 0 (dgraph version < v21.03), attach namespace to the predicates and +// the drop data/attr operation. +// If the manifest version is 2103, convert the format of predicate from | to +// -. This is because of a bug for namespace greater than 127. +// See https://github.com/dgraph-io/dgraph/pull/7810 +// NOTE: Do not use the upgraded manifest to overwrite the non-upgraded manifest. +func upgradeManifest(m *Manifest) error { + switch m.Version { + case 0: + for gid, preds := range m.Groups { + parsedPreds := preds[:0] + for _, pred := range preds { + parsedPreds = append(parsedPreds, x.GalaxyAttr(pred)) + } + m.Groups[gid] = parsedPreds + } + for _, op := range m.DropOperations { + switch op.DropOp { + case pb.DropOperation_DATA: + op.DropValue = fmt.Sprintf("%#x", x.GalaxyNamespace) + case pb.DropOperation_ATTR: + op.DropValue = x.GalaxyAttr(op.DropValue) + default: + // do nothing for drop all and drop namespace. + } + } + case 2103: + for gid, preds := range m.Groups { + parsedPreds := preds[:0] + for _, pred := range preds { + ns, attr, err := parseNsAttr(pred) + if err != nil { + return errors.Errorf("while parsing predicate got: %q", err) + } + parsedPreds = append(parsedPreds, x.NamespaceAttr(ns, attr)) + } + m.Groups[gid] = parsedPreds + } + for _, op := range m.DropOperations { + // We have a cluster wide drop data in v21.03. + if op.DropOp == pb.DropOperation_ATTR { + ns, attr, err := parseNsAttr(op.DropValue) + if err != nil { + return errors.Errorf("while parsing the drop operation %+v got: %q", + op, err) + } + op.DropValue = x.NamespaceAttr(ns, attr) + } + } + case 2105: + // pass + } + return nil +} + func readManifest(h UriHandler, path string) (*Manifest, error) { var m Manifest b, err := h.Read(path) @@ -200,10 +265,11 @@ func readMasterManifest(h UriHandler, path string) (*MasterManifest, error) { return &m, nil } -func GetManifest(h UriHandler, uri *url.URL) (*MasterManifest, error) { +// GetManifestNoUpgrade returns the master manifest using the given handler and uri. +func GetManifestNoUpgrade(h UriHandler, uri *url.URL) (*MasterManifest, error) { if !h.DirExists("") { - return &MasterManifest{}, errors.Errorf("getManifest: The uri path: %q doesn't exists", - uri.Path) + return &MasterManifest{}, + errors.Errorf("getManifestWithoutUpgrade: The uri path: %q doesn't exists", uri.Path) } manifest, err := getConsolidatedManifest(h, uri) if err != nil { @@ -212,7 +278,24 @@ func GetManifest(h UriHandler, uri *url.URL) (*MasterManifest, error) { return manifest, nil } -func createManifest(h UriHandler, uri *url.URL, manifest *MasterManifest) error { +// GetManifest returns the master manifest using the given handler and uri. Additionally, it also +// upgrades the manifest for the in-memory processing. +// Note: This function must not be used when using the returned manifest for the purpose of +// overwriting the old manifest. +func GetManifest(h UriHandler, uri *url.URL) (*MasterManifest, error) { + manifest, err := GetManifestNoUpgrade(h, uri) + if err != nil { + return manifest, err + } + for _, m := range manifest.Manifests { + if err := upgradeManifest(m); err != nil { + return manifest, errors.Wrapf(err, "getManifest: failed to upgrade") + } + } + return manifest, nil +} + +func CreateManifest(h UriHandler, uri *url.URL, manifest *MasterManifest) error { var err error if !h.DirExists("./") { if err := h.CreateDir("./"); err != nil { diff --git a/worker/online_restore.go b/worker/online_restore.go index 6fe53921451..d0e5ce5d084 100644 --- a/worker/online_restore.go +++ b/worker/online_restore.go @@ -288,15 +288,6 @@ func handleRestoreProposal(ctx context.Context, req *pb.RestoreRequest, pidx uin lastManifest := manifests[0] preds, ok := lastManifest.Groups[req.GroupId] - // Version is 0 if the backup was taken on an old version (v20.11). - if lastManifest.Version == 0 { - tmp := make([]string, 0, len(preds)) - for _, pred := range preds { - tmp = append(tmp, x.GalaxyAttr(pred)) - } - preds = tmp - } - if !ok { return errors.Errorf("backup manifest does not contain information for group ID %d", req.GroupId) diff --git a/worker/restore_map.go b/worker/restore_map.go index 3a52dc8d81a..896761f1daa 100644 --- a/worker/restore_map.go +++ b/worker/restore_map.go @@ -728,15 +728,14 @@ func RunMapper(req *pb.RestoreRequest, mapDir string) (*mapResult, error) { case pb.DropOperation_ALL: dropAll = true case pb.DropOperation_DATA: - var ns uint64 - if manifest.Version == 0 { - ns = x.GalaxyNamespace - } else { - var err error - ns, err = strconv.ParseUint(op.DropValue, 0, 64) - if err != nil { - return nil, errors.Wrap(err, "Map phase failed to parse namespace") - } + if op.DropValue == "" { + // In 2103, we do not support namespace level drop data. + dropAll = true + continue + } + ns, err := strconv.ParseUint(op.DropValue, 0, 64) + if err != nil { + return nil, errors.Wrap(err, "Map phase failed to parse namespace") } dropNs[ns] = struct{}{} case pb.DropOperation_ATTR: diff --git a/x/x.go b/x/x.go index 997c179507c..cdd27ded7fc 100644 --- a/x/x.go +++ b/x/x.go @@ -138,7 +138,7 @@ const ( "X-CSRF-Token, X-Auth-Token, X-Requested-With" DgraphCostHeader = "Dgraph-TouchedUids" - DgraphVersion = 2103 + ManifestVersion = 2105 ) var (