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

Add series and backup number information to manifest. #3559

Merged
merged 7 commits into from
Jun 17, 2019

Conversation

martinmr
Copy link
Contributor

@martinmr martinmr commented Jun 13, 2019

  • Remove partial restore feature. Replace it with the ability to restore a series by its uid.
  • Add series uid and backup num info to the manifest. This makes it easy to restore a single uid
    and to verify there are no gaps in the manifests to prevent restoring corrupted data.
  • Added tests for verification of manifests based on series and backup nums.

This change is Reviewable

@martinmr martinmr requested review from manishrjain and a team as code owners June 13, 2019 23:12
ee/backup/backup.go Outdated Show resolved Hide resolved
ee/backup/backup.go Outdated Show resolved Hide resolved
ee/backup/file_handler.go Outdated Show resolved Hide resolved
ee/backup/handler.go Outdated Show resolved Hide resolved
ee/backup/handler.go Outdated Show resolved Hide resolved
ee/backup/handler.go Outdated Show resolved Hide resolved
ee/backup/run.go Outdated Show resolved Hide resolved
ee/backup/run.go Outdated Show resolved Hide resolved
ee/backup/s3_handler.go Outdated Show resolved Hide resolved
Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

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

:lgtm: Got a few comments. Address those before merging.

Reviewed 8 of 9 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @golangcibot and @martinmr)


ee/backup/backup.go, line 52 at r1 (raw file):

Previously, golangcibot (Bot from GolangCI) wrote…

struct field SeriesUid should be SeriesUID (from golint)

Call it BackupId. Then the one below can be called BackupNum. Don't call it Uid.


ee/backup/backup.go, line 57 at r1 (raw file):

Previously, golangcibot (Bot from GolangCI) wrote…

structtag: struct field tag json"backup_num" not compatible with reflect.StructTag.Get: bad syntax for struct tag pair (from govet)

huh? Can you look into this?


ee/backup/handler.go, line 186 at r2 (raw file):

	var filteredManifests []*Manifest
	for i := len(manifests) - 1; i >= 0; i-- {
		if len(seriesUid) > 0 && manifests[i].SeriesUid != seriesUid {

You most likely don't need the len(seriesUid) check. The not equals should be sufficient.


x/names-generator.go, line 1 at r2 (raw file):

// Taken from

Finish this comment.

Also, if you can copy over the license from Docker, please do and paste it here. Then add a comment that Copied from docker ..., and modified by Dgraph.

Path string `json:"-"`
// BackupId is a unique ID assigned to all the backups in the same series
// (from the first full backup to the last incremental backup).
BackupId string `json:"backup_id"`

Choose a reason for hiding this comment

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

struct field BackupId should be BackupID (from golint)

@@ -111,7 +111,7 @@ func (h *fileHandler) CreateManifest(uri *url.URL, req *pb.BackupRequest) error

// Load uses tries to load any backup files found.
// Returns the maximum value of Since on success, error otherwise.
func (h *fileHandler) Load(uri *url.URL, lastDir string, fn loadFn) (uint64, error) {
func (h *fileHandler) Load(uri *url.URL, backupId string, fn loadFn) (uint64, error) {

Choose a reason for hiding this comment

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

method parameter backupId should be backupID (from golint)

ee/backup/handler.go Show resolved Hide resolved
@@ -181,14 +179,16 @@ func ListManifests(l string) (map[string]*Manifest, error) {

// filterManifests takes a list of manifests and returns the list of manifests
// that should be considered during a restore.
func filterManifests(manifests []*Manifest, lastDir string) ([]*Manifest, error) {
func filterManifests(manifests []*Manifest, backupId string) ([]*Manifest, error) {

Choose a reason for hiding this comment

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

func parameter backupId should be backupID (from golint)

manifests[0].BackupNum)
}

seriesUid := manifests[0].BackupId

Choose a reason for hiding this comment

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

var seriesUid should be seriesUID (from golint)

@@ -38,7 +38,7 @@ var Restore x.SubCommand
var LsBackup x.SubCommand

var opt struct {
lastDir, location, pdir, zero string
backupId, location, pdir, zero string

Choose a reason for hiding this comment

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

struct field backupId should be backupID (from golint)

@@ -216,7 +214,7 @@ func runRestoreCmd() error {
}

// RunRestore calls badger.Load and tries to load data into a new DB.
func RunRestore(pdir, location, lastDir string) (uint64, error) {
func RunRestore(pdir, location, backupId string) (uint64, error) {

Choose a reason for hiding this comment

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

func parameter backupId should be backupID (from golint)

@@ -239,7 +239,7 @@ func (h *s3Handler) readManifest(mc *minio.Client, object string, m *Manifest) e
// Load creates a new session, scans for backup objects in a bucket, then tries to
// load any backup objects found.
// Returns nil and the maximum Since value on success, error otherwise.
func (h *s3Handler) Load(uri *url.URL, lastDir string, fn loadFn) (uint64, error) {
func (h *s3Handler) Load(uri *url.URL, backupId string, fn loadFn) (uint64, error) {

Choose a reason for hiding this comment

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

method parameter backupId should be backupID (from golint)

Copy link
Contributor Author

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 9 files reviewed, 19 unresolved discussions (waiting on @golangcibot, @manishrjain, and @martinmr)


ee/backup/backup.go, line 52 at r1 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Call it BackupId. Then the one below can be called BackupNum. Don't call it Uid.

Done.


ee/backup/backup.go, line 57 at r1 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

huh? Can you look into this?

Already fixed. The warning was triggered because I missed the colon in my first commit.


ee/backup/handler.go, line 186 at r2 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

You most likely don't need the len(seriesUid) check. The not equals should be sufficient.

If the backupId is empty, it means that option was not passed in the command line. So by default we want to restore the latest series of backups. If I remove this all the backups will be skipped, which is not what we want. I have added a comment explaining this.


x/names-generator.go, line 1 at r2 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Finish this comment.

Also, if you can copy over the license from Docker, please do and paste it here. Then add a comment that Copied from docker ..., and modified by Dgraph.

Done.

@martinmr martinmr merged commit c913555 into master Jun 17, 2019
@martinmr martinmr deleted the martinmr/backup-series branch June 17, 2019 20:12
dna2github pushed a commit to dna2fork/dgraph that referenced this pull request Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants