Skip to content
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

feat(magicNumber): Introduce magic number #8032

Merged
merged 5 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/Shopify/sarama v1.27.2
github.com/blevesearch/bleve v1.0.13
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd
github.com/dgraph-io/badger/v3 v3.0.0-20210914152503-560e319d7ceb
github.com/dgraph-io/badger/v3 v3.0.0-20210916095630-2a9a524b649b
github.com/dgraph-io/dgo/v210 v210.0.0-20210421093152-78a2fece3ebd
github.com/dgraph-io/gqlgen v0.13.2
github.com/dgraph-io/gqlparser/v2 v2.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ 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/v3 v3.0.0-20210914152503-560e319d7ceb h1:FlJGJO+ebnP7GeDe8K77tRuLwCJSVoMgOsTFCgcbFtg=
github.com/dgraph-io/badger/v3 v3.0.0-20210914152503-560e319d7ceb/go.mod h1:dULbq6ehJ5K0cGW/1TQ9iSfUk0gbSiToDWmWmTsJ53E=
github.com/dgraph-io/badger/v3 v3.0.0-20210916095630-2a9a524b649b h1:t7Em1/gcmd4THIGLYDHhkxwLE/gbNLe08QFVM0dKxaQ=
github.com/dgraph-io/badger/v3 v3.0.0-20210916095630-2a9a524b649b/go.mod h1:dULbq6ehJ5K0cGW/1TQ9iSfUk0gbSiToDWmWmTsJ53E=
github.com/dgraph-io/dgo/v210 v210.0.0-20210421093152-78a2fece3ebd h1:bKck5FnruuJxL1oCmrDSYWRl634IxBwL/IwwWx4UgEM=
github.com/dgraph-io/dgo/v210 v210.0.0-20210421093152-78a2fece3ebd/go.mod h1:dCzdThGGTPYOAuNtrM6BiXj/86voHn7ZzkPL6noXR3s=
github.com/dgraph-io/gqlgen v0.13.2 h1:TNhndk+eHKj5qE7BenKKSYdSIdOGhLqxR1rCiMso9KM=
Expand Down
5 changes: 5 additions & 0 deletions worker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import (
)

const (
// magicVersion is a unique uint16 number. Badger won't start if this magic number doesn't match
// with the one presnet in the manifest. It prevents starting up dgraph with new data format
ahsanbarkati marked this conversation as resolved.
Show resolved Hide resolved
// (using roaring bitmap) on older p directory.
ahsanbarkati marked this conversation as resolved.
Show resolved Hide resolved
magicVersion = uint16(2109)

// AllowMutations is the mode allowing all mutations.
AllowMutations int = iota
// DisallowMutations is the mode that disallows all mutations.
Expand Down
3 changes: 2 additions & 1 deletion worker/server_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ func (s *ServerState) initStorage() {
opt := x.WorkerConfig.Badger.
WithDir(Config.PostingDir).WithValueDir(Config.PostingDir).
WithNumVersionsToKeep(math.MaxInt32).
WithNamespaceOffset(x.NamespaceOffset)
WithNamespaceOffset(x.NamespaceOffset).
WithExternalMagic(magicVersion)
opt = setBadgerOptions(opt)

// Print the options w/o exposing key.
Expand Down