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

fix(enterprise): Set version correctly post marshalling during restore #7018

Merged
merged 9 commits into from
Dec 2, 2020

Conversation

rahulgurnani
Copy link
Contributor

@rahulgurnani rahulgurnani commented Nov 30, 2020

Fixes DGRAPH-2775
The marshalPostingList function returns a KV without the version set and
this causes issues if you restore a backup on top of an existing data.
This PR fixes this issue by explicitly setting the version for the KV
returned by the MarshalPostingList function.

Also added a test which for incremental backup which was failing before this change.


This change is Reviewable

rahulgurnani and others added 3 commits November 26, 2020 19:28
The marshalPostingList function returns a KV without the version set and
this causes issues if you restore a backup on top of an existing data.
This PR fixes this issue by explicitly setting the version for the KV
returned by the MarshalPostingList function.
@netlify
Copy link

netlify bot commented Nov 30, 2020

Deploy preview for dgraph-docs ready!

Built with commit 6232050

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

systest/backup/filesystem/backup_test.go Outdated Show resolved Hide resolved
ctx := context.Background()

require.NoError(t, dg.Alter(ctx, &api.Operation{DropAll: true}))
time.Sleep(2 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please confirm that these sleeps are good enough by running the tests multiple times. Otherwise these can be flaky.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Ran it 10 times locally.

systest/backup/filesystem/backup_test.go Outdated Show resolved Hide resolved
systest/backup/filesystem/backup_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jarifibrahim jarifibrahim left a comment

Choose a reason for hiding this comment

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

Got some comments.

@@ -330,7 +399,7 @@ func runBackupInternal(t *testing.T, forceFull bool, numExpectedFiles,
copyToLocalFs(t)

files := x.WalkPathFunc(copyBackupDir, func(path string, isdir bool) bool {
return !isdir && strings.HasSuffix(path, ".backup")
return !isdir && strings.HasSuffix(path, ".backup") && strings.HasPrefix(path, "data/backups_copy/dgraph.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Use copyBackupDir instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it would not help because copyBackupDir = ./data/backups_copy

@@ -340,7 +409,7 @@ func runBackupInternal(t *testing.T, forceFull bool, numExpectedFiles,
require.Equal(t, numExpectedDirs, len(dirs))

manifests := x.WalkPathFunc(copyBackupDir, func(path string, isdir bool) bool {
return !isdir && strings.Contains(path, "manifest.json")
return !isdir && strings.Contains(path, "manifest.json") && strings.HasPrefix(path, "data/backups_copy/dgraph.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Use copyBackupDir instead.

copyBackupDir = "./data/backups_copy"
restoreDir = "./data/restore"
testDirs = []string{restoreDir, exporterDir}
exporterDir = "data/exporter"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see exporterDir being used anywhere. Why do we have it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, cleaned it up

func copyOldBackupDir(t *testing.T) {
destPath := testutil.DockerPrefix + "_alpha1_1:/data"
srchPath := "." + oldBackupDir
if err := testutil.DockerCp(srchPath, destPath); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

require.NoError please

systest/backup/filesystem/backup_test.go Outdated Show resolved Hide resolved
systest/backup/filesystem/backup_test.go Outdated Show resolved Hide resolved
systest/backup/filesystem/backup_test.go Outdated Show resolved Hide resolved
systest/backup/filesystem/backup_test.go Outdated Show resolved Hide resolved
systest/backup/filesystem/backup_test.go Show resolved Hide resolved
@rahulgurnani rahulgurnani force-pushed the rahulgurnani/backup_restore branch 5 times, most recently from 615e3e3 to 88a8323 Compare December 1, 2020 12:14
@rahulgurnani rahulgurnani merged commit 30ee966 into master Dec 2, 2020
rahulgurnani added a commit that referenced this pull request Dec 2, 2020
#7018)

* Add test for old restore to a cluster

* Fix author query

* fix(restore): Use correct version after marshalling

The marshalPostingList function returns a KV without the version set and
this causes issues if you restore a backup on top of an existing data.
This PR fixes this issue by explicitly setting the version for the KV
returned by the MarshalPostingList function.

* Fix test for restoring old backup incremental

* Address review comments

* Add old backup dir

* Add wait for restore, address review comments

* Make test use tls, refactor out waitforrestore

Co-authored-by: Ibrahim Jarif <ibrahim@dgraph.io>
@joshua-goldstein joshua-goldstein deleted the rahulgurnani/backup_restore branch August 11, 2022 21:00
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