Skip to content

Commit 695c6d7

Browse files
authored
fix(zero): fix update membership to make bulk tablet proposal instead of multiple small (#8090)
Converting the smaller tablet proposals into a single bulk call makes the execution faster. Else, this update becomes of the order of O(n^2), where n is the number of tablet updates.
1 parent c204d0a commit 695c6d7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

dgraph/cmd/zero/zero.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ func (s *Server) createProposals(dst *pb.Group) ([]*pb.ZeroProposal, error) {
380380
})
381381
}
382382
}
383+
384+
var tablets []*pb.Tablet
383385
for key, dstTablet := range dst.Tablets {
384386
group, has := s.state.Groups[dstTablet.GroupId]
385387
if !has {
@@ -395,12 +397,13 @@ func (s *Server) createProposals(dst *pb.Group) ([]*pb.ZeroProposal, error) {
395397
d := float64(dstTablet.OnDiskBytes)
396398
if dstTablet.Remove || (s == 0 && d > 0) || (s > 0 && math.Abs(d/s-1) > 0.1) {
397399
dstTablet.Force = false
398-
proposal := &pb.ZeroProposal{
399-
Tablet: dstTablet,
400-
}
401-
res = append(res, proposal)
400+
tablets = append(tablets, dstTablet)
402401
}
403402
}
403+
404+
if len(tablets) > 0 {
405+
res = append(res, &pb.ZeroProposal{Tablets: tablets})
406+
}
404407
return res, nil
405408
}
406409

0 commit comments

Comments
 (0)