Skip to content

feat(Dgraph): Use Badger with new WAL format. #6643

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

Merged
merged 31 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e68971e
Update badger.
martinmr Oct 3, 2020
0894687
Fix build issues.
martinmr Oct 3, 2020
0ca5415
Set default cache_mb to 1GB.
martinmr Oct 3, 2020
0c2a7eb
Add block cache to index rebuilder.
martinmr Oct 3, 2020
f07adce
update badger.
martinmr Oct 3, 2020
b5736a7
More changes.
martinmr Oct 3, 2020
6993aed
Update badger and fix compilation issues
Oct 4, 2020
eb2f937
Fix build. Bulk loader works
Oct 4, 2020
e83a251
Update to latest badger
Oct 4, 2020
3eccd84
Add index cache to alpha
Oct 4, 2020
aaf0a08
Add index cache for indexing
Oct 4, 2020
926a997
Update badger and fix backup tests.
martinmr Oct 4, 2020
dbd175d
Fix encryption backup test.
martinmr Oct 4, 2020
f396d91
Fix xid loader test.
martinmr Oct 4, 2020
31653ea
Update badger.
martinmr Oct 4, 2020
dfa9d12
Update to latest badger
Oct 5, 2020
877c61c
Update badger
Oct 5, 2020
45e1023
Update badger
Oct 5, 2020
75a25ec
Update badger
Oct 5, 2020
ef3e6b8
Update badger
Oct 5, 2020
41c8d90
Break out if g.Ctx is done
manishrjain Oct 5, 2020
e12b4dd
Don't call sync during writer.Flush
manishrjain Oct 5, 2020
186e275
Merge branch 'master' into martinmr/wal
manishrjain Oct 5, 2020
96c285f
Remove v(3)
manishrjain Oct 5, 2020
c8fc6e1
Remove extra flags
manishrjain Oct 5, 2020
92bb448
Update badger.
martinmr Oct 7, 2020
89b3f48
Don't do Badger cache monitoring in Dgraph.
manishrjain Oct 11, 2020
424869e
Also print jemalloc when pricing Go GC.
manishrjain Oct 11, 2020
202e681
update for badger file rename
darkn3rd Oct 7, 2020
f3fb84e
Review
manishrjain Oct 13, 2020
a0656f1
address review comments.
martinmr Oct 7, 2020
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
10 changes: 0 additions & 10 deletions dgraph/cmd/alpha/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ they form a Raft group and provide synchronous replication.
flag.StringP("postings", "p", "p", "Directory to store posting lists.")

