diff --git a/pkg/cmd/roachtest/pebble.go b/pkg/cmd/roachtest/pebble.go index 85abe70b89aa..dba9c6a1c51a 100644 --- a/pkg/cmd/roachtest/pebble.go +++ b/pkg/cmd/roachtest/pebble.go @@ -61,7 +61,7 @@ func registerPebble(r *testRegistry) { "rm -f %s && tar cvPf %s %s) > init.log 2>&1", benchDir, size, initialKeys, cache, dataTar, dataTar, benchDir)) - for _, workload := range []string{"A", "B", "C", "D", "E"} { + for _, workload := range []string{"A", "B", "C", "D", "E", "F"} { keys := "zipf" switch workload { case "D": diff --git a/pkg/kv/kvnemesis/applier.go b/pkg/kv/kvnemesis/applier.go index 305563e2ef2e..fdd9e8fde798 100644 --- a/pkg/kv/kvnemesis/applier.go +++ b/pkg/kv/kvnemesis/applier.go @@ -82,6 +82,9 @@ func applyOp(ctx context.Context, db *kv.DB, op *Operation) { _, err := db.AdminChangeReplicas(ctx, o.Key, desc, o.Changes) // TODO(dan): Save returned desc? o.Result = resultError(ctx, err) + case *TransferLeaseOperation: + err := db.AdminTransferLease(ctx, o.Key, o.Target) + o.Result = resultError(ctx, err) case *ClosureTxnOperation: var savedTxn *kv.Txn txnErr := db.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error { diff --git a/pkg/kv/kvnemesis/applier_test.go b/pkg/kv/kvnemesis/applier_test.go index 7386ec8dd76d..5cb05491a5a2 100644 --- a/pkg/kv/kvnemesis/applier_test.go +++ b/pkg/kv/kvnemesis/applier_test.go @@ -140,4 +140,10 @@ db0.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error { `db1.AdminSplit(ctx, "foo") // context canceled`) checkErr(t, step(merge(`foo`)), `db0.AdminMerge(ctx, "foo") // context canceled`) + + // Lease transfers + check(t, step(transferLease(`foo`, 1)), + `db1.TransferLeaseOperation(ctx, "foo", 1) // nil`) + checkErr(t, step(transferLease(`foo`, 1)), + `db0.TransferLeaseOperation(ctx, "foo", 1) // context canceled`) } diff --git a/pkg/kv/kvnemesis/doc.go b/pkg/kv/kvnemesis/doc.go index 3b06bad26827..bacc61e7bf2f 100644 --- a/pkg/kv/kvnemesis/doc.go +++ b/pkg/kv/kvnemesis/doc.go @@ -25,7 +25,10 @@ // TODO // - CPut/InitPut/Increment/Delete // - DeleteRange/ClearRange/RevertRange/ReverseScan -// - TransferLease +// - AdminRelocateRange +// - AdminUnsplit +// - AdminScatter +// - CheckConsistency // - ExportRequest // - AddSSTable // - Root and leaf transactions diff --git a/pkg/kv/kvnemesis/generator.go b/pkg/kv/kvnemesis/generator.go index be7bfef8d4bf..4e56bda84573 100644 --- a/pkg/kv/kvnemesis/generator.go +++ b/pkg/kv/kvnemesis/generator.go @@ -42,6 +42,7 @@ type OperationConfig struct { Split SplitConfig Merge MergeConfig ChangeReplicas ChangeReplicasConfig + ChangeLease ChangeLeaseConfig } // ClosureTxnConfig configures the relative probability of running some @@ -129,6 +130,13 @@ type ChangeReplicasConfig struct { AtomicSwapReplica int } +// ChangeLeaseConfig configures the relative probability of generating an +// operation that causes a leaseholder change. +type ChangeLeaseConfig struct { + // Transfer the lease to a random replica. + TransferLease int +} + // newAllOperationsConfig returns a GeneratorConfig that exercises *all* // options. You probably want NewDefaultConfig. Most of the time, these will be // the same, but having both allows us to merge code for operations that do not @@ -170,6 +178,9 @@ func newAllOperationsConfig() GeneratorConfig { RemoveReplica: 1, AtomicSwapReplica: 1, }, + ChangeLease: ChangeLeaseConfig{ + TransferLease: 1, + }, }} } @@ -324,6 +335,8 @@ func (g *generator) RandStep(rng *rand.Rand) Step { removeReplicaFn := makeRemoveReplicaFn(key, current) addOpGen(&allowed, removeReplicaFn, g.Config.Ops.ChangeReplicas.RemoveReplica) } + transferLeaseFn := makeTransferLeaseFn(key, current) + addOpGen(&allowed, transferLeaseFn, g.Config.Ops.ChangeLease.TransferLease) return step(g.selectOp(rng, allowed)) } @@ -473,6 +486,13 @@ func makeAddReplicaFn(key string, current []roachpb.ReplicationTarget, atomicSwa } } +func makeTransferLeaseFn(key string, current []roachpb.ReplicationTarget) opGenFunc { + return func(g *generator, rng *rand.Rand) Operation { + target := current[rng.Intn(len(current))] + return transferLease(key, target.StoreID) + } +} + func makeRandBatch(c *ClientOperationConfig) opGenFunc { return func(g *generator, rng *rand.Rand) Operation { var allowed []opGen @@ -600,3 +620,7 @@ func merge(key string) Operation { func changeReplicas(key string, changes ...roachpb.ReplicationChange) Operation { return Operation{ChangeReplicas: &ChangeReplicasOperation{Key: []byte(key), Changes: changes}} } + +func transferLease(key string, target roachpb.StoreID) Operation { + return Operation{TransferLease: &TransferLeaseOperation{Key: []byte(key), Target: target}} +} diff --git a/pkg/kv/kvnemesis/generator_test.go b/pkg/kv/kvnemesis/generator_test.go index 9ab835b14d91..99ab65d7dd65 100644 --- a/pkg/kv/kvnemesis/generator_test.go +++ b/pkg/kv/kvnemesis/generator_test.go @@ -169,6 +169,8 @@ func TestRandStep(t *testing.T) { } else if adds == 1 && removes == 1 { counts.ChangeReplicas.AtomicSwapReplica++ } + case *TransferLeaseOperation: + counts.ChangeLease.TransferLease++ } updateKeys(step.Op) diff --git a/pkg/kv/kvnemesis/operations.go b/pkg/kv/kvnemesis/operations.go index 4e03f02855d8..52ac5de1f474 100644 --- a/pkg/kv/kvnemesis/operations.go +++ b/pkg/kv/kvnemesis/operations.go @@ -33,6 +33,10 @@ func (op Operation) Result() *Result { return &o.Result case *MergeOperation: return &o.Result + case *ChangeReplicasOperation: + return &o.Result + case *TransferLeaseOperation: + return &o.Result case *BatchOperation: return &o.Result case *ClosureTxnOperation: @@ -104,6 +108,8 @@ func (op Operation) format(w *strings.Builder, fctx formatCtx) { o.format(w, fctx) case *ChangeReplicasOperation: o.format(w, fctx) + case *TransferLeaseOperation: + o.format(w, fctx) case *BatchOperation: newFctx := fctx newFctx.indent = fctx.indent + ` ` @@ -231,6 +237,11 @@ func (op ChangeReplicasOperation) format(w *strings.Builder, fctx formatCtx) { op.Result.format(w) } +func (op TransferLeaseOperation) format(w *strings.Builder, fctx formatCtx) { + fmt.Fprintf(w, `%s.TransferLeaseOperation(ctx, %s, %d)`, fctx.receiver, roachpb.Key(op.Key), op.Target) + op.Result.format(w) +} + func (r Result) format(w *strings.Builder) { switch r.Type { case ResultType_NoError: diff --git a/pkg/kv/kvnemesis/operations.pb.go b/pkg/kv/kvnemesis/operations.pb.go index 6ed73845fd01..ba7c7314a9c9 100644 --- a/pkg/kv/kvnemesis/operations.pb.go +++ b/pkg/kv/kvnemesis/operations.pb.go @@ -10,6 +10,8 @@ import errorspb "github.com/cockroachdb/errors/errorspb" import roachpb "github.com/cockroachdb/cockroach/pkg/roachpb" import hlc "github.com/cockroachdb/cockroach/pkg/util/hlc" +import github_com_cockroachdb_cockroach_pkg_roachpb "github.com/cockroachdb/cockroach/pkg/roachpb" + import io "io" // Reference imports to suppress errors if they are not otherwise used. @@ -43,7 +45,7 @@ func (x ClosureTxnType) String() string { return proto.EnumName(ClosureTxnType_name, int32(x)) } func (ClosureTxnType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{0} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{0} } type ResultType int32 @@ -75,7 +77,7 @@ func (x ResultType) String() string { return proto.EnumName(ResultType_name, int32(x)) } func (ResultType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{1} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{1} } type BatchOperation struct { @@ -87,7 +89,7 @@ func (m *BatchOperation) Reset() { *m = BatchOperation{} } func (m *BatchOperation) String() string { return proto.CompactTextString(m) } func (*BatchOperation) ProtoMessage() {} func (*BatchOperation) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{0} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{0} } func (m *BatchOperation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -125,7 +127,7 @@ func (m *ClosureTxnOperation) Reset() { *m = ClosureTxnOperation{} } func (m *ClosureTxnOperation) String() string { return proto.CompactTextString(m) } func (*ClosureTxnOperation) ProtoMessage() {} func (*ClosureTxnOperation) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{1} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{1} } func (m *ClosureTxnOperation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -159,7 +161,7 @@ func (m *GetOperation) Reset() { *m = GetOperation{} } func (m *GetOperation) String() string { return proto.CompactTextString(m) } func (*GetOperation) ProtoMessage() {} func (*GetOperation) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{2} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{2} } func (m *GetOperation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -195,7 +197,7 @@ func (m *ScanOperation) Reset() { *m = ScanOperation{} } func (m *ScanOperation) String() string { return proto.CompactTextString(m) } func (*ScanOperation) ProtoMessage() {} func (*ScanOperation) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{3} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{3} } func (m *ScanOperation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -230,7 +232,7 @@ func (m *PutOperation) Reset() { *m = PutOperation{} } func (m *PutOperation) String() string { return proto.CompactTextString(m) } func (*PutOperation) ProtoMessage() {} func (*PutOperation) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{4} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{4} } func (m *PutOperation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -264,7 +266,7 @@ func (m *SplitOperation) Reset() { *m = SplitOperation{} } func (m *SplitOperation) String() string { return proto.CompactTextString(m) } func (*SplitOperation) ProtoMessage() {} func (*SplitOperation) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{5} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{5} } func (m *SplitOperation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -298,7 +300,7 @@ func (m *MergeOperation) Reset() { *m = MergeOperation{} } func (m *MergeOperation) String() string { return proto.CompactTextString(m) } func (*MergeOperation) ProtoMessage() {} func (*MergeOperation) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{6} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{6} } func (m *MergeOperation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -333,7 +335,7 @@ func (m *ChangeReplicasOperation) Reset() { *m = ChangeReplicasOperation func (m *ChangeReplicasOperation) String() string { return proto.CompactTextString(m) } func (*ChangeReplicasOperation) ProtoMessage() {} func (*ChangeReplicasOperation) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{7} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{7} } func (m *ChangeReplicasOperation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -358,6 +360,41 @@ func (m *ChangeReplicasOperation) XXX_DiscardUnknown() { var xxx_messageInfo_ChangeReplicasOperation proto.InternalMessageInfo +type TransferLeaseOperation struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Target github_com_cockroachdb_cockroach_pkg_roachpb.StoreID `protobuf:"varint,2,opt,name=target,proto3,casttype=github.com/cockroachdb/cockroach/pkg/roachpb.StoreID" json:"target,omitempty"` + Result Result `protobuf:"bytes,3,opt,name=result,proto3" json:"result"` +} + +func (m *TransferLeaseOperation) Reset() { *m = TransferLeaseOperation{} } +func (m *TransferLeaseOperation) String() string { return proto.CompactTextString(m) } +func (*TransferLeaseOperation) ProtoMessage() {} +func (*TransferLeaseOperation) Descriptor() ([]byte, []int) { + return fileDescriptor_operations_7efc7ec20a8915d9, []int{8} +} +func (m *TransferLeaseOperation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TransferLeaseOperation) 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 *TransferLeaseOperation) XXX_Merge(src proto.Message) { + xxx_messageInfo_TransferLeaseOperation.Merge(dst, src) +} +func (m *TransferLeaseOperation) XXX_Size() int { + return m.Size() +} +func (m *TransferLeaseOperation) XXX_DiscardUnknown() { + xxx_messageInfo_TransferLeaseOperation.DiscardUnknown(m) +} + +var xxx_messageInfo_TransferLeaseOperation proto.InternalMessageInfo + type Operation struct { Batch *BatchOperation `protobuf:"bytes,1,opt,name=batch,proto3" json:"batch,omitempty"` // TODO(dan): The original prototype of kvnemesis had separate operations for @@ -371,12 +408,13 @@ type Operation struct { Split *SplitOperation `protobuf:"bytes,10,opt,name=split,proto3" json:"split,omitempty"` Merge *MergeOperation `protobuf:"bytes,11,opt,name=merge,proto3" json:"merge,omitempty"` ChangeReplicas *ChangeReplicasOperation `protobuf:"bytes,12,opt,name=change_replicas,json=changeReplicas,proto3" json:"change_replicas,omitempty"` + TransferLease *TransferLeaseOperation `protobuf:"bytes,13,opt,name=transfer_lease,json=transferLease,proto3" json:"transfer_lease,omitempty"` } func (m *Operation) Reset() { *m = Operation{} } func (*Operation) ProtoMessage() {} func (*Operation) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{8} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{9} } func (m *Operation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -411,7 +449,7 @@ func (m *KeyValue) Reset() { *m = KeyValue{} } func (m *KeyValue) String() string { return proto.CompactTextString(m) } func (*KeyValue) ProtoMessage() {} func (*KeyValue) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{9} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{10} } func (m *KeyValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -450,7 +488,7 @@ func (m *Result) Reset() { *m = Result{} } func (m *Result) String() string { return proto.CompactTextString(m) } func (*Result) ProtoMessage() {} func (*Result) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{10} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{11} } func (m *Result) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -488,7 +526,7 @@ type Step struct { func (m *Step) Reset() { *m = Step{} } func (*Step) ProtoMessage() {} func (*Step) Descriptor() ([]byte, []int) { - return fileDescriptor_operations_928d467cbd1fe68c, []int{11} + return fileDescriptor_operations_7efc7ec20a8915d9, []int{12} } func (m *Step) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -522,6 +560,7 @@ func init() { proto.RegisterType((*SplitOperation)(nil), "cockroach.kv.kvnemesis.SplitOperation") proto.RegisterType((*MergeOperation)(nil), "cockroach.kv.kvnemesis.MergeOperation") proto.RegisterType((*ChangeReplicasOperation)(nil), "cockroach.kv.kvnemesis.ChangeReplicasOperation") + proto.RegisterType((*TransferLeaseOperation)(nil), "cockroach.kv.kvnemesis.TransferLeaseOperation") proto.RegisterType((*Operation)(nil), "cockroach.kv.kvnemesis.Operation") proto.RegisterType((*KeyValue)(nil), "cockroach.kv.kvnemesis.KeyValue") proto.RegisterType((*Result)(nil), "cockroach.kv.kvnemesis.Result") @@ -862,6 +901,43 @@ func (m *ChangeReplicasOperation) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *TransferLeaseOperation) 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 *TransferLeaseOperation) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Key) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintOperations(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + if m.Target != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintOperations(dAtA, i, uint64(m.Target)) + } + dAtA[i] = 0x1a + i++ + i = encodeVarintOperations(dAtA, i, uint64(m.Result.Size())) + n11, err := m.Result.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n11 + return i, nil +} + func (m *Operation) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -881,81 +957,91 @@ func (m *Operation) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintOperations(dAtA, i, uint64(m.Batch.Size())) - n11, err := m.Batch.MarshalTo(dAtA[i:]) + n12, err := m.Batch.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n11 + i += n12 } if m.ClosureTxn != nil { dAtA[i] = 0x12 i++ i = encodeVarintOperations(dAtA, i, uint64(m.ClosureTxn.Size())) - n12, err := m.ClosureTxn.MarshalTo(dAtA[i:]) + n13, err := m.ClosureTxn.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n12 + i += n13 } if m.Get != nil { dAtA[i] = 0x3a i++ i = encodeVarintOperations(dAtA, i, uint64(m.Get.Size())) - n13, err := m.Get.MarshalTo(dAtA[i:]) + n14, err := m.Get.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n13 + i += n14 } if m.Put != nil { dAtA[i] = 0x42 i++ i = encodeVarintOperations(dAtA, i, uint64(m.Put.Size())) - n14, err := m.Put.MarshalTo(dAtA[i:]) + n15, err := m.Put.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n14 + i += n15 } if m.Scan != nil { dAtA[i] = 0x4a i++ i = encodeVarintOperations(dAtA, i, uint64(m.Scan.Size())) - n15, err := m.Scan.MarshalTo(dAtA[i:]) + n16, err := m.Scan.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n15 + i += n16 } if m.Split != nil { dAtA[i] = 0x52 i++ i = encodeVarintOperations(dAtA, i, uint64(m.Split.Size())) - n16, err := m.Split.MarshalTo(dAtA[i:]) + n17, err := m.Split.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n16 + i += n17 } if m.Merge != nil { dAtA[i] = 0x5a i++ i = encodeVarintOperations(dAtA, i, uint64(m.Merge.Size())) - n17, err := m.Merge.MarshalTo(dAtA[i:]) + n18, err := m.Merge.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n17 + i += n18 } if m.ChangeReplicas != nil { dAtA[i] = 0x62 i++ i = encodeVarintOperations(dAtA, i, uint64(m.ChangeReplicas.Size())) - n18, err := m.ChangeReplicas.MarshalTo(dAtA[i:]) + n19, err := m.ChangeReplicas.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n18 + i += n19 + } + if m.TransferLease != nil { + dAtA[i] = 0x6a + i++ + i = encodeVarintOperations(dAtA, i, uint64(m.TransferLease.Size())) + n20, err := m.TransferLease.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n20 } return i, nil } @@ -1014,11 +1100,11 @@ func (m *Result) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintOperations(dAtA, i, uint64(m.Err.Size())) - n19, err := m.Err.MarshalTo(dAtA[i:]) + n21, err := m.Err.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n19 + i += n21 } if len(m.Value) > 0 { dAtA[i] = 0x1a @@ -1059,27 +1145,27 @@ func (m *Step) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintOperations(dAtA, i, uint64(m.Op.Size())) - n20, err := m.Op.MarshalTo(dAtA[i:]) + n22, err := m.Op.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n20 + i += n22 dAtA[i] = 0x12 i++ i = encodeVarintOperations(dAtA, i, uint64(m.Before.Size())) - n21, err := m.Before.MarshalTo(dAtA[i:]) + n23, err := m.Before.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n21 + i += n23 dAtA[i] = 0x1a i++ i = encodeVarintOperations(dAtA, i, uint64(m.After.Size())) - n22, err := m.After.MarshalTo(dAtA[i:]) + n24, err := m.After.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n22 + i += n24 if m.DBID != 0 { dAtA[i] = 0x20 i++ @@ -1259,6 +1345,24 @@ func (m *ChangeReplicasOperation) Size() (n int) { return n } +func (m *TransferLeaseOperation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovOperations(uint64(l)) + } + if m.Target != 0 { + n += 1 + sovOperations(uint64(m.Target)) + } + l = m.Result.Size() + n += 1 + l + sovOperations(uint64(l)) + return n +} + func (m *Operation) Size() (n int) { if m == nil { return 0 @@ -1297,6 +1401,10 @@ func (m *Operation) Size() (n int) { l = m.ChangeReplicas.Size() n += 1 + l + sovOperations(uint64(l)) } + if m.TransferLease != nil { + l = m.TransferLease.Size() + n += 1 + l + sovOperations(uint64(l)) + } return n } @@ -1403,6 +1511,9 @@ func (this *Operation) GetValue() interface{} { if this.ChangeReplicas != nil { return this.ChangeReplicas } + if this.TransferLease != nil { + return this.TransferLease + } return nil } @@ -1424,6 +1535,8 @@ func (this *Operation) SetValue(value interface{}) bool { this.Merge = vt case *ChangeReplicasOperation: this.ChangeReplicas = vt + case *TransferLeaseOperation: + this.TransferLease = vt default: return false } @@ -2544,6 +2657,136 @@ func (m *ChangeReplicasOperation) Unmarshal(dAtA []byte) error { } return nil } +func (m *TransferLeaseOperation) 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 ErrIntOverflowOperations + } + 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: TransferLeaseOperation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TransferLeaseOperation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOperations + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOperations + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + } + m.Target = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOperations + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Target |= (github_com_cockroachdb_cockroach_pkg_roachpb.StoreID(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOperations + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOperations + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Result.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOperations(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOperations + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Operation) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2837,6 +3080,39 @@ func (m *Operation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferLease", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOperations + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOperations + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TransferLease == nil { + m.TransferLease = &TransferLeaseOperation{} + } + if err := m.TransferLease.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipOperations(dAtA[iNdEx:]) @@ -3428,69 +3704,74 @@ var ( ) func init() { - proto.RegisterFile("kv/kvnemesis/operations.proto", fileDescriptor_operations_928d467cbd1fe68c) -} - -var fileDescriptor_operations_928d467cbd1fe68c = []byte{ - // 957 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x6f, 0x1b, 0xc5, - 0x17, 0xf7, 0x78, 0xd7, 0x8e, 0xfd, 0xec, 0xba, 0xfe, 0xcf, 0xbf, 0xd0, 0x55, 0xa5, 0xd8, 0xc6, - 0x2a, 0x28, 0x4a, 0x25, 0x1b, 0x05, 0xa9, 0x28, 0xa1, 0xe2, 0xe0, 0xa4, 0x02, 0xab, 0x50, 0xd0, - 0xc6, 0x45, 0x88, 0x03, 0xee, 0x7a, 0x77, 0x62, 0xaf, 0xbc, 0x9e, 0x59, 0xcd, 0x8e, 0x83, 0xfd, - 0x11, 0xb8, 0x71, 0x83, 0x63, 0xc5, 0x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, 0x2b, 0xfc, 0x5a, 0x58, 0x8d, 0xc0, - 0xdb, 0x90, 0xf3, 0x06, 0xf2, 0x75, 0x20, 0x2f, 0x82, 0x5c, 0xa7, 0xb0, 0x38, 0xaf, 0x9b, 0x47, - 0x9d, 0xee, 0x91, 0x6d, 0x7a, 0x83, 0xae, 0x27, 0xe9, 0x12, 0xdc, 0x71, 0x89, 0xba, 0x53, 0x8b, - 0xb6, 0xfe, 0x38, 0x30, 0xe5, 0xce, 0xef, 0xee, 0x42, 0x65, 0xf5, 0x22, 0xc6, 0x00, 0xf9, 0x43, - 0x75, 0x9f, 0x57, 0x33, 0xb8, 0x0c, 0x05, 0x9b, 0x05, 0xc1, 0xc0, 0x71, 0xc7, 0x55, 0xb4, 0xfb, - 0x39, 0xc0, 0x72, 0xfb, 0x70, 0x09, 0xb6, 0x9e, 0xd1, 0x31, 0x65, 0x3f, 0xd0, 0x6a, 0x46, 0x7e, - 0x3c, 0x65, 0x6a, 0x87, 0xaa, 0x08, 0x17, 0x21, 0xa7, 0xcd, 0xac, 0x34, 0x15, 0xd5, 0x55, 0x43, - 0xe6, 0x55, 0x66, 0x54, 0x35, 0x3b, 0x0f, 0xce, 0xfe, 0xac, 0x65, 0xce, 0x16, 0x35, 0xf4, 0x72, - 0x51, 0x43, 0xaf, 0x16, 0x35, 0xf4, 0xc7, 0xa2, 0x86, 0x7e, 0xba, 0xa8, 0x65, 0x5e, 0x5e, 0xd4, - 0x32, 0xaf, 0x2e, 0x6a, 0x99, 0xef, 0x8a, 0x97, 0x4c, 0x0f, 0xf2, 0xea, 0x9d, 0xf6, 0xd1, 0x3f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x09, 0xc4, 0x2c, 0x4e, 0x0a, 0x00, 0x00, + proto.RegisterFile("kv/kvnemesis/operations.proto", fileDescriptor_operations_7efc7ec20a8915d9) +} + +var fileDescriptor_operations_7efc7ec20a8915d9 = []byte{ + // 1040 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xda, 0x6b, 0xc7, 0x7e, 0x49, 0x5c, 0x33, 0x94, 0x76, 0x55, 0x29, 0xb6, 0xb1, 0x0a, + 0x8a, 0x5a, 0x69, 0x17, 0x05, 0x54, 0x48, 0xa8, 0x38, 0x38, 0xa9, 0xc0, 0x6a, 0x29, 0xd5, 0x24, + 0x41, 0x88, 0x03, 0xee, 0x78, 0x77, 0x62, 0xaf, 0xbc, 0xde, 0x59, 0xcd, 0x8e, 0x43, 0xf2, 0x13, + 0xb8, 0x71, 0x83, 0x63, 0xff, 0x01, 0x77, 0x7e, 0x41, 0xc4, 0xa9, 0xc7, 0x9e, 0x22, 0x70, 0xee, + 0x1c, 0xb8, 0xc1, 0x09, 0xcd, 0xcc, 0x6e, 0xbc, 0x16, 0xb1, 0x49, 0x13, 0xf5, 0xf6, 0xe6, 0xed, + 0xfb, 0xde, 0x7b, 0xf3, 0xcd, 0x7b, 0x6f, 0x1f, 0xac, 0x0d, 0x0f, 0x9d, 0xe1, 0x61, 0x48, 0x47, + 0x34, 0xf6, 0x63, 0x87, 0x45, 0x94, 0x13, 0xe1, 0xb3, 0x30, 0xb6, 0x23, 0xce, 0x04, 0x43, 0xb7, + 0x5c, 0xe6, 0x0e, 0x39, 0x23, 0xee, 0xc0, 0x1e, 0x1e, 0xda, 0xe7, 0x86, 0x77, 0xde, 0xa1, 0x9c, + 0x33, 0x1e, 0x47, 0x3d, 0x47, 0x0b, 0xda, 0xfc, 0xce, 0xcd, 0x3e, 0xeb, 0x33, 0x25, 0x3a, 0x52, + 0x4a, 0xb4, 0x6f, 0x29, 0x07, 0x51, 0xcf, 0x21, 0x91, 0x9f, 0xa8, 0x50, 0xaa, 0xf2, 0x88, 0x20, + 0x89, 0xce, 0x1a, 0x0b, 0x3f, 0x70, 0x06, 0x81, 0xeb, 0x08, 0x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0xcb, 0x94, 0x2f, 0x7f, 0xef, 0x1e, 0x54, 0x67, 0x97, 0x13, 0x04, + 0x50, 0xda, 0x56, 0x3b, 0x4e, 0x2d, 0x87, 0x56, 0xa0, 0x8c, 0x59, 0x10, 0xf4, 0x88, 0x3b, 0xac, + 0x19, 0xf7, 0xbe, 0x00, 0x98, 0x3e, 0x1f, 0x5a, 0x86, 0xa5, 0xfd, 0x70, 0x18, 0xb2, 0xef, 0xc3, + 0x5a, 0x4e, 0x1e, 0x9e, 0x32, 0xf5, 0x42, 0x35, 0x03, 0x55, 0xa0, 0xa8, 0xc5, 0xbc, 0x14, 0x15, + 0xd5, 0xb5, 0x82, 0xf4, 0xab, 0xc4, 0xb8, 0x66, 0xb6, 0xef, 0x9f, 0xfc, 0x51, 0xcf, 0x9d, 0x4c, + 0xea, 0xc6, 0xcb, 0x49, 0xdd, 0x78, 0x35, 0xa9, 0x1b, 0xbf, 0x4f, 0xea, 0xc6, 0x8f, 0x67, 0xf5, + 0xdc, 0xcb, 0xb3, 0x7a, 0xee, 0xd5, 0x59, 0x3d, 0xf7, 0x6d, 0xe5, 0x9c, 0xe9, 0x5e, 0x49, 0xed, + 0xae, 0x1f, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x62, 0x08, 0xb0, 0xfa, 0x62, 0x0b, 0x00, 0x00, } diff --git a/pkg/kv/kvnemesis/operations.proto b/pkg/kv/kvnemesis/operations.proto index 159aaf5bdb45..0e843c39bb21 100644 --- a/pkg/kv/kvnemesis/operations.proto +++ b/pkg/kv/kvnemesis/operations.proto @@ -72,6 +72,12 @@ message ChangeReplicasOperation { Result result = 3 [(gogoproto.nullable) = false]; } +message TransferLeaseOperation { + bytes key = 1; + int32 target = 2 [(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.StoreID"]; + Result result = 3 [(gogoproto.nullable) = false]; +} + message Operation { option (gogoproto.goproto_stringer) = false; option (gogoproto.onlyone) = true; @@ -90,6 +96,7 @@ message Operation { SplitOperation split = 10; MergeOperation merge = 11; ChangeReplicasOperation change_replicas = 12; + TransferLeaseOperation transfer_lease = 13; } enum ResultType { diff --git a/pkg/kv/kvnemesis/validator.go b/pkg/kv/kvnemesis/validator.go index 0c824e75dc5a..f80a23f68d86 100644 --- a/pkg/kv/kvnemesis/validator.go +++ b/pkg/kv/kvnemesis/validator.go @@ -340,6 +340,17 @@ func (v *validator) processOp(txnID *string, op Operation) { if !ignore { v.failIfError(op, t.Result) } + case *TransferLeaseOperation: + if resultIsError(t.Result, `cannot transfer lease to replica of type (VOTER_INCOMING|VOTER_OUTGOING|VOTER_DEMOTING|LEARNER|NON_VOTER)`) { + // Only VOTER_FULL replicas can currently hold a range lease. + // Attempts to transfer to lease to any other replica type are + // rejected. + } else if resultIsError(t.Result, `unable to find store \d+ in range`) { + // A lease transfer that races with a replica removal may find that + // the store it was targeting is no longer part of the range. + } else { + v.failIfError(op, t.Result) + } case *BatchOperation: if !resultIsRetryable(t.Result) { v.failIfError(op, t.Result) diff --git a/pkg/sql/colexec/COLEXEC.bzl b/pkg/sql/colexec/COLEXEC.bzl index 7c2fecbe1968..18e754e97cf5 100644 --- a/pkg/sql/colexec/COLEXEC.bzl +++ b/pkg/sql/colexec/COLEXEC.bzl @@ -3,6 +3,7 @@ targets = [ ('and_or_projection.eg.go', 'and_or_projection_tmpl.go'), ('cast.eg.go', 'cast_tmpl.go'), ('const.eg.go', 'const_tmpl.go'), + ('crossjoiner.eg.go', 'crossjoiner_tmpl.go'), ('default_cmp_expr.eg.go', 'default_cmp_expr_tmpl.go'), ('default_cmp_proj_ops.eg.go', 'default_cmp_proj_ops_tmpl.go'), ('default_cmp_sel_ops.eg.go', 'default_cmp_sel_ops_tmpl.go'), diff --git a/pkg/sql/colexec/crossjoiner.eg.go b/pkg/sql/colexec/crossjoiner.eg.go index c63c352aafba..6d7739936637 100644 --- a/pkg/sql/colexec/crossjoiner.eg.go +++ b/pkg/sql/colexec/crossjoiner.eg.go @@ -19,6 +19,12 @@ import ( "github.com/cockroachdb/errors" ) +// Workaround for bazel auto-generated code. goimports does not automatically +// pick up the right packages when run within the bazel sandbox. +var ( + _ = typeconv.DatumVecCanonicalTypeFamily +) + // buildFromLeftInput builds part of the output of a cross join that comes from // the vectors of the left input. The new output tuples are put starting at // index destStartIdx and will not exceed the capacity of the output batch. It diff --git a/pkg/sql/colexec/crossjoiner_tmpl.go b/pkg/sql/colexec/crossjoiner_tmpl.go index 7107e7a93437..31f44a75c79a 100644 --- a/pkg/sql/colexec/crossjoiner_tmpl.go +++ b/pkg/sql/colexec/crossjoiner_tmpl.go @@ -23,11 +23,19 @@ import ( "context" "github.com/cockroachdb/cockroach/pkg/col/coldata" + "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" "github.com/cockroachdb/cockroach/pkg/sql/colexecbase/colexecerror" + "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/errors" ) +// Workaround for bazel auto-generated code. goimports does not automatically +// pick up the right packages when run within the bazel sandbox. +var ( + _ = typeconv.DatumVecCanonicalTypeFamily +) + // buildFromLeftInput builds part of the output of a cross join that comes from // the vectors of the left input. The new output tuples are put starting at // index destStartIdx and will not exceed the capacity of the output batch. It