Skip to content

Commit

Permalink
fix to assorted list of goroutine leaks. (dgraph-io#3074)
Browse files Browse the repository at this point in the history
In all of these channel allocs multiple goroutines are executed and returned early
in case of error. We don't wait for other goroutines to terminate while blocked on
sending to the channel.
  • Loading branch information
srfrog authored and dna2github committed Jul 19, 2019
1 parent 3f5c36c commit dd7b388
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dgraph/cmd/zero/zero.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ func (s *Server) UpdateMembership(ctx context.Context, group *pb.Group) (*api.Pa
ctx, cancel := context.WithCancel(ctx)
defer cancel()

errCh := make(chan error)
errCh := make(chan error, len(proposals))
for _, pr := range proposals {
go func(pr *pb.ZeroProposal) {
errCh <- s.Node.proposeAndWait(ctx, pr)
Expand Down
2 changes: 1 addition & 1 deletion worker/backup_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func BackupOverNetwork(pctx context.Context, dst string) error {

// This will dispatch the request to all groups and wait for their response.
// If we receive any failures, we cancel the process.
errCh := make(chan error, 1)
errCh := make(chan error, len(gids))
for _, gid := range gids {
go func(gid uint32) {
req.GroupId = gid
Expand Down
4 changes: 2 additions & 2 deletions worker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er
x.AssertTrue(width > 0)
span.Annotatef(nil, "Width: %d. NumGo: %d", width, numGo)

errCh := make(chan error, 1)
errCh := make(chan error, numGo)
outputs := make([]*pb.Result, numGo)
listType := schema.State().IsList(q.Attr)

Expand Down Expand Up @@ -548,7 +548,7 @@ func (qs *queryState) handleUidPostings(
x.AssertTrue(width > 0)
span.Annotatef(nil, "Width: %d. NumGo: %d", width, numGo)

errCh := make(chan error, 1)
errCh := make(chan error, numGo)
outputs := make([]*pb.Result, numGo)

calculate := func(start, end int) error {
Expand Down

0 comments on commit dd7b388

Please sign in to comment.