Skip to content

Commit

Permalink
fix(backup): Free the UidPack after use (#7786)
Browse files Browse the repository at this point in the history
Fix memory leak caused because of not freeing posting list's uidpack.
  • Loading branch information
ahsanbarkati authored May 5, 2021
1 parent e98009b commit 8a0c70f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion worker/restore_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

bpb "github.com/dgraph-io/badger/v3/pb"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/dgraph/codec"
"github.com/dgraph-io/dgraph/ee"
"github.com/dgraph-io/dgraph/ee/enc"
"github.com/dgraph-io/dgraph/posting"
Expand Down Expand Up @@ -322,9 +323,11 @@ func (m *mapper) processReqCh(ctx context.Context) error {
if err := backupPl.Unmarshal(kv.Value); err != nil {
return errors.Wrapf(err, "while reading backup posting list")
}

pl := posting.FromBackupPostingList(backupPl)
shouldSplit := pl.Size() >= (1<<20)/2 && len(pl.Pack.Blocks) > 1
defer codec.FreePack(pl.Pack)

shouldSplit := pl.Size() >= (1<<20)/2 && len(pl.Pack.Blocks) > 1
if !shouldSplit || parsedKey.HasStartUid || len(pl.GetSplits()) > 0 {
// This covers two cases.
// 1. The list is not big enough to be split.
Expand Down

0 comments on commit 8a0c70f

Please sign in to comment.