Skip to content

Commit

Permalink
Online restores only processes backups for the alpha's group (dgraph-…
Browse files Browse the repository at this point in the history
…io#5588)

I changed the test backup to have three groups instead of one and I noticed that
the test didn't work anymore. There was a missing check that caused every
group's backup to be restored to the alpha. After introducing the check, all
tests pass again.

Fixes DGRAPH-1663
  • Loading branch information
martinmr authored and dna2github committed Jul 18, 2020
1 parent 4023ab1 commit 549af23
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 10 deletions.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"full","since":15,"groups":{"1":["dgraph.type","dgraph.graphql.xid","dgraph.graphql.schema"],"2":[],"3":[]},"backup_id":"cranky_bartik8","backup_num":1,"encrypted":true}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�DnjzEM)�ڟ��͈9�Dk\�~�"�P/�^�-2#63�\{NR�<I�@[ۇe�[vVw��p&1j��f Gl{��hX7�@9�Fo�D��{��h�6|�F
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"incremental","since":2106,"groups":{"1":["performance.actor","dgraph.graphql.xid","dgraph.graphql.schema","dgraph.type","rating","rated"],"2":["email","performance.film","performance.character","name"],"3":["country","loc","genre","initial_release_date","performance.character_note","starring","director.film","actor.film","tagline","cut.note"]},"backup_id":"cranky_bartik8","backup_num":2,"encrypted":true}
Binary file not shown.
Binary file not shown.
Binary file not shown.
66 changes: 60 additions & 6 deletions systest/online-restore/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Auto-generated with: [./compose -a 1 -z 1 --ratel -w]
# Auto-generated with: [./compose --num_zeros 1 --num_alphas 3 --ratel]
#
version: "3.5"
services:
Expand All @@ -23,10 +23,64 @@ services:
- type: bind
source: ./backup
target: /data/backup
read_only: true
read_only: false
command: /gobin/dgraph alpha -o 100 --my=alpha1:7180 --lru_mb=1024 --zero=zero1:5180
--logtostderr -v=2 --idx=1 --whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
--encryption_key_file /data/keys/enc_key
--logtostderr -v=2 --idx=1 --encryption_key_file /data/keys/enc_key
--whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
alpha2:
image: dgraph/dgraph:latest
container_name: alpha2
working_dir: /data/alpha2
depends_on:
- alpha1
labels:
cluster: test
ports:
- 8182:8182
- 9182:9182
volumes:
- type: bind
source: $GOPATH/bin
target: /gobin
read_only: true
- type: bind
source: ./keys
target: /data/keys
read_only: true
- type: bind
source: ./backup
target: /data/backup
read_only: false
command: /gobin/dgraph alpha -o 102 --my=alpha2:7182 --lru_mb=1024 --zero=zero1:5180
--logtostderr -v=2 --idx=2 --encryption_key_file /data/keys/enc_key
--whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
alpha3:
image: dgraph/dgraph:latest
container_name: alpha3
working_dir: /data/alpha3
depends_on:
- alpha2
labels:
cluster: test
ports:
- 8183:8183
- 9183:9183
volumes:
- type: bind
source: $GOPATH/bin
target: /gobin
read_only: true
- type: bind
source: ./keys
target: /data/keys
read_only: true
- type: bind
source: ./backup
target: /data/backup
read_only: false
command: /gobin/dgraph alpha -o 103 --my=alpha3:7183 --lru_mb=1024 --zero=zero1:5180
--logtostderr -v=2 --idx=3 --encryption_key_file /data/keys/enc_key
--whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
ratel:
image: dgraph/dgraph:latest
container_name: ratel
Expand All @@ -47,6 +101,6 @@ services:
source: $GOPATH/bin
target: /gobin
read_only: true
command: /gobin/dgraph zero -o 100 --idx=1 --my=zero1:5180 --logtostderr -v=2
--bindall
command: /gobin/dgraph zero -o 100 --idx=1 --my=zero1:5180 --replicas=1 --logtostderr
-v=2 --bindall
volumes: {}
4 changes: 2 additions & 2 deletions systest/online-restore/online_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (

func sendRestoreRequest(t *testing.T) {
restoreRequest := `mutation restore() {
restore(input: {location: "/data/backup", backupId: "heuristic_sammet9",
restore(input: {location: "/data/backup", backupId: "cranky_bartik8",
encryptionKeyFile: "/data/keys/enc_key"}) {
response {
code
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestListBackups(t *testing.T) {
buf, err := ioutil.ReadAll(resp.Body)
require.NoError(t, err)
sbuf := string(buf)
require.Contains(t, sbuf, `"backupId":"heuristic_sammet9"`)
require.Contains(t, sbuf, `"backupId":"cranky_bartik8"`)
require.Contains(t, sbuf, `"backupNum":1`)
require.Contains(t, sbuf, `"backupNum":2`)
require.Contains(t, sbuf, "initial_release_date")
Expand Down
6 changes: 6 additions & 0 deletions worker/online_restore_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ func getEncConfig(req *pb.RestoreRequest) (*viper.Viper, error) {
func writeBackup(ctx context.Context, req *pb.RestoreRequest) error {
res := LoadBackup(req.Location, req.BackupId,
func(r io.Reader, groupId uint32, preds predicateSet) (uint64, error) {
if groupId != req.GroupId {
// LoadBackup will try to call the backup function for every group.
// Exit here if the group is not the one indicated by the request.
return 0, nil
}

cfg, err := getEncConfig(req)
if err != nil {
return 0, errors.Wrapf(err, "unable to get encryption config")
Expand Down

0 comments on commit 549af23

Please sign in to comment.