From 0d039eb094054efd86012b6b8257f89b63910cb9 Mon Sep 17 00:00:00 2001 From: Brett Jones Date: Thu, 9 Jan 2020 13:22:22 -0600 Subject: [PATCH] address PR comments Signed-off-by: Brett Jones --- pkg/receive/handler.go | 23 ++-- pkg/receive/handler_test.go | 2 +- pkg/store/storepb/rpc.pb.go | 224 ++++++++++++++++++------------------ pkg/store/storepb/rpc.proto | 6 +- 4 files changed, 132 insertions(+), 123 deletions(-) diff --git a/pkg/receive/handler.go b/pkg/receive/handler.go index 641a052fa61..21de5f3f794 100644 --- a/pkg/receive/handler.go +++ b/pkg/receive/handler.go @@ -385,7 +385,7 @@ func (h *Handler) parallelizeRequests(ctx context.Context, tenant string, replic h.forwardRequestsTotal.WithLabelValues("success").Inc() }() - cl, err := h.peers.Get(ctx, endpoint) + cl, err := h.peers.get(ctx, endpoint) if err != nil { level.Error(h.logger).Log("msg", "failed to get peer connection to forward request", "err", err, "endpoint", endpoint) ec <- err @@ -396,6 +396,8 @@ func (h *Handler) parallelizeRequests(ctx context.Context, tenant string, replic span, ctx := tracing.StartSpan(ctx, "thanos_receive_forward") defer span.Finish() + // Actually make the request against the endpoint + // we determined should handle these time series. _, err = cl.RemoteWrite(ctx, &storepb.WriteRequest{ Timeseries: wreqs[endpoint].Timeseries, Tenant: tenant, @@ -516,7 +518,7 @@ func newPeerGroup(dialOpts ...grpc.DialOption) *peerGroup { return &peerGroup{ dialOpts: dialOpts, cache: map[string]storepb.WriteableStoreClient{}, - m: sync.Mutex{}, + m: sync.RWMutex{}, dialer: grpc.DialContext, } } @@ -524,21 +526,28 @@ func newPeerGroup(dialOpts ...grpc.DialOption) *peerGroup { type peerGroup struct { dialOpts []grpc.DialOption cache map[string]storepb.WriteableStoreClient - m sync.Mutex + m sync.RWMutex // dialer is used for testing. dialer func(ctx context.Context, target string, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error) } -func (p *peerGroup) Get(ctx context.Context, addr string) (storepb.WriteableStoreClient, error) { - p.m.Lock() - defer p.m.Unlock() - +func (p *peerGroup) get(ctx context.Context, addr string) (storepb.WriteableStoreClient, error) { + // use a RLock first to prevent blocking if we don't need to. + p.m.RLock() c, ok := p.cache[addr] + p.m.RUnlock() if ok { return c, nil } + p.m.Lock() + defer p.m.Unlock() + // Make sure that another caller hasn't created the connection since obtaining the write lock. + c, ok = p.cache[addr] + if ok { + return c, nil + } conn, err := p.dialer(ctx, addr, p.dialOpts...) if err != nil { return nil, errors.Wrap(err, "failed to dial peer") diff --git a/pkg/receive/handler_test.go b/pkg/receive/handler_test.go index dd5da5eb455..6f58b84cec0 100644 --- a/pkg/receive/handler_test.go +++ b/pkg/receive/handler_test.go @@ -146,7 +146,7 @@ func newHandlerHashring(appendables []*fakeAppendable, replicationFactor uint64) // This removes the network from the tests and creates a more consistent testing harness. peers := &peerGroup{ dialOpts: nil, - m: sync.Mutex{}, + m: sync.RWMutex{}, cache: map[string]storepb.WriteableStoreClient{}, dialer: func(context.Context, string, ...grpc.DialOption) (*grpc.ClientConn, error) { // dialer should never be called since we are creating fake clients with fake addresses diff --git a/pkg/store/storepb/rpc.pb.go b/pkg/store/storepb/rpc.pb.go index 7febe055d40..63f1ab4974e 100644 --- a/pkg/store/storepb/rpc.pb.go +++ b/pkg/store/storepb/rpc.pb.go @@ -174,9 +174,9 @@ func (m *WriteResponse) XXX_DiscardUnknown() { var xxx_messageInfo_WriteResponse proto.InternalMessageInfo type WriteRequest struct { - Tenant string `protobuf:"bytes,1,opt,name=tenant,proto3" json:"tenant,omitempty"` - Replica int64 `protobuf:"varint,2,opt,name=replica,proto3" json:"replica,omitempty"` - Timeseries []prompb.TimeSeries `protobuf:"bytes,3,rep,name=timeseries,proto3" json:"timeseries"` + Timeseries []prompb.TimeSeries `protobuf:"bytes,1,rep,name=timeseries,proto3" json:"timeseries"` + Tenant string `protobuf:"bytes,2,opt,name=tenant,proto3" json:"tenant,omitempty"` + Replica int64 `protobuf:"varint,3,opt,name=replica,proto3" json:"replica,omitempty"` } func (m *WriteRequest) Reset() { *m = WriteRequest{} } @@ -635,66 +635,66 @@ func init() { func init() { proto.RegisterFile("rpc.proto", fileDescriptor_77a6da22d6a3feb1) } var fileDescriptor_77a6da22d6a3feb1 = []byte{ - // 931 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcd, 0x6e, 0x22, 0x47, - 0x10, 0xa6, 0x19, 0x7e, 0x0b, 0x9b, 0xcc, 0xb6, 0xb1, 0x77, 0x4c, 0x24, 0x8c, 0x46, 0x8a, 0x84, - 0x9c, 0x08, 0x27, 0xac, 0x92, 0x28, 0xd1, 0x5e, 0x80, 0x65, 0xb5, 0x28, 0x6b, 0x9c, 0x34, 0xb0, - 0xe4, 0xe7, 0x40, 0x06, 0xdc, 0x19, 0x46, 0x0b, 0x33, 0x93, 0xe9, 0x26, 0xb6, 0x2f, 0x39, 0xe4, - 0x09, 0x72, 0xcd, 0x3b, 0xe4, 0x2d, 0x72, 0xf1, 0x71, 0x8f, 0xc9, 0x25, 0x4a, 0xec, 0x17, 0x89, - 0xba, 0xa7, 0x07, 0x18, 0xc7, 0xb6, 0xb4, 0xf2, 0xad, 0xeb, 0xfb, 0x8a, 0xfa, 0xf9, 0xaa, 0x7a, - 0x1a, 0xc8, 0x07, 0xfe, 0xb4, 0xee, 0x07, 0x1e, 0xf7, 0x70, 0x86, 0xcf, 0x2c, 0xd7, 0x63, 0xe5, - 0x02, 0xbf, 0xf0, 0x29, 0x0b, 0xc1, 0x72, 0xc9, 0xf6, 0x6c, 0x4f, 0x1e, 0x8f, 0xc4, 0x49, 0xa1, - 0x4f, 0x6c, 0x87, 0xcf, 0x96, 0x93, 0xfa, 0xd4, 0x5b, 0x1c, 0xf9, 0x81, 0xb7, 0xa0, 0x7c, 0x46, - 0x97, 0xec, 0xe6, 0xd1, 0x9f, 0x1c, 0x6d, 0x84, 0x32, 0xdf, 0x81, 0xed, 0x51, 0xe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 0x32, 0xea, 0x2e, 0x88, - 0xc9, 0x14, 0x1a, 0xc5, 0xd5, 0x2e, 0x49, 0xf4, 0x45, 0x82, 0x28, 0x1e, 0x97, 0x21, 0x7b, 0x66, - 0x05, 0xae, 0xe3, 0xda, 0x72, 0x52, 0xf9, 0x17, 0x09, 0x12, 0x01, 0xad, 0x1c, 0x64, 0x02, 0xca, - 0x96, 0x73, 0x6e, 0xfe, 0x8e, 0xe0, 0x91, 0x1c, 0x4f, 0xcf, 0x5a, 0xac, 0x37, 0xe0, 0x5e, 0xc5, - 0xd0, 0x03, 0x14, 0x4b, 0x3e, 0x4c, 0x31, 0xf3, 0x39, 0xe0, 0xcd, 0x6a, 0x95, 0x28, 0x25, 0x48, - 0xbb, 0x02, 0x90, 0xeb, 0x9e, 0x27, 0xa1, 0x81, 0xcb, 0x90, 0x53, 0xfd, 0x32, 0x23, 0x29, 0x89, - 0x95, 0x6d, 0xfe, 0x81, 0x54, 0xa0, 0x57, 0xd6, 0x7c, 0xb9, 0xee, 0xbb, 0x04, 0x69, 0x79, 0x2b, - 0xd4, 0xe7, 0x29, 0x34, 0xee, 0x57, 0x23, 0xf9, 0x00, 0x35, 0xb4, 0x07, 0xaa, 0xd1, 0x85, 0x9d, - 0x58, 0x13, 0x4a, 0x8e, 0x3d, 0xc8, 0xfc, 0x24, 0x11, 0xa5, 0x87, 0xb2, 0xee, 0x13, 0xe4, 0x90, - 0x40, 0x7e, 0xf5, 0x35, 0xc2, 0x05, 0xc8, 0x0e, 0x7b, 0x5f, 0xf4, 0x4e, 0x46, 0x3d, 0x3d, 0x81, - 0xf3, 0x90, 0xfe, 0x6a, 0xd8, 0x21, 0xdf, 0xe8, 0x08, 0xe7, 0x20, 0x45, 0x86, 0x2f, 0x3b, 0x7a, - 0x52, 0x78, 0xf4, 0xbb, 0xcf, 0x3a, 0xed, 0x26, 0xd1, 0x35, 0xe1, 0xd1, 0x1f, 0x9c, 0x90, 0x8e, - 0x9e, 0x12, 0x38, 0xe9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x41, 0xff, 0x5c, 0x55, 0xd0, 0xaf, 0xd7, - 0x95, 0xc4, 0x9b, 0xeb, 0x4a, 0xe2, 0xcf, 0xeb, 0x4a, 0xe2, 0xdb, 0xac, 0x7c, 0xbb, 0xfc, 0xc9, - 0x24, 0x23, 0xff, 0x05, 0x3c, 0xf9, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x65, 0xca, 0x36, 0x8b, 0x72, - 0x08, 0x00, 0x00, + // 934 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcb, 0x6e, 0x23, 0x45, + 0x14, 0x75, 0xbb, 0xfd, 0xbc, 0x4e, 0x4c, 0x4f, 0xc5, 0xc9, 0x74, 0x8c, 0xe4, 0x58, 0x2d, 0x21, + 0x59, 0x01, 0x39, 0xe0, 0x11, 0x20, 0xd0, 0x6c, 0x6c, 0x8f, 0x47, 0x63, 0x31, 0x71, 0xa0, 0x6c, + 0x8f, 0x79, 0x2c, 0x4c, 0xdb, 0x29, 0xda, 0xad, 0x71, 0x3f, 0xe8, 0x2a, 0x93, 0x64, 0xc3, 0x82, + 0x2f, 0x60, 0xcb, 0x3f, 0xf0, 0x17, 0x6c, 0xb2, 0x9c, 0x25, 0x6c, 0x10, 0x24, 0x3f, 0x82, 0xaa, + 0xba, 0xda, 0xee, 0x0e, 0x49, 0xa4, 0x51, 0x76, 0x75, 0xcf, 0xb9, 0xbe, 0x8f, 0x53, 0xf7, 0x76, + 0x19, 0x8a, 0x81, 0x3f, 0x6f, 0xfa, 0x81, 0xc7, 0x3c, 0x94, 0x63, 0x0b, 0xd3, 0xf5, 0x68, 0xb5, + 0xc4, 0x2e, 0x7c, 0x42, 0x43, 0xb0, 0x5a, 0xb1, 0x3c, 0xcb, 0x13, 0xc7, 0x23, 0x7e, 0x92, 0xe8, + 0x13, 0xcb, 0x66, 0x8b, 0xd5, 0xac, 0x39, 0xf7, 0x9c,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 0x8c, 0x08, 0x1c, 0xad, 0xdb, 0x8f, 0xbf, 0xce, 0xd5, 0xdd, 0x1b, 0xa8, 0x7c, 0xc4, 0x53, 0x9d, + 0xf7, 0x2e, 0xff, 0xad, 0xa5, 0x2e, 0xaf, 0x6a, 0xca, 0x9b, 0xab, 0x9a, 0xf2, 0xcf, 0x55, 0x4d, + 0xf9, 0xf5, 0xba, 0x96, 0x7a, 0x73, 0x5d, 0x4b, 0xfd, 0x79, 0x5d, 0x4b, 0x7d, 0x9b, 0x17, 0x6f, + 0x97, 0x3f, 0x9b, 0xe5, 0xc4, 0xbf, 0x80, 0x27, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x67, 0x56, + 0x73, 0x8e, 0x72, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1052,6 +1052,18 @@ func (m *WriteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Replica != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.Replica)) + i-- + dAtA[i] = 0x18 + } + if len(m.Tenant) > 0 { + i -= len(m.Tenant) + copy(dAtA[i:], m.Tenant) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Tenant))) + i-- + dAtA[i] = 0x12 + } if len(m.Timeseries) > 0 { for iNdEx := len(m.Timeseries) - 1; iNdEx >= 0; iNdEx-- { { @@ -1063,21 +1075,9 @@ func (m *WriteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0xa } } - if m.Replica != 0 { - i = encodeVarintRpc(dAtA, i, uint64(m.Replica)) - i-- - dAtA[i] = 0x10 - } - if len(m.Tenant) > 0 { - i -= len(m.Tenant) - copy(dAtA[i:], m.Tenant) - i = encodeVarintRpc(dAtA, i, uint64(len(m.Tenant))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } @@ -1560,6 +1560,12 @@ func (m *WriteRequest) Size() (n int) { } var l int _ = l + if len(m.Timeseries) > 0 { + for _, e := range m.Timeseries { + l = e.Size() + n += 1 + l + sovRpc(uint64(l)) + } + } l = len(m.Tenant) if l > 0 { n += 1 + l + sovRpc(uint64(l)) @@ -1567,12 +1573,6 @@ func (m *WriteRequest) Size() (n int) { if m.Replica != 0 { n += 1 + sovRpc(uint64(m.Replica)) } - if len(m.Timeseries) > 0 { - for _, e := range m.Timeseries { - l = e.Size() - n += 1 + l + sovRpc(uint64(l)) - } - } return n } @@ -1870,9 +1870,9 @@ func (m *WriteRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tenant", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Timeseries", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRpc @@ -1882,29 +1882,31 @@ func (m *WriteRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthRpc } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF } - m.Tenant = string(dAtA[iNdEx:postIndex]) + m.Timeseries = append(m.Timeseries, prompb.TimeSeries{}) + if err := m.Timeseries[len(m.Timeseries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Replica", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tenant", wireType) } - m.Replica = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRpc @@ -1914,16 +1916,29 @@ func (m *WriteRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Replica |= int64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthRpc + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tenant = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Timeseries", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Replica", wireType) } - var msglen int + m.Replica = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRpc @@ -1933,26 +1948,11 @@ func (m *WriteRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Replica |= int64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthRpc - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRpc - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Timeseries = append(m.Timeseries, prompb.TimeSeries{}) - if err := m.Timeseries[len(m.Timeseries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipRpc(dAtA[iNdEx:]) diff --git a/pkg/store/storepb/rpc.proto b/pkg/store/storepb/rpc.proto index 8cb13bc5545..ebd3bb20c73 100644 --- a/pkg/store/storepb/rpc.proto +++ b/pkg/store/storepb/rpc.proto @@ -50,9 +50,9 @@ message WriteResponse { } message WriteRequest { - string tenant = 1; - int64 replica = 2; - repeated prometheus.TimeSeries timeseries = 3 [(gogoproto.nullable) = false]; + repeated prometheus.TimeSeries timeseries = 1 [(gogoproto.nullable) = false]; + string tenant = 2; + int64 replica = 3; } message InfoRequest {