Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return nil instead of emptyTablet in groupi.Tablet() (#5469)
groupi.Tablet returns error and empty Tablet when error is returned while querying zero for Tablet serving info. Allocation of space by empty Tablet shows up in alloc_space profile. . . 463:func (g *groupi) Tablet(key string) (*pb.Tablet, error) { 16.22GB 16.22GB 464: emptyTablet := pb.Tablet{} . . 465: . . 466: // TODO: Remove all this later, create a membership state and apply it . . 467: g.RLock() . . 468: tablet, ok := g.tablets[key] . . 469: g.RUnlock() . . 470: if ok { . . 471: return tablet, nil . . 472: } . . 473: . . 474: // We don't know about this tablet. . . 475: // Check with dgraphzero if we can serve it. . . 476: pl := g.connToZeroLeader() . . 477: zc := pb.NewZeroClient(pl.Get()) . . 478: . . 479: tablet = &pb.Tablet{GroupId: g.groupId(), Predicate: key} . 1.07MB 480: out, err := zc.ShouldServe(context.Background(), tablet) . . 481: if err != nil { . . 482: glog.Errorf("Error while ShouldServe grpc call %v", err) . . 483: return &emptyTablet, err . . 484: } This can be avoided. We can return nil instead of emptyTablet and save allocations here. Caller function always checks for error first before accessing tablet information. (cherry picked from commit 428f3bd)
- Loading branch information