diff --git a/pkg/bloombuild/planner/planner_test.go b/pkg/bloombuild/planner/planner_test.go index 656a0b533c3c2..75d41027dd562 100644 --- a/pkg/bloombuild/planner/planner_test.go +++ b/pkg/bloombuild/planner/planner_test.go @@ -713,7 +713,10 @@ func (f *fakeBuilder) Send(req *protos.PlannerToBuilder) error { } func (f *fakeBuilder) Recv() (*protos.BuilderToPlanner, error) { - if len(f.tasks) == 0 { + f.mx.Lock() + tasksLen := len(f.tasks) + f.mx.Unlock() + if tasksLen == 0 { // First call to Recv answers with builderID return &protos.BuilderToPlanner{ BuilderID: f.id,