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

Access groupi.gid atomically #3402

Merged
merged 2 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dgraph/cmd/alpha/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,14 +527,14 @@ func run() {
sdCh := make(chan os.Signal, 3)
shutdownCh = make(chan struct{})

var numShutDownSig int
defer func() {
signal.Stop(sdCh)
close(sdCh)
}()
// sigint : Ctrl-C, sigterm : kill command.
signal.Notify(sdCh, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
go func() {
var numShutDownSig int
for {
select {
case _, ok := <-sdCh:
Expand All @@ -555,7 +555,6 @@ func run() {
}
}
}()
_ = numShutDownSig

// Setup external communication.
aclCloser := y.NewCloser(1)
Expand Down
2 changes: 1 addition & 1 deletion worker/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ func (n *node) commitOrAbort(pkey string, delta *pb.OracleDelta) error {
}

g := groups()
atomic.StoreUint64(&g.deltaChecksum, delta.GroupChecksums[g.gid])
atomic.StoreUint64(&g.deltaChecksum, delta.GroupChecksums[g.groupId()])

// Now advance Oracle(), so we can service waiting reads.
posting.Oracle().ProcessDelta(delta)
Expand Down
10 changes: 4 additions & 6 deletions worker/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ func (g *groupi) applyState(state *pb.MembershipState) {
for _, tablet := range group.Tablets {
g.tablets[tablet.Predicate] = tablet
}
if gid == g.gid {
glog.V(3).Infof("group %d checksum: %d", g.gid, group.Checksum)
if gid == g.groupId() {
glog.V(3).Infof("group %d checksum: %d", g.groupId(), group.Checksum)
atomic.StoreUint64(&g.membershipChecksum, group.Checksum)
}
}
Expand Down Expand Up @@ -289,9 +289,7 @@ func (g *groupi) applyState(state *pb.MembershipState) {
}

func (g *groupi) ServesGroup(gid uint32) bool {
g.RLock()
defer g.RUnlock()
return g.gid == gid
return g.groupId() == gid
}

func (g *groupi) ChecksumsMatch(ctx context.Context) error {
Expand All @@ -307,7 +305,7 @@ func (g *groupi) ChecksumsMatch(ctx context.Context) error {
return nil
}
case <-ctx.Done():
return fmt.Errorf("Group checksum mismatch for id: %d", g.gid)
return fmt.Errorf("Group checksum mismatch for id: %d", g.groupId())
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions worker/predicate_move.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ func (w *grpcWorker) MovePredicate(ctx context.Context,
if !n.AmLeader() {
return &emptyPayload, errNotLeader
}
if groups().gid != in.SourceGid {
if groups().groupId() != in.SourceGid {
return &emptyPayload,
x.Errorf("Group id doesn't match, received request for %d, my gid: %d",
in.SourceGid, groups().gid)
in.SourceGid, groups().groupId())
}
if len(in.Predicate) == 0 {
return &emptyPayload, errEmptyPredicate
Expand Down