diff --git a/pkg/kv/kvclient/kvcoord/dist_sender.go b/pkg/kv/kvclient/kvcoord/dist_sender.go index 9ce888da9e52..1b02bf571174 100644 --- a/pkg/kv/kvclient/kvcoord/dist_sender.go +++ b/pkg/kv/kvclient/kvcoord/dist_sender.go @@ -462,6 +462,11 @@ func (ds *DistSender) FirstRange() (*roachpb.RangeDescriptor, error) { return ds.firstRangeProvider.GetFirstRangeDescriptor() } +// NodeDialer returns a Dialer. +func (ds *DistSender) NodeDialer() *nodedialer.Dialer { + return ds.nodeDialer +} + // getNodeID attempts to return the local node ID. It returns 0 if the DistSender // does not have access to the Gossip network. func (ds *DistSender) getNodeID() roachpb.NodeID { diff --git a/pkg/kv/kvserver/api.pb.go b/pkg/kv/kvserver/api.pb.go index c784e0b829f1..1fe43fbca9c0 100644 --- a/pkg/kv/kvserver/api.pb.go +++ b/pkg/kv/kvserver/api.pb.go @@ -35,7 +35,7 @@ func (m *StoreRequestHeader) Reset() { *m = StoreRequestHeader{} } func (m *StoreRequestHeader) String() string { return proto.CompactTextString(m) } func (*StoreRequestHeader) ProtoMessage() {} func (*StoreRequestHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_api_cef23d12e9246cb3, []int{0} + return fileDescriptor_api_4b6691848ee10d89, []int{0} } func (m *StoreRequestHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -74,7 +74,7 @@ func (m *CollectChecksumRequest) Reset() { *m = CollectChecksumRequest{} func (m *CollectChecksumRequest) String() string { return proto.CompactTextString(m) } func (*CollectChecksumRequest) ProtoMessage() {} func (*CollectChecksumRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_cef23d12e9246cb3, []int{1} + return fileDescriptor_api_4b6691848ee10d89, []int{1} } func (m *CollectChecksumRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -119,7 +119,7 @@ func (m *CollectChecksumResponse) Reset() { *m = CollectChecksumResponse func (m *CollectChecksumResponse) String() string { return proto.CompactTextString(m) } func (*CollectChecksumResponse) ProtoMessage() {} func (*CollectChecksumResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_api_cef23d12e9246cb3, []int{2} + return fileDescriptor_api_4b6691848ee10d89, []int{2} } func (m *CollectChecksumResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -156,7 +156,7 @@ func (m *WaitForApplicationRequest) Reset() { *m = WaitForApplicationReq func (m *WaitForApplicationRequest) String() string { return proto.CompactTextString(m) } func (*WaitForApplicationRequest) ProtoMessage() {} func (*WaitForApplicationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_cef23d12e9246cb3, []int{3} + return fileDescriptor_api_4b6691848ee10d89, []int{3} } func (m *WaitForApplicationRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -188,7 +188,7 @@ func (m *WaitForApplicationResponse) Reset() { *m = WaitForApplicationRe func (m *WaitForApplicationResponse) String() string { return proto.CompactTextString(m) } func (*WaitForApplicationResponse) ProtoMessage() {} func (*WaitForApplicationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_api_cef23d12e9246cb3, []int{4} + return fileDescriptor_api_4b6691848ee10d89, []int{4} } func (m *WaitForApplicationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -222,7 +222,7 @@ func (m *WaitForReplicaInitRequest) Reset() { *m = WaitForReplicaInitReq func (m *WaitForReplicaInitRequest) String() string { return proto.CompactTextString(m) } func (*WaitForReplicaInitRequest) ProtoMessage() {} func (*WaitForReplicaInitRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_cef23d12e9246cb3, []int{5} + return fileDescriptor_api_4b6691848ee10d89, []int{5} } func (m *WaitForReplicaInitRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -254,7 +254,7 @@ func (m *WaitForReplicaInitResponse) Reset() { *m = WaitForReplicaInitRe func (m *WaitForReplicaInitResponse) String() string { return proto.CompactTextString(m) } func (*WaitForReplicaInitResponse) ProtoMessage() {} func (*WaitForReplicaInitResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_api_cef23d12e9246cb3, []int{6} + return fileDescriptor_api_4b6691848ee10d89, []int{6} } func (m *WaitForReplicaInitResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -279,6 +279,74 @@ func (m *WaitForReplicaInitResponse) XXX_DiscardUnknown() { var xxx_messageInfo_WaitForReplicaInitResponse proto.InternalMessageInfo +// CompactEngineSpanRequest does a synchronous compaction of the provided +// engine span in the given store. +type CompactEngineSpanRequest struct { + StoreRequestHeader `protobuf:"bytes,1,opt,name=header,proto3,embedded=header" json:"header"` + Span roachpb.Span `protobuf:"bytes,2,opt,name=span,proto3" json:"span"` +} + +func (m *CompactEngineSpanRequest) Reset() { *m = CompactEngineSpanRequest{} } +func (m *CompactEngineSpanRequest) String() string { return proto.CompactTextString(m) } +func (*CompactEngineSpanRequest) ProtoMessage() {} +func (*CompactEngineSpanRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_api_4b6691848ee10d89, []int{7} +} +func (m *CompactEngineSpanRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompactEngineSpanRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (dst *CompactEngineSpanRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompactEngineSpanRequest.Merge(dst, src) +} +func (m *CompactEngineSpanRequest) XXX_Size() int { + return m.Size() +} +func (m *CompactEngineSpanRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CompactEngineSpanRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CompactEngineSpanRequest proto.InternalMessageInfo + +type CompactEngineSpanResponse struct { +} + +func (m *CompactEngineSpanResponse) Reset() { *m = CompactEngineSpanResponse{} } +func (m *CompactEngineSpanResponse) String() string { return proto.CompactTextString(m) } +func (*CompactEngineSpanResponse) ProtoMessage() {} +func (*CompactEngineSpanResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_api_4b6691848ee10d89, []int{8} +} +func (m *CompactEngineSpanResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompactEngineSpanResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (dst *CompactEngineSpanResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompactEngineSpanResponse.Merge(dst, src) +} +func (m *CompactEngineSpanResponse) XXX_Size() int { + return m.Size() +} +func (m *CompactEngineSpanResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CompactEngineSpanResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CompactEngineSpanResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*StoreRequestHeader)(nil), "cockroach.kv.kvserver.StoreRequestHeader") proto.RegisterType((*CollectChecksumRequest)(nil), "cockroach.kv.kvserver.CollectChecksumRequest") @@ -287,6 +355,8 @@ func init() { proto.RegisterType((*WaitForApplicationResponse)(nil), "cockroach.kv.kvserver.WaitForApplicationResponse") proto.RegisterType((*WaitForReplicaInitRequest)(nil), "cockroach.kv.kvserver.WaitForReplicaInitRequest") proto.RegisterType((*WaitForReplicaInitResponse)(nil), "cockroach.kv.kvserver.WaitForReplicaInitResponse") + proto.RegisterType((*CompactEngineSpanRequest)(nil), "cockroach.kv.kvserver.CompactEngineSpanRequest") + proto.RegisterType((*CompactEngineSpanResponse)(nil), "cockroach.kv.kvserver.CompactEngineSpanResponse") } func (m *StoreRequestHeader) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -514,6 +584,58 @@ func (m *WaitForReplicaInitResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *CompactEngineSpanRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompactEngineSpanRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintApi(dAtA, i, uint64(m.StoreRequestHeader.Size())) + n8, err := m.StoreRequestHeader.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n8 + dAtA[i] = 0x12 + i++ + i = encodeVarintApi(dAtA, i, uint64(m.Span.Size())) + n9, err := m.Span.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n9 + return i, nil +} + +func (m *CompactEngineSpanResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompactEngineSpanResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + return i, nil +} + func encodeVarintApi(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -628,6 +750,28 @@ func (m *WaitForReplicaInitResponse) Size() (n int) { return n } +func (m *CompactEngineSpanRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.StoreRequestHeader.Size() + n += 1 + l + sovApi(uint64(l)) + l = m.Span.Size() + n += 1 + l + sovApi(uint64(l)) + return n +} + +func (m *CompactEngineSpanResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovApi(x uint64) (n int) { for { n++ @@ -1380,6 +1524,166 @@ func (m *WaitForReplicaInitResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *CompactEngineSpanRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CompactEngineSpanRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompactEngineSpanRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StoreRequestHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.StoreRequestHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Span", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Span.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompactEngineSpanResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CompactEngineSpanResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompactEngineSpanResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipApi(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 @@ -1485,46 +1789,49 @@ var ( ErrIntOverflowApi = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("kv/kvserver/api.proto", fileDescriptor_api_cef23d12e9246cb3) } - -var fileDescriptor_api_cef23d12e9246cb3 = []byte{ - // 597 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x94, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0x9b, 0xfd, 0x69, 0x8b, 0xc3, 0x29, 0x62, 0x30, 0xba, 0x29, 0x99, 0x82, 0x90, 0xc6, - 0x0e, 0x89, 0xd4, 0x71, 0x47, 0x6b, 0xab, 0x89, 0x08, 0xc1, 0xc1, 0xd3, 0x40, 0xda, 0x81, 0xc9, - 0x8d, 0xbd, 0xd4, 0x24, 0x8b, 0x83, 0xed, 0x54, 0x7c, 0x05, 0x6e, 0x7c, 0xac, 0x5e, 0x90, 0x7a, - 0x9c, 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0x82, 0x6d, 0x4c, 0x22, - 0x89, 0x14, 0xba, 0xde, 0x3d, 0x5a, 0x52, 0x57, 0x2f, 0xdd, 0xa9, 0x5f, 0xba, 0xf3, 0xf6, 0x7d, - 0xbf, 0x7f, 0x26, 0x91, 0x14, 0x83, 0x42, 0xd1, 0xdb, 0x2a, 0x62, 0x82, 0xa5, 0xdc, 0xf0, 0xc0, - 0x83, 0x84, 0x70, 0x41, 0x85, 0x24, 0x58, 0xd1, 0xe9, 0xdd, 0xe7, 0x77, 0xf2, 0xaa, 0x6c, 0x16, - 0x6a, 0xfb, 0xb7, 0x06, 0x9e, 0x7e, 0x40, 0x54, 0x9e, 0x32, 0x7e, 0x92, 0x24, 0x11, 0xf5, 0x91, - 0xa4, 0x2c, 0xbe, 0x97, 0xcf, 0xcb, 0x02, 0x7a, 0x44, 0x90, 0x20, 0x97, 0x34, 0xc6, 0xe4, 0x8b, - 0xca, 0x78, 0x0b, 0x02, 0x55, 0xf2, 0x8a, 0x8a, 0xbd, 0x0f, 0x3a, 0xeb, 0x50, 0xcb, 0x9b, 0xb7, - 0x27, 0x8b, 0x24, 0x20, 0x51, 0x6d, 0x2f, 0xa6, 0xf2, 0x3e, 0x26, 0xb1, 0x04, 0xba, 0x42, 0x52, - 0x82, 0xf6, 0x8e, 0x26, 0xbf, 0xcc, 0xc6, 0x24, 0x37, 0xb5, 0x69, 0x6e, 0x6a, 0x37, 0xb9, 0xa9, - 0xfd, 0xcc, 0x4d, 0xed, 0xdb, 0xcc, 0x6c, 0x4c, 0x67, 0x66, 0xe3, 0x66, 0x66, 0x36, 0x2e, 0xda, - 0x35, 0xce, 0xb0, 0xa9, 0x7e, 0xaa, 0xc7, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe4, 0xde, 0x21, - 0x8e, 0xf2, 0x05, 0x00, 0x00, +func init() { proto.RegisterFile("kv/kvserver/api.proto", fileDescriptor_api_4b6691848ee10d89) } + +var fileDescriptor_api_4b6691848ee10d89 = []byte{ + // 649 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x55, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0x8e, 0xdb, 0x34, 0x09, 0x17, 0x26, 0x8b, 0xd2, 0x36, 0xad, 0xec, 0xca, 0x08, 0xa9, 0x74, + 0xb0, 0x45, 0xca, 0x8e, 0x9a, 0x84, 0x0a, 0x0b, 0xc1, 0xe0, 0xa8, 0x20, 0x75, 0xa0, 0xba, 0xf8, + 0xae, 0xce, 0x11, 0xc7, 0x77, 0xf8, 0x2e, 0x11, 0x7f, 0x81, 0x8d, 0x99, 0x5f, 0x94, 0x05, 0x29, + 0x63, 0xc5, 0x10, 0x81, 0x3b, 0xf1, 0x17, 0x98, 0xd0, 0x9d, 0xcf, 0x49, 0xa3, 0x66, 0x28, 0x48, + 0x0c, 0xdd, 0xce, 0xef, 0xbd, 0xef, 0xbb, 0xf7, 0x7d, 0xef, 0x9d, 0x0c, 0x36, 0x07, 0x63, 0x6f, + 0x30, 0xe6, 0x38, 0x1d, 0xe3, 0xd4, 0x83, 0x8c, 0xb8, 0x2c, 0xa5, 0x82, 0x9a, 0x9b, 0x21, 0x0d, + 0x07, 0x29, 0x85, 0x61, 0xdf, 0x1d, 0x8c, 0xdd, 0xa2, 0xa0, 0x61, 0xaa, 0x10, 0xeb, 0x79, 0x08, + 0x0a, 0x98, 0x97, 0x36, 0x76, 0x8b, 0x18, 0x49, 0x04, 0x4e, 0x13, 0x18, 0x9f, 0xa7, 0xf0, 0x42, + 0x14, 0x49, 0x2e, 0x68, 0x0a, 0x23, 0xec, 0xe1, 0x24, 0x22, 0x09, 0x66, 0x3d, 0x6f, 0x38, 0x0e, + 0x43, 0x9d, 0xdc, 0x5b, 0x99, 0x3c, 0xd2, 0xd9, 0x07, 0x11, 0x8d, 0xa8, 0x3a, 0x7a, 0xf2, 0x94, + 0x47, 0x9d, 0xa9, 0x01, 0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42, 0xc4, 0x5d, 0x74, 0xe2, 0x9a, 0xd0, 0x25, 0x25, 0x5a, 0xe8, 0x57, 0x03, 0x6c, 0xb7, 0xe9, + 0x90, 0xc1, 0x50, 0xbc, 0x50, 0x1b, 0xd2, 0x65, 0xf0, 0xff, 0x4c, 0xfc, 0x29, 0x28, 0x73, 0x06, + 0x13, 0xfd, 0x58, 0xb6, 0x56, 0x3c, 0x16, 0x79, 0xb5, 0x5e, 0x4a, 0x55, 0xea, 0xec, 0x82, 0x9d, + 0x15, 0xbd, 0xe5, 0x9d, 0xb7, 0x0e, 0x27, 0x3f, 0xad, 0xd2, 0x24, 0xb3, 0x8c, 0x69, 0x66, 0x19, + 0x97, 0x99, 0x65, 0xfc, 0xc8, 0x2c, 0xe3, 0xcb, 0x95, 0x55, 0x9a, 0x5e, 0x59, 0xa5, 0xcb, 0x2b, + 0xab, 0x74, 0x56, 0x2b, 0x1a, 0xec, 0x55, 0xd4, 0xef, 0xe0, 0xe8, 0x4f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x38, 0x72, 0x88, 0x62, 0xc0, 0x06, 0x00, 0x00, } diff --git a/pkg/kv/kvserver/api.proto b/pkg/kv/kvserver/api.proto index ba7dd101ecd5..c2ba71565d7e 100644 --- a/pkg/kv/kvserver/api.proto +++ b/pkg/kv/kvserver/api.proto @@ -12,6 +12,7 @@ syntax = "proto3"; package cockroach.kv.kvserver; option go_package = "kvserver"; +import "roachpb/data.proto"; import "roachpb/internal_raft.proto"; import "storage/enginepb/mvcc.proto"; import "storage/enginepb/mvcc3.proto"; @@ -75,3 +76,12 @@ message WaitForReplicaInitRequest { message WaitForReplicaInitResponse { } +// CompactEngineSpanRequest does a synchronous compaction of the provided +// engine span in the given store. +message CompactEngineSpanRequest { + StoreRequestHeader header = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true]; + roachpb.Span span = 2 [(gogoproto.nullable) = false]; +} + +message CompactEngineSpanResponse { +} diff --git a/pkg/kv/kvserver/client_test.go b/pkg/kv/kvserver/client_test.go index b2a1c8cd9849..4cb5b186b93e 100644 --- a/pkg/kv/kvserver/client_test.go +++ b/pkg/kv/kvserver/client_test.go @@ -971,8 +971,9 @@ func (m *multiTestContext) addStore(idx int) { sender := kvserver.NewStores(ambient, clock) sender.AddStore(store) - perReplicaServer := kvserver.MakeServer(&roachpb.NodeDescriptor{NodeID: nodeID}, sender) - kvserver.RegisterPerReplicaServer(grpcServer, perReplicaServer) + server := kvserver.MakeServer(&roachpb.NodeDescriptor{NodeID: nodeID}, sender) + kvserver.RegisterPerReplicaServer(grpcServer, server) + kvserver.RegisterPerStoreServer(grpcServer, server) ln, err := netutil.ListenAndServeGRPC(m.transportStopper, grpcServer, util.TestAddr) if err != nil { diff --git a/pkg/kv/kvserver/storage_services.pb.go b/pkg/kv/kvserver/storage_services.pb.go index 4257637accc5..1f4ff6fa8e47 100644 --- a/pkg/kv/kvserver/storage_services.pb.go +++ b/pkg/kv/kvserver/storage_services.pb.go @@ -322,32 +322,98 @@ var _PerReplica_serviceDesc = grpc.ServiceDesc{ Metadata: "kv/kvserver/storage_services.proto", } +// PerStoreClient is the client API for PerStore service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type PerStoreClient interface { + CompactEngineSpan(ctx context.Context, in *CompactEngineSpanRequest, opts ...grpc.CallOption) (*CompactEngineSpanResponse, error) +} + +type perStoreClient struct { + cc *grpc.ClientConn +} + +func NewPerStoreClient(cc *grpc.ClientConn) PerStoreClient { + return &perStoreClient{cc} +} + +func (c *perStoreClient) CompactEngineSpan(ctx context.Context, in *CompactEngineSpanRequest, opts ...grpc.CallOption) (*CompactEngineSpanResponse, error) { + out := new(CompactEngineSpanResponse) + err := c.cc.Invoke(ctx, "/cockroach.storage.PerStore/CompactEngineSpan", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PerStoreServer is the server API for PerStore service. +type PerStoreServer interface { + CompactEngineSpan(context.Context, *CompactEngineSpanRequest) (*CompactEngineSpanResponse, error) +} + +func RegisterPerStoreServer(s *grpc.Server, srv PerStoreServer) { + s.RegisterService(&_PerStore_serviceDesc, srv) +} + +func _PerStore_CompactEngineSpan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CompactEngineSpanRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PerStoreServer).CompactEngineSpan(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cockroach.storage.PerStore/CompactEngineSpan", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PerStoreServer).CompactEngineSpan(ctx, req.(*CompactEngineSpanRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _PerStore_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cockroach.storage.PerStore", + HandlerType: (*PerStoreServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CompactEngineSpan", + Handler: _PerStore_CompactEngineSpan_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kv/kvserver/storage_services.proto", +} + func init() { - proto.RegisterFile("kv/kvserver/storage_services.proto", fileDescriptor_storage_services_26b72250ee725fca) -} - -var fileDescriptor_storage_services_26b72250ee725fca = []byte{ - // 339 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xbf, 0x4e, 0xeb, 0x30, - 0x14, 0x87, 0xe3, 0x3b, 0x5c, 0x81, 0x85, 0x04, 0x58, 0xc0, 0x90, 0xc1, 0x43, 0x07, 0x40, 0x95, - 0x70, 0x4b, 0x79, 0x02, 0x5a, 0x09, 0x89, 0xa1, 0x12, 0x2a, 0x03, 0x12, 0x0b, 0x32, 0xd6, 0x69, - 0x62, 0x25, 0xc4, 0xc1, 0x76, 0xb3, 0xf0, 0x12, 0x3c, 0x56, 0xc7, 0x8e, 0x1d, 0x21, 0x5d, 0x78, - 0x06, 0x26, 0x94, 0x34, 0x16, 0xe1, 0x4f, 0xd5, 0x30, 0xe5, 0xe4, 0xf8, 0x3b, 0xbf, 0xef, 0xc8, - 0x32, 0x6e, 0x45, 0x59, 0x27, 0xca, 0x0c, 0xe8, 0x0c, 0x74, 0xc7, 0x58, 0xa5, 0x79, 0x00, 0x77, - 0xc5, 0xaf, 0x14, 0x60, 0x58, 0xaa, 0x95, 0x55, 0x64, 0x57, 0x28, 0x11, 0x69, 0xc5, 0x45, 0xc8, - 0x2a, 0xc2, 0x3f, 0xa8, 0x8f, 0x69, 0x3e, 0xb6, 0x4b, 0xd4, 0xdf, 0xaf, 0xf7, 0x79, 0x2a, 0xab, - 0xf6, 0x5e, 0xa0, 0x02, 0x55, 0x96, 0x9d, 0xa2, 0x5a, 0x76, 0x7b, 0x6f, 0x08, 0x6f, 0x0e, 0x27, - 0xb1, 0x95, 0x23, 0x3e, 0xb6, 0xc4, 0xe2, 0x9d, 0xe2, 0x3b, 0x04, 0x63, 0x78, 0x00, 0x7d, 0x6e, - 0x45, 0x48, 0x18, 0xfb, 0x54, 0x47, 0x19, 0x73, 0xc9, 0xac, 0x06, 0x8e, 0xe0, 0x71, 0x02, 0xc6, - 0x96, 0xbc, 0xdf, 0x6e, 0xc2, 0x9b, 0x54, 0x25, 0x06, 0x5a, 0xde, 0x31, 0xea, 0x22, 0x02, 0x78, - 0xab, 0x38, 0xbc, 0x4e, 0x78, 0x6a, 0x42, 0x65, 0xc9, 0xe1, 0x8a, 0x04, 0x07, 0x54, 0x3a, 0xff, - 0x68, 0x2d, 0x57, 0xd7, 0xf4, 0xde, 0xff, 0x61, 0x7c, 0x05, 0x7a, 0x04, 0x69, 0x2c, 0x05, 0x27, - 0x1a, 0x6f, 0x0f, 0x54, 0x1c, 0x83, 0xb0, 0x83, 0x10, 0x44, 0x64, 0x26, 0x0f, 0xe4, 0x64, 0x45, - 0xe0, 0x37, 0xce, 0xf9, 0x59, 0x53, 0xdc, 0xad, 0x41, 0x9e, 0x30, 0xb9, 0xe1, 0xd2, 0x5e, 0x28, - 0x7d, 0x9e, 0x96, 0x5b, 0x58, 0xa9, 0x12, 0xd2, 0x5d, 0x91, 0xf3, 0x13, 0x75, 0xe6, 0xd3, 0x3f, - 0x4c, 0xfc, 0x22, 0xaf, 0xae, 0xe0, 0x32, 0x91, 0x76, 0x9d, 0xbc, 0x86, 0x36, 0x94, 0x7f, 0x99, - 0x70, 0xf2, 0x7e, 0x7b, 0xfa, 0x4a, 0xbd, 0x69, 0x4e, 0xd1, 0x2c, 0xa7, 0x68, 0x9e, 0x53, 0xf4, - 0x92, 0x53, 0xf4, 0xbc, 0xa0, 0xde, 0x6c, 0x41, 0xbd, 0xf9, 0x82, 0x7a, 0xb7, 0x1b, 0x2e, 0xe8, - 0xfe, 0x7f, 0xf9, 0x34, 0xcf, 0x3e, 0x02, 0x00, 0x00, 0xff, 0xff, 0x83, 0x9e, 0xc7, 0x08, 0x18, - 0x03, 0x00, 0x00, + proto.RegisterFile("kv/kvserver/storage_services.proto", fileDescriptor_storage_services_be9c06f8924f6568) +} + +var fileDescriptor_storage_services_be9c06f8924f6568 = []byte{ + // 382 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xb1, 0x8e, 0xd3, 0x30, + 0x18, 0xc7, 0x63, 0x06, 0x54, 0x2c, 0x24, 0xa8, 0x05, 0x0c, 0x19, 0x3c, 0x74, 0x00, 0x54, 0x89, + 0xa4, 0x94, 0x27, 0xa0, 0x15, 0x48, 0x0c, 0x95, 0xaa, 0x76, 0x40, 0x62, 0x41, 0xc6, 0xfa, 0x9a, + 0x58, 0x49, 0x63, 0x63, 0xbb, 0x11, 0x12, 0x2b, 0x0f, 0xc0, 0x63, 0x75, 0xec, 0xd8, 0xf1, 0x2e, + 0x5d, 0xee, 0x19, 0x6e, 0x3a,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e8, 0x8a, 0xbb, 0x1a, 0xe4, 0x2f, + 0x26, 0xdf, 0x99, 0xb0, 0x5f, 0xa5, 0xfe, 0xac, 0xaa, 0x16, 0x56, 0xc8, 0x8c, 0x8c, 0x5a, 0x72, + 0xee, 0xa3, 0xce, 0xfc, 0xf1, 0x11, 0x1b, 0x0f, 0xc8, 0xeb, 0x2b, 0xf8, 0x96, 0x09, 0x7b, 0x4e, + 0xde, 0x40, 0x3b, 0xca, 0xef, 0x6c, 0x38, 0xf9, 0xf8, 0x1f, 0xc2, 0xbd, 0x39, 0xe8, 0xa5, 0x95, + 0x1a, 0xc8, 0x1f, 0xdc, 0x9f, 0xca, 0xb5, 0x62, 0xdc, 0x7e, 0xc9, 0x22, 0x91, 0xc1, 0x52, 0xb1, + 0x8c, 0x84, 0xad, 0xb7, 0x79, 0x42, 0xba, 0x1e, 0xa3, 0xee, 0x0b, 0xae, 0xc6, 0x64, 0xb8, 0xbd, + 0xa4, 0xde, 0xb6, 0xa0, 0x68, 0x57, 0x50, 0xb4, 0x2f, 0x28, 0xba, 0x28, 0x28, 0xfa, 0x7f, 0xa0, + 0xde, 0xee, 0x40, 0xbd, 0xfd, 0x81, 0x7a, 0x3f, 0x7a, 0x2e, 0xe7, 0xd7, 0xd3, 0xea, 0x0f, 0xf9, + 0x74, 0x13, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x5b, 0x61, 0x28, 0x9f, 0x03, 0x00, 0x00, } diff --git a/pkg/kv/kvserver/storage_services.proto b/pkg/kv/kvserver/storage_services.proto index 6143e0bc3afc..0a7ccb86de26 100644 --- a/pkg/kv/kvserver/storage_services.proto +++ b/pkg/kv/kvserver/storage_services.proto @@ -26,3 +26,7 @@ service PerReplica { rpc WaitForApplication(cockroach.kv.kvserver.WaitForApplicationRequest) returns (cockroach.kv.kvserver.WaitForApplicationResponse) {} rpc WaitForReplicaInit(cockroach.kv.kvserver.WaitForReplicaInitRequest) returns (cockroach.kv.kvserver.WaitForReplicaInitResponse) {} } + +service PerStore { + rpc CompactEngineSpan(cockroach.kv.kvserver.CompactEngineSpanRequest) returns (cockroach.kv.kvserver.CompactEngineSpanResponse) {} +} diff --git a/pkg/kv/kvserver/stores_server.go b/pkg/kv/kvserver/stores_server.go index 4960ff4b051d..d14c89dbbfe5 100644 --- a/pkg/kv/kvserver/stores_server.go +++ b/pkg/kv/kvserver/stores_server.go @@ -28,6 +28,7 @@ type Server struct { } var _ PerReplicaServer = Server{} +var _ PerStoreServer = Server{} // MakeServer returns a new instance of Server. func MakeServer(descriptor *roachpb.NodeDescriptor, stores *Stores) Server { @@ -152,3 +153,16 @@ func (is Server) WaitForReplicaInit( }) return resp, err } + +// CompactEngineSpan implements PerStoreServer. It blocks until the compaction +// is done, so it can be a long-lived RPC. +func (is Server) CompactEngineSpan( + ctx context.Context, req *CompactEngineSpanRequest, +) (*CompactEngineSpanResponse, error) { + resp := &CompactEngineSpanResponse{} + err := is.execStoreCommand(ctx, req.StoreRequestHeader, + func(ctx context.Context, s *Store) error { + return s.Engine().CompactRange(req.Span.Key, req.Span.EndKey, true /* forceBottommost */) + }) + return resp, err +} diff --git a/pkg/server/server.go b/pkg/server/server.go index 3281c0fd7cd0..f3a67877d0f3 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -554,6 +554,7 @@ func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error) { lateBoundNode = node roachpb.RegisterInternalServer(grpcServer.Server, node) kvserver.RegisterPerReplicaServer(grpcServer.Server, node.perReplicaServer) + kvserver.RegisterPerStoreServer(grpcServer.Server, node.perReplicaServer) node.storeCfg.ClosedTimestamp.RegisterClosedTimestampServer(grpcServer.Server) replicationReporter := reports.NewReporter( db, node.stores, storePool, st, nodeLiveness, internalExecutor) diff --git a/pkg/sql/BUILD.bazel b/pkg/sql/BUILD.bazel index 74e9745c2222..2f9b4b9e70ce 100644 --- a/pkg/sql/BUILD.bazel +++ b/pkg/sql/BUILD.bazel @@ -239,6 +239,7 @@ go_library( "//pkg/kv", "//pkg/kv/kvclient/kvcoord", "//pkg/kv/kvclient/rangecache", + "//pkg/kv/kvserver", "//pkg/kv/kvserver/liveness/livenesspb", "//pkg/kv/kvserver/protectedts", "//pkg/roachpb", diff --git a/pkg/sql/faketreeeval/evalctx.go b/pkg/sql/faketreeeval/evalctx.go index 4042c6c56605..3edacc21ab6d 100644 --- a/pkg/sql/faketreeeval/evalctx.go +++ b/pkg/sql/faketreeeval/evalctx.go @@ -115,6 +115,13 @@ func (ep *DummyEvalPlanner) UnsafeDeleteNamespaceEntry( return errors.WithStack(errEvalPlanner) } +// CompactEngineSpan is part of the EvalPlanner interface. +func (ep *DummyEvalPlanner) CompactEngineSpan( + ctx context.Context, nodeID int32, storeID int32, startKey []byte, endKey []byte, +) error { + return errors.WithStack(errEvalPlanner) +} + var _ tree.EvalPlanner = &DummyEvalPlanner{} var errEvalPlanner = pgerror.New(pgcode.ScalarOperationCannotRunWithoutFullSessionContext, diff --git a/pkg/sql/logictest/testdata/logic_test/crdb_internal b/pkg/sql/logictest/testdata/logic_test/crdb_internal index 357e1129968c..83d7fb2db3fc 100644 --- a/pkg/sql/logictest/testdata/logic_test/crdb_internal +++ b/pkg/sql/logictest/testdata/logic_test/crdb_internal @@ -635,6 +635,32 @@ SELECT FROM table41834; +# Compact a range at this node, store. +query II colnames +SELECT node_id, store_id FROM crdb_internal.kv_store_status ORDER BY (node_id, store_id) LIMIT 1 +---- +node_id store_id +1 1 + +# Do the compaction. +query B colnames +SELECT crdb_internal.compact_engine_span(1, 1, start_key, end_key) +FROM crdb_internal.ranges_no_leases WHERE table_name = 'foo' LIMIT 1 +---- +crdb_internal.compact_engine_span +true + +# Failed compaction due to unknown node. +query error could not dial node ID 153 +SELECT crdb_internal.compact_engine_span(153, 1, decode('c08989', 'hex'), decode('c0898a', 'hex')) + +# Failed compaction due to unknown store. +query error store 23 was not found +SELECT crdb_internal.compact_engine_span(1, 23, decode('c08989', 'hex'), decode('c0898a', 'hex')) + +# Failed compaction due to invalid range. +query error start /Table/56/1/2 is not less than end /Table/56/1/1 +SELECT crdb_internal.compact_engine_span(1, 1, decode('c0898a', 'hex'), decode('c08989', 'hex')) subtest builtin_is_admin diff --git a/pkg/sql/planner.go b/pkg/sql/planner.go index e2e6431d18a7..93fe98b6f22c 100644 --- a/pkg/sql/planner.go +++ b/pkg/sql/planner.go @@ -17,6 +17,9 @@ import ( "github.com/cockroachdb/cockroach/pkg/jobs" "github.com/cockroachdb/cockroach/pkg/kv" + "github.com/cockroachdb/cockroach/pkg/kv/kvserver" + "github.com/cockroachdb/cockroach/pkg/roachpb" + "github.com/cockroachdb/cockroach/pkg/rpc" "github.com/cockroachdb/cockroach/pkg/security" "github.com/cockroachdb/cockroach/pkg/server/serverpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog" @@ -37,6 +40,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/util/cancelchecker" "github.com/cockroachdb/cockroach/pkg/util/envutil" + "github.com/cockroachdb/cockroach/pkg/util/errorutil" "github.com/cockroachdb/cockroach/pkg/util/hlc" "github.com/cockroachdb/cockroach/pkg/util/mon" "github.com/cockroachdb/errors" @@ -714,3 +718,31 @@ type txnModesSetter interface { // asOfTs, if not empty, is the evaluation of modes.AsOf. setTransactionModes(modes tree.TransactionModes, asOfTs hlc.Timestamp) error } + +// CompactEngineSpan is part of the EvalPlanner interface. +func (p *planner) CompactEngineSpan( + ctx context.Context, nodeID int32, storeID int32, startKey []byte, endKey []byte, +) error { + if !p.ExecCfg().Codec.ForSystemTenant() { + return errorutil.UnsupportedWithMultiTenancy(errorutil.FeatureNotAvailableToNonSystemTenantsIssue) + } + conn, err := p.ExecCfg().DistSender.NodeDialer().Dial(ctx, roachpb.NodeID(nodeID), rpc.DefaultClass) + if err != nil { + return errors.Wrapf(err, "could not dial node ID %d", nodeID) + } + start := roachpb.Key(startKey) + end := roachpb.Key(endKey) + if start.Compare(end) >= 0 { + return errors.Errorf("start %s is not less than end %s", start, end) + } + client := kvserver.NewPerStoreClient(conn) + req := &kvserver.CompactEngineSpanRequest{ + StoreRequestHeader: kvserver.StoreRequestHeader{ + NodeID: roachpb.NodeID(nodeID), + StoreID: roachpb.StoreID(storeID), + }, + Span: roachpb.Span{Key: start, EndKey: end}, + } + _, err = client.CompactEngineSpan(ctx, req) + return err +} diff --git a/pkg/sql/sem/builtins/builtins.go b/pkg/sql/sem/builtins/builtins.go index 6cd2ce2510d0..08d97799ab97 100644 --- a/pkg/sql/sem/builtins/builtins.go +++ b/pkg/sql/sem/builtins/builtins.go @@ -4601,6 +4601,43 @@ may increase either contention or retry errors, or both.`, }, ), + "crdb_internal.compact_engine_span": makeBuiltin( + tree.FunctionProperties{ + Category: categorySystemRepair, + DistsqlBlocklist: true, + Undocumented: true, + }, + tree.Overload{ + Types: tree.ArgTypes{ + {"node_id", types.Int}, + {"store_id", types.Int}, + {"start_key", types.Bytes}, + {"end_key", types.Bytes}, + }, + ReturnType: tree.FixedReturnType(types.Bool), + Fn: func(ctx *tree.EvalContext, args tree.Datums) (tree.Datum, error) { + nodeID := int32(tree.MustBeDInt(args[0])) + storeID := int32(tree.MustBeDInt(args[1])) + startKey := []byte(tree.MustBeDBytes(args[2])) + endKey := []byte(tree.MustBeDBytes(args[3])) + if err := ctx.Planner.CompactEngineSpan( + ctx.Context, nodeID, storeID, startKey, endKey); err != nil { + return nil, err + } + return tree.DBoolTrue, nil + }, + Info: "This function is used only by CockroachDB's developers for restoring engine health. " + + "It is used to compact a span of the engine at the given node and store. The start and " + + "end keys are bytes. To compact a particular rangeID, one can do: " + + "SELECT crdb_internal.compact_engine_span(, , start_key, end_key) " + + "FROM crdb_internal.ranges_no_leases WHERE range_id=. If one has hex or escape " + + "formatted bytea, one can use decode(, 'hex'|'escape') as the parameter. " + + "The compaction is run synchronously, so this function may take a long time to return. " + + "One can use the logs at the node to confirm that a compaction has started.", + Volatility: tree.VolatilityVolatile, + }, + ), + "num_nulls": makeBuiltin( tree.FunctionProperties{ Category: categoryComparison, diff --git a/pkg/sql/sem/tree/eval.go b/pkg/sql/sem/tree/eval.go index 1ec9669e5a46..c01d0469042b 100644 --- a/pkg/sql/sem/tree/eval.go +++ b/pkg/sql/sem/tree/eval.go @@ -3035,17 +3035,17 @@ type EvalPlanner interface { // EvalSubquery returns the Datum for the given subquery node. EvalSubquery(expr *Subquery) (Datum, error) - // UnsafeUpsertDescriptor is a used to repair descriptors in dire + // UnsafeUpsertDescriptor is used to repair descriptors in dire // circumstances. See the comment on the planner implementation. UnsafeUpsertDescriptor( ctx context.Context, descID int64, encodedDescriptor []byte, force bool, ) error - // UnsafeDeleteDescriptor is a used to repair descriptors in dire + // UnsafeDeleteDescriptor is used to repair descriptors in dire // circumstances. See the comment on the planner implementation. UnsafeDeleteDescriptor(ctx context.Context, descID int64, force bool) error - // UnsafeUpsertNamespaceEntry is a used to repair namespace entries in dire + // UnsafeUpsertNamespaceEntry is used to repair namespace entries in dire // circumstances. See the comment on the planner implementation. UnsafeUpsertNamespaceEntry( ctx context.Context, @@ -3055,7 +3055,7 @@ type EvalPlanner interface { force bool, ) error - // UnsafeDeleteNamespaceEntry is a used to repair namespace entries in dire + // UnsafeDeleteNamespaceEntry is used to repair namespace entries in dire // circumstances. See the comment on the planner implementation. UnsafeDeleteNamespaceEntry( ctx context.Context, @@ -3064,6 +3064,14 @@ type EvalPlanner interface { descID int64, force bool, ) error + + // CompactEngineSpan is used to compact an engine key span at the given + // (nodeID, storeID). If we add more overloads to the compact_span builtin, + // this parameter list should be changed to a struct union to accommodate + // those overloads. + CompactEngineSpan( + ctx context.Context, nodeID int32, storeID int32, startKey []byte, endKey []byte, + ) error } // EvalSessionAccessor is a limited interface to access session variables.