-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
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.
Deploy preview for dgraph-docs ready! Built with commit 6232050 |
3799931
to
4172438
Compare
ctx := context.Background() | ||
|
||
require.NoError(t, dg.Alter(ctx, &api.Operation{DropAll: true})) | ||
time.Sleep(2 * time.Second) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use copyBackupDir
instead.
There was a problem hiding this comment.
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.") |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require.NoError please
615e3e3
to
88a8323
Compare
88a8323
to
6232050
Compare
#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>
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