diff --git a/dgraph/cmd/debug/run.go b/dgraph/cmd/debug/run.go index 32a621b7931..56e8013ea0a 100644 --- a/dgraph/cmd/debug/run.go +++ b/dgraph/cmd/debug/run.go @@ -71,6 +71,7 @@ type flagOptions struct { namespace uint64 key x.Sensitive onlySummary bool + magic uint16 // Options related to the WAL. wdir string @@ -108,6 +109,7 @@ func init() { "Show a histogram of the key and value sizes.") flag.BoolVar(&opt.onlySummary, "only-summary", false, "If true, only show the summary of the p directory.") + flag.Uint16Var(&opt.magic, "magic", 1, "Magic version of the p directory.") // Flags related to WAL. flag.StringVarP(&opt.wdir, "wal", "w", "", "Directory where Raft write-ahead logs are stored.") @@ -878,6 +880,7 @@ func run() { WithEncryptionKey(opt.key). WithBlockCacheSize(1 << 30). WithIndexCacheSize(1 << 30). + WithExternalMagic(opt.magic). WithNamespaceOffset(x.NamespaceOffset) // We don't want to see the banned data. x.AssertTruef(len(bopts.Dir) > 0, "No posting or wal dir specified.") diff --git a/worker/online_restore.go b/worker/online_restore.go index e8c6ec1523e..7c53b22ea6b 100644 --- a/worker/online_restore.go +++ b/worker/online_restore.go @@ -542,10 +542,6 @@ func RunOfflineRestore(dir, location, backupId string, keyFile string, } } - mapDir, err := ioutil.TempDir(x.WorkerConfig.TmpDir, "restore-map") - x.Check(err) - defer os.RemoveAll(mapDir) - for gid := range manifest.Groups { req := &pb.RestoreRequest{ Location: location, @@ -554,6 +550,12 @@ func RunOfflineRestore(dir, location, backupId string, keyFile string, EncryptionKeyFile: keyFile, RestoreTs: 1, } + mapDir, err := ioutil.TempDir(x.WorkerConfig.TmpDir, "restore-map") + if err != nil { + return LoadResult{Err: errors.Wrapf(err, "Failed to create temp map directory")} + } + defer os.RemoveAll(mapDir) + if _, err := RunMapper(req, mapDir); err != nil { return LoadResult{Err: errors.Wrap(err, "RunRestore failed to map")} } diff --git a/worker/restore_map.go b/worker/restore_map.go index 9ce49696cc7..cc76400cb4b 100644 --- a/worker/restore_map.go +++ b/worker/restore_map.go @@ -305,11 +305,11 @@ func (p *processor) processKV(buf *z.Buffer, in *loadBackupInput, kv *bpb.KV) er toBuffer := func(kv *bpb.KV, version uint64) error { key := y.KeyWithTs(kv.Key, version) sz := kv.Size() - buf := buf.SliceAllocate(2 + len(key) + sz) + b := buf.SliceAllocate(2 + len(key) + sz) - binary.BigEndian.PutUint16(buf[0:2], uint16(len(key))) - x.AssertTrue(copy(buf[2:], key) == len(key)) - _, err := kv.MarshalToSizedBuffer(buf[2+len(key):]) + binary.BigEndian.PutUint16(b[0:2], uint16(len(key))) + x.AssertTrue(copy(b[2:], key) == len(key)) + _, err := kv.MarshalToSizedBuffer(b[2+len(key):]) return err } if len(kv.GetUserMeta()) != 1 {