Skip to content

fix(magic): fix the magic version in bulk loader etc #8070

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 2 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
3 changes: 2 additions & 1 deletion dgraph/cmd/bulk/reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func (r *reducer) createBadgerInternal(dir string, compression bool) *badger.DB
opt := r.state.opt.Badger.
WithDir(dir).WithValueDir(dir).
WithSyncWrites(false).
WithEncryptionKey(key)
WithEncryptionKey(key).
WithExternalMagic(x.MagicVersion)

opt.Compression = bo.None
opt.ZSTDCompressionLevel = 0
Expand Down
4 changes: 1 addition & 3 deletions dgraph/cmd/debug/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ type flagOptions struct {
namespace uint64
key x.Sensitive
onlySummary bool
magic uint16

// Options related to the WAL.
wdir string
Expand Down Expand Up @@ -109,7 +108,6 @@ 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.")
Expand Down Expand Up @@ -880,7 +878,7 @@ func run() {
WithEncryptionKey(opt.key).
WithBlockCacheSize(1 << 30).
WithIndexCacheSize(1 << 30).
WithExternalMagic(opt.magic).
WithExternalMagic(x.MagicVersion).
WithNamespaceOffset(x.NamespaceOffset) // We don't want to see the banned data.

x.AssertTruef(len(bopts.Dir) > 0, "No posting or wal dir specified.")
Expand Down
3 changes: 2 additions & 1 deletion worker/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ func StoreExport(request *pb.ExportRequest, dir string, key x.Sensitive) error {
WithSyncWrites(false).
WithValueThreshold(1 << 10).
WithNumVersionsToKeep(math.MaxInt32).
WithEncryptionKey(key))
WithEncryptionKey(key).
WithExternalMagic(x.MagicVersion))

if err != nil {
return err
Expand Down
3 changes: 0 additions & 3 deletions worker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import (
)

const (
// magicVersion is a unique uint16 number. Badger won't start if this magic number doesn't match
// with the one present in the manifest. It prevents starting up dgraph with new data format
// (eg. the change in 21.09 by using roaring bitmap) on older p directory.
magicVersion = 1

// AllowMutations is the mode allowing all mutations.
Expand Down
3 changes: 2 additions & 1 deletion worker/online_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ func RunOfflineRestore(dir, location, backupId string, keyFile string,
WithIndexCacheSize(100 * (1 << 20)).
WithNumVersionsToKeep(math.MaxInt32).
WithEncryptionKey(key).
WithNamespaceOffset(x.NamespaceOffset))
WithNamespaceOffset(x.NamespaceOffset).
WithExternalMagic(x.MagicVersion))
if err != nil {
return LoadResult{Err: errors.Wrap(err, "RunRestore failed to open DB")}
}
Expand Down
2 changes: 1 addition & 1 deletion worker/server_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (s *ServerState) initStorage() {
WithDir(Config.PostingDir).WithValueDir(Config.PostingDir).
WithNumVersionsToKeep(math.MaxInt32).
WithNamespaceOffset(x.NamespaceOffset).
WithExternalMagic(magicVersion)
WithExternalMagic(x.MagicVersion)
opt = setBadgerOptions(opt)

// Print the options w/o exposing key.
Expand Down
5 changes: 5 additions & 0 deletions x/x.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ const (
DgraphCostHeader = "Dgraph-TouchedUids"

ManifestVersion = 2105

// MagicVersion is a unique uint16 number. Badger won't start if this magic number doesn't match
// with the one present in the manifest. It prevents starting up dgraph with new data format
// (eg. the change in 21.09 by using roaring bitmap) on older p directory.
MagicVersion = 1
)

var (
Expand Down