Skip to content

Commit

Permalink
fix(raftwal): unmarshal snapshot onto zerosnapshot instead of members…
Browse files Browse the repository at this point in the history
…hipState (#7125) (#7128)

We were unmarshalling into incorrect type (MembershipState) the snapshot which contained data marshalled from ZeroSnapshot. This PR fixes that.

(cherry picked from commit 55dd455)
  • Loading branch information
NamanJain8 committed Dec 14, 2020
1 parent 88505f6 commit 098480f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions dgraph/cmd/debug/wal.go
Expand Up @@ -71,11 +71,11 @@ func printBasic(store RaftStore) (uint64, uint64) {
} else {
fmt.Printf("Snapshot Metadata: %+v\n", snap.Metadata)
var ds pb.Snapshot
var ms pb.MembershipState
var zs pb.ZeroSnapshot
if err := ds.Unmarshal(snap.Data); err == nil {
fmt.Printf("Snapshot Alpha: %+v\n", ds)
} else if err := ms.Unmarshal(snap.Data); err == nil {
for gid, group := range ms.GetGroups() {
} else if err := zs.Unmarshal(snap.Data); err == nil {
for gid, group := range zs.State.GetGroups() {
fmt.Printf("\nGROUP: %d\n", gid)
for _, member := range group.GetMembers() {
fmt.Printf("Member: %+v .\n", member)
Expand All @@ -87,8 +87,8 @@ func printBasic(store RaftStore) (uint64, uint64) {
group.Tablets = nil
fmt.Printf("Group: %d %+v .\n", gid, group)
}
ms.Groups = nil
fmt.Printf("\nSnapshot Zero: %+v\n", ms)
zs.State.Groups = nil
fmt.Printf("\nSnapshot Zero: %+v\n", zs)
} else {
fmt.Printf("Unable to unmarshal Dgraph snapshot: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions dgraph/cmd/zero/raft.go
Expand Up @@ -546,11 +546,11 @@ func (n *node) initAndStartNode() error {
// It is important that we pick up the conf state here.
n.SetConfState(&sp.Metadata.ConfState)

var state pb.MembershipState
x.Check(state.Unmarshal(sp.Data))
n.server.SetMembershipState(&state)
var zs pb.ZeroSnapshot
x.Check(zs.Unmarshal(sp.Data))
n.server.SetMembershipState(zs.State)
for _, id := range sp.Metadata.ConfState.Nodes {
n.Connect(id, state.Zeros[id].Addr)
n.Connect(id, zs.State.Zeros[id].Addr)
}
}

Expand Down

0 comments on commit 098480f

Please sign in to comment.