Skip to content

Commit

Permalink
fix(restore): use different map directory for each group (#8047)
Browse files Browse the repository at this point in the history
  • Loading branch information
mangalaman93 committed Aug 25, 2023
1 parent 666cf04 commit 3259d28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions worker/online_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,6 @@ func RunOfflineRestore(dir, location, backupId, keyFile string, key x.Sensitive,
}
}

mapDir, err := os.MkdirTemp(x.WorkerConfig.TmpDir, "restore-map")
x.Check(err)
defer os.RemoveAll(mapDir)

for gid := range manifest.Groups {
req := &pb.RestoreRequest{
Location: location,
Expand All @@ -545,6 +541,12 @@ func RunOfflineRestore(dir, location, backupId, keyFile string, key x.Sensitive,
EncryptionKeyFile: keyFile,
RestoreTs: 1,
}
mapDir, err := os.MkdirTemp(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")}
}
Expand Down
8 changes: 4 additions & 4 deletions worker/restore_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,11 @@ func (m *mapper) processReqCh(ctx context.Context) error {
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
}

Expand Down

0 comments on commit 3259d28

Please sign in to comment.