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(Dgraph): Add badger.compression to Dgraph restore #6987

Merged
merged 1 commit into from
Nov 30, 2020

Conversation

ajeetdsouza
Copy link
Contributor

@ajeetdsouza ajeetdsouza commented Nov 25, 2020

dgraph restore does not currently use any form of compression. This PR adds a --badger.compression flag (similar to other Dgraph subcommands) and defaults all compression to snappy.


This change is Reviewable

@github-actions github-actions bot added area/bulk-loader Issues related to bulk loading. area/enterprise Related to proprietary features area/testing Testing related issues labels Nov 25, 2020
@netlify
Copy link

netlify bot commented Nov 25, 2020

Deploy preview for dgraph-docs ready!

Built with commit 239336b

https://deploy-preview-6987--dgraph-docs.netlify.app

@@ -158,10 +158,6 @@ func run() {
if opt.Version {
os.Exit(0)
}
if opt.BadgerCompressionLevel < 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been removed because this is derived from x.ParseCompression, which calls glog.Fatal in case of a negative compression level. Thus, there is no need to check over here.

@@ -111,6 +112,10 @@ $ dgraph restore -p . -l /var/backups/dgraph -z localhost:5080
}

flag := Restore.Cmd.Flags()
flag.StringVar(&opt.compression, "badger.compression", "snappy",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the third place in the code where this exact description has been duplicated. Perhaps we could extract it out elsewhere.

@@ -35,7 +36,7 @@ import (
)

// RunRestore calls badger.Load and tries to load data into a new DB.
func RunRestore(pdir, location, backupId string, key x.SensitiveByteSlice) LoadResult {
func RunRestore(pdir, location, backupId string, key x.SensitiveByteSlice, ctype options.CompressionType, clevel int) LoadResult {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like too many arguments. Should this function be changed to take in the entire opt struct instead?

@@ -354,7 +355,7 @@ func runFailingRestore(t *testing.T, backupLocation, lastDir string, commitTs ui
require.NotNil(t, k)
require.NoError(t, err)

result := worker.RunRestore("./data/restore", backupLocation, lastDir, k)
result := worker.RunRestore("./data/restore", backupLocation, lastDir, k, options.Snappy, 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: these tests did not use any form of compression earlier, but I've changed them to use snappy by default.

@ajeetdsouza ajeetdsouza changed the title Add badger.compression to Dgraph restore feat(Dgraph): Add badger.compression to Dgraph restore Nov 26, 2020
@ajeetdsouza ajeetdsouza merged commit 784b245 into master Nov 30, 2020
@ajeetdsouza ajeetdsouza deleted the ajeet/compression branch November 30, 2020 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bulk-loader Issues related to bulk loading. area/enterprise Related to proprietary features area/testing Testing related issues
Development

Successfully merging this pull request may close these issues.

2 participants