// Options around how to set up Badger.
flag.String("badger.tables", "mmap",
"[ram, mmap, disk] Specifies how Badger LSM tree is stored for the postings."+
"Option sequence consume most to least RAM while providing "+
"best to worst read performance respectively.")
flag.String("badger.vlog", "mmap",
"[mmap, disk] Specifies how Badger Value log is stored for the postings."+
"mmap consumes more RAM, but provides better performance.")
flag.String("badger.compression", "snappy",
"[none, zstd:level, snappy] Specifies the compression algorithm and the compression"+
"level (if applicable) for the postings directory. none would disable compression,"+
Expand Down Expand Up @@ -621,9 +614,6 @@ func run() {
AllottedMemory: Alpha.Conf.GetFloat64("lru_mb"),
}

opts.BadgerTables = Alpha.Conf.GetString("badger.tables")
opts.BadgerVlog = Alpha.Conf.GetString("badger.vlog")

secretFile := Alpha.Conf.GetString("acl_secret_file")
if secretFile != "" {
hmacSecret, err := ioutil.ReadFile(secretFile)
Expand Down
6 changes: 2 additions & 4 deletions dgraph/cmd/bulk/reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,10 @@ func (r *reducer) createBadgerInternal(dir string, compression bool) *badger.DB

opt := badger.DefaultOptions(dir).
WithSyncWrites(false).
WithTableLoadingMode(bo.MemoryMap).
WithValueThreshold(1 << 10 /* 1 KB */).
WithValueThreshold(1 << 20 /* 1 KB */).
WithEncryptionKey(key).
WithBlockCacheSize(r.opt.BlockCacheSize).
WithIndexCacheSize(r.opt.IndexCacheSize).
WithLoadBloomsOnOpen(false)
WithIndexCacheSize(r.opt.IndexCacheSize)

opt.Compression = bo.None
opt.ZSTDCompressionLevel = 0
Expand Down
2 changes: 1 addition & 1 deletion dgraph/cmd/bulk/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func init() {
flag.Int("badger.compression_level", 1,
"The compression level for Badger. A higher value uses more resources.")
flag.Int64("badger.cache_mb", 64, "Total size of cache (in MB) per shard in reducer.")
flag.String("badger.cache_percentage", "0,100",
flag.String("badger.cache_percentage", "100,0",
"Cache percentages summing up to 100 for various caches"+
" (FORMAT: BlockCacheSize, IndexCacheSize).")

Expand Down
2 changes: 0 additions & 2 deletions dgraph/cmd/debug/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"strings"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/dgraph/codec"
"github.com/dgraph-io/dgraph/ee/enc"
"github.com/dgraph-io/dgraph/posting"
Expand Down Expand Up @@ -774,7 +773,6 @@ func run() {
}

bopts := badger.DefaultOptions(dir).
WithTableLoadingMode(options.MemoryMap).
WithReadOnly(opt.readOnly).
WithEncryptionKey(opt.key)

Expand Down
3 changes: 1 addition & 2 deletions dgraph/cmd/debug/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ func printBasic(store RaftStore) (uint64, uint64) {
func printRaft(db *badger.DB, store *raftmigrate.OldDiskStorage) {
startIdx, lastIdx := printBasic(store)

commitTs, err := db.MaxVersion()
x.Check(err)
commitTs := db.MaxVersion()
// In case we need to truncate raft entries.
batch := db.NewWriteBatchAt(commitTs)
defer batch.Cancel()
Expand Down
4 changes: 2 additions & 2 deletions dgraph/cmd/live/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,10 @@ func setup(opts batchMutationOptions, dc *dgo.Dgraph, conf *viper.Viper) *loader

var err error
db, err = badger.Open(badger.DefaultOptions(opt.clientDir).
WithTableLoadingMode(bopt.MemoryMap).
WithCompression(bopt.ZSTD).
WithSyncWrites(false).
WithLoadBloomsOnOpen(false).
WithBlockCacheSize(100 * (1 << 20)).
WithIndexCacheSize(100 * (1 << 20)).
WithZSTDCompressionLevel(3))
x.Checkf(err, "Error while creating badger KV posting store")

Expand Down
4 changes: 1 addition & 3 deletions dgraph/cmd/raft-migrate/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ func run(conf *viper.Viper) error {
// Copied over from zero/run.go
kvOpt := badger.LSMOnlyOptions(oldDir).
WithSyncWrites(false).
WithTruncate(true).
WithValueLogFileSize(64 << 20).
WithLoadBloomsOnOpen(false)
WithValueLogFileSize(64 << 20)

kv, err := badger.OpenManaged(kvOpt)
x.Checkf(err, "Error while opening WAL store")
Expand Down
3 changes: 1 addition & 2 deletions dgraph/cmd/raft-migrate/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ func (w *OldDiskStorage) fetchMaxVersion() {
}
if err == badger.ErrKeyNotFound {
// We don't have the special key so get it using the MaxVersion API.
version, err := w.db.MaxVersion()
x.Check(err)
version := w.db.MaxVersion()

w.commitTs = version + 1
// Insert the same key back into badger for reuse.
Expand Down
5 changes: 3 additions & 2 deletions dgraph/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ func main() {

case ms.NumGC == lastNumGC:
runtime.GC()
glog.V(2).Infof("GC: %d. InUse: %s. Idle: %s\n", ms.NumGC,
glog.V(2).Infof("GC: %d. InUse: %s. Idle: %s. jemalloc: %s.\n", ms.NumGC,
humanize.IBytes(ms.HeapInuse),
humanize.IBytes(ms.HeapIdle-ms.HeapReleased))
humanize.IBytes(ms.HeapIdle-ms.HeapReleased),
humanize.IBytes(js.Active))
lastNumGC = ms.NumGC + 1
lastMs = ms
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ require (
github.com/blevesearch/segment v0.0.0-20160915185041-762005e7a34f // indirect
github.com/blevesearch/snowballstem v0.0.0-20180110192139-26b06a2c243d // indirect
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201001173203-feb98a8d999d
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201007014141-e3a0d29f75d9
github.com/dgraph-io/dgo/v200 v200.0.0-20200805103119-a3544c464dd6
github.com/dgraph-io/graphql-transport-ws v0.0.0-20200916064635-48589439591b
github.com/dgraph-io/ristretto v0.0.4-0.20201002035039-b807f09fa376
github.com/dgraph-io/ristretto v0.0.4-0.20201012160933-079c5f0d0daf
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13
Expand Down
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo=
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201001173203-feb98a8d999d h1:/0/ylo7/wmNoDM/aj4FHW4FQGGCPbTkp6pQK1tlnhJs=
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201001173203-feb98a8d999d/go.mod h1:2uGEvGm+JSDLd5UAaKIFSbXDcYyeH0fWJP4N2HMMYMI=
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201007014141-e3a0d29f75d9 h1:jcCG8IgceDFY0eigR/Zp2NwRYowQAVYRkVnmBPJEw+0=
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201007014141-e3a0d29f75d9/go.mod h1:KGLxSlEzmRl4n00ZXty5ibkBgDNbFJkHfjkn3Do0o6I=
github.com/dgraph-io/dgo/v200 v200.0.0-20200805103119-a3544c464dd6 h1:toHzMCdCUgYsjM0cW9+wafnKFXfp1HizIJUyzihN+vk=
github.com/dgraph-io/dgo/v200 v200.0.0-20200805103119-a3544c464dd6/go.mod h1:rHa+h3kI4M8ASOirxyIyNeXBfHFgeskVUum2OrDMN3U=
github.com/dgraph-io/graphql-transport-ws v0.0.0-20200916064635-48589439591b h1:PDEhlwHpkEQ5WBfOOKZCNZTXFDGyCEWTYDhxGQbyIpk=
github.com/dgraph-io/graphql-transport-ws v0.0.0-20200916064635-48589439591b/go.mod h1:7z3c/5w0sMYYZF5bHsrh8IH4fKwG5O5Y70cPH1ZLLRQ=
github.com/dgraph-io/ristretto v0.0.4-0.20200906165740-41ebdbffecfd/go.mod h1:YylP9MpCYGVZQrly/j/diqcdUetCRRePeBB0c2VGXsA=
github.com/dgraph-io/ristretto v0.0.4-0.20201002035039-b807f09fa376 h1:bp6nDHi2H+P7TTY/1MbwRcwSyMiDi3aD9w8PpF+kj+Q=
github.com/dgraph-io/ristretto v0.0.4-0.20201002035039-b807f09fa376/go.mod h1:bDI4cDaalvYSji3vBVDKrn9ouDZrwN974u8ZO/AhYXs=
github.com/dgraph-io/ristretto v0.0.4-0.20201012160933-079c5f0d0daf h1:FccUHvo6MMTYz+SrPSjgFuwp7W2376H34YVSzm8qjUY=
github.com/dgraph-io/ristretto v0.0.4-0.20201012160933-079c5f0d0daf/go.mod h1:bDI4cDaalvYSji3vBVDKrn9ouDZrwN974u8ZO/AhYXs=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1 h1:CaO/zOnF8VvUfEbhRatPcwKVWamvbYd8tQGRWacE9kU=
Expand Down Expand Up @@ -164,6 +163,8 @@ github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85q
github.com/google/btree v0.0.0-20180124185431-e89373fe6b4a/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/codesearch v1.0.0 h1:z4h5JoHkUS+GqxqPDrldC3Y0Qq0vHAGgaDEW5pWU/ys=
github.com/google/codesearch v1.0.0/go.mod h1:qCnXDFnak/trCmLaE50kgPte3AX9jSeruZexWEOivi0=
github.com/google/flatbuffers v1.12.0 h1:/PtAHvnBY4Kqnx/xCQ3OIV9uYcSFGScBsWI3Oogeh6w=
github.com/google/flatbuffers v1.12.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
Expand Down
10 changes: 8 additions & 2 deletions posting/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,14 @@ func (r *rebuilder) Run(ctx context.Context) error {
WithNumVersionsToKeep(math.MaxInt32).
WithLogger(&x.ToGlog{}).
WithCompression(options.None).
WithLogRotatesToFlush(10).
WithEncryptionKey(x.WorkerConfig.EncryptionKey)
WithLogRotatesToFlush(10)

// Set cache if we have encryption.
if len(x.WorkerConfig.EncryptionKey) > 0 {
dbOpts.EncryptionKey = x.WorkerConfig.EncryptionKey
dbOpts.BlockCacheSize = 100 << 20
dbOpts.IndexCacheSize = 100 << 20
}
tmpDB, err := badger.OpenManaged(dbOpts)
if err != nil {
return errors.Wrap(err, "error opening temp badger for reindexing")
Expand Down
6 changes: 1 addition & 5 deletions posting/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ func (w *TxnWriter) SetAt(key, val []byte, meta byte, ts uint64) error {

// Flush waits until all operations are done and all data is written to disk.
func (w *TxnWriter) Flush() error {
defer func() {
if err := w.db.Sync(); err != nil {
glog.Errorf("Error while calling Sync from TxnWriter.Flush: %v", err)
}
}()
// No need to call Sync here.
return w.Wait()
}

Expand Down
2 changes: 1 addition & 1 deletion protos/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ copy-protos:
@mkdir -p ${TMPDIR}/src/${DGO_PATH}/protos
@mkdir -p ${TMPDIR}/src/${BADGER_PATH}/pb
@mkdir -p ${TMPDIR}/src/${GOGO_PATH}/gogoproto
@cp $(shell go list -m -f "{{.Dir}}" ${BADGER_PATH})/pb/pb.proto ${TMPDIR}/src/${BADGER_PATH}/pb/pb.proto
@cp $(shell go list -m -f "{{.Dir}}" ${BADGER_PATH})/pb/badgerpb2.proto ${TMPDIR}/src/${BADGER_PATH}/pb/pb.proto
@cp $(shell go list -m -f "{{.Dir}}" ${DGO_PATH})/protos/api.proto ${TMPDIR}/src/${DGO_PATH}/protos/api.proto
@cp $(shell go list -m -f "{{.Dir}}" ${GOGO_PATH})/gogoproto/gogo.proto ${TMPDIR}/src/${GOGO_PATH}/gogoproto/gogo.proto

Expand Down
4 changes: 2 additions & 2 deletions raftwal/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ func logFname(dir string, id int64) string {
// openLogFile opens a logFile in the given directory. The filename is
// constructed based on the value of fid.
func openLogFile(dir string, fid int64) (*logFile, error) {
glog.V(2).Infof("opening log file: %d\n", fid)
glog.V(3).Infof("opening log file: %d\n", fid)
fpath := logFname(dir, fid)
// Open the file in read-write mode and create it if it doesn't exist yet.
mf, err := z.OpenMmapFile(fpath, os.O_RDWR|os.O_CREATE, logFileSize)

if err == z.NewFile {
glog.V(2).Infof("New file: %d\n", fid)
glog.V(3).Infof("New file: %d\n", fid)
z.ZeroOut(mf.Data, 0, logFileOffset)
} else {
x.Check(err)
Expand Down
19 changes: 6 additions & 13 deletions systest/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"testing"

Expand All @@ -43,28 +42,22 @@ func TestLoaderXidmap(t *testing.T) {

data, err := filepath.Abs("testdata/first.rdf.gz")
require.NoError(t, err)
liveCmd := exec.Command(testutil.DgraphBinaryPath(), "live",
err = testutil.ExecWithOpts([]string{testutil.DgraphBinaryPath(), "live",
"--files", data,
"--alpha", testutil.SockAddr,
"--zero", testutil.SockAddrZero,
"-x", "x",
)
liveCmd.Dir = tmpDir
require.NoError(t, liveCmd.Run())
"-x", "x"}, testutil.CmdOpts{Dir: tmpDir})
require.NoError(t, err)

// Load another file, live should reuse the xidmap.
data, err = filepath.Abs("testdata/second.rdf.gz")
require.NoError(t, err)
liveCmd = exec.Command(testutil.DgraphBinaryPath(), "live",
err = testutil.ExecWithOpts([]string{testutil.DgraphBinaryPath(), "live",
"--files", data,
"--alpha", testutil.SockAddr,
"--zero", testutil.SockAddrZero,
"-x", "x",
)
liveCmd.Dir = tmpDir
liveCmd.Stdout = os.Stdout
liveCmd.Stderr = os.Stdout
require.NoError(t, liveCmd.Run())
"-x", "x"}, testutil.CmdOpts{Dir: tmpDir})
require.NoError(t, err)

op := api.Operation{Schema: "name: string @index(exact) ."}
x.Check(dg.Alter(ctx, &op))
Expand Down
10 changes: 6 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,12 @@ if [[ :${TEST_SET}: == *:cluster:* ]]; then
fi

if [[ :${TEST_SET}: == *:systest:* ]]; then
Info "Running posting size calculation"
cd posting
RunCmd ./size_test.sh || TestFailed
cd ..
# TODO: Fix this test. The fix consists of updating the test script to
# download a p directory that's compatible with the badger WAL changes.
# Info "Running posting size calculation"
# cd posting
# RunCmd ./size_test.sh || TestFailed
# cd ..

Info "Running small load test"
RunCmd ./contrib/scripts/load-test.sh || TestFailed
Expand Down
6 changes: 3 additions & 3 deletions testutil/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"testing"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/dgraph/ee/enc"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/protos/pb"
Expand Down Expand Up @@ -50,8 +49,9 @@ func openDgraph(pdir string) (*badger.DB, error) {
return nil, err
}

opt := badger.DefaultOptions(pdir).WithTableLoadingMode(options.MemoryMap).
WithReadOnly(true).
opt := badger.DefaultOptions(pdir).
WithBlockCacheSize(10 * (1 << 20)).
WithIndexCacheSize(10 * (1 << 20)).
WithEncryptionKey(k)
return badger.OpenManaged(opt)
}
Expand Down
4 changes: 0 additions & 4 deletions worker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ const (
type Options struct {
// PostingDir is the path to the directory storing the postings..
PostingDir string
// BadgerTables is the name of the mode used to load the badger tables for the p directory.
BadgerTables string
// BadgerVlog is the name of the mode used to load the badger value log for the p directory.
BadgerVlog string

// PostingDirCompression is the compression algorithem used to compression Postings directory.
PostingDirCompression bo.CompressionType
Expand Down
7 changes: 6 additions & 1 deletion worker/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,11 @@ func (n *node) commitOrAbort(pkey string, delta *pb.OracleDelta) error {
return errors.Wrapf(err, "while flushing to disk")
}
}
if x.WorkerConfig.HardSync {
if err := pstore.Sync(); err != nil {
glog.Errorf("Error while calling Sync while commitOrAbort: %v", err)
}
}

g := groups()
if delta.GroupChecksums != nil && delta.GroupChecksums[g.groupId()] > 0 {
Expand Down Expand Up @@ -1317,7 +1322,7 @@ func (n *node) calculateTabletSizes() {
total += size
}

tableInfos := pstore.Tables(false)
tableInfos := pstore.Tables()
previousLeft := ""
var previousSize int64
glog.V(2).Infof("Calculating tablet sizes. Found %d tables\n", len(tableInfos))
Expand Down
3 changes: 0 additions & 3 deletions worker/file_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"time"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/dgraph/ee/enc"
"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/x"
Expand Down Expand Up @@ -296,7 +295,6 @@ func (h *fileHandler) ExportBackup(backupDir, exportDir, format string,
// file reader and verifying the encryption in the backup file.
db, err := badger.OpenManaged(badger.DefaultOptions(dir).
WithSyncWrites(false).
WithTableLoadingMode(options.MemoryMap).
WithValueThreshold(1 << 10).
WithNumVersionsToKeep(math.MaxInt32).
WithEncryptionKey(key))
Expand Down Expand Up @@ -349,7 +347,6 @@ func (h *fileHandler) ExportBackup(backupDir, exportDir, format string,
dir := filepath.Join(tmpDir, fmt.Sprintf("p%d", group))
db, err := badger.OpenManaged(badger.DefaultOptions(dir).
WithSyncWrites(false).
WithTableLoadingMode(options.MemoryMap).
WithValueThreshold(1 << 10).
WithNumVersionsToKeep(math.MaxInt32).
WithEncryptionKey(key))
Expand Down
4 changes: 2 additions & 2 deletions worker/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"path/filepath"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/options"
bpb "github.com/dgraph-io/badger/v2/pb"
"github.com/pkg/errors"

Expand Down Expand Up @@ -65,8 +64,9 @@ func RunRestore(pdir, location, backupId string, key x.SensitiveByteSlice) LoadR
// file reader and verifying the encryption in the backup file.
db, err := badger.OpenManaged(badger.DefaultOptions(dir).
WithSyncWrites(false).
WithTableLoadingMode(options.MemoryMap).
WithValueThreshold(1 << 10).
WithBlockCacheSize(100 * (1 << 20)).
WithIndexCacheSize(100 * (1 << 20)).
WithNumVersionsToKeep(math.MaxInt32).
WithEncryptionKey(key))
if err != nil {
Expand Down
Loading