From a2b9c19ca29709a5cd9424ccba0c765b60e2647b Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Tue, 23 Feb 2021 01:51:51 -0500 Subject: [PATCH 1/2] kv: make RaftCommand.ClosedTimestamp nullable Fixes #60852. Fixes #60833. Fixes #58298. Fixes #59428. Fixes #60756. Fixes #60848. Fixes #60849. In #60852 and related issues, we saw that the introduction of a non-nullable `RaftCommand.ClosedTimestamp`, coupled with the `ClosedTimestampFooter` encoding strategy we use, led to encoded `RaftCommand` protos with their ClosedTimestamp field set twice. This is ok from a correctness perspective, at least as protobuf is concerned, but it led to a subtle interaction where the process of passing through sideloading (`maybeInlineSideloadedRaftCommand(maybeSideloadEntriesImpl(e))`) would reduce the size of an encoded RaftCommand by 3 bytes (the encoded size of an empty `hlc.Timestamp`). This was resulting in an `uncommittedSize` leak in Raft, which was eventually stalling on its `MaxUncommittedEntriesSize` limit. This commit fixes this issue by making `RaftCommand.ClosedTimestamp` nullable. With the field marked as nullable, it will no longer be encoded as an empty timestamp when unset, ensuring that when the encoded `ClosedTimestampFooter` is appended, it contains the only instance of the `ClosedTimestamp` field. --- pkg/kv/kvserver/client_replica_test.go | 16 +- pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go | 250 +++++++++--------- pkg/kv/kvserver/kvserverpb/proposer_kv.proto | 10 +- .../replica_application_state_machine.go | 8 +- pkg/kv/kvserver/replica_proposal_buf_test.go | 7 +- pkg/kv/kvserver/stateloader/stateloader.go | 17 +- pkg/kv/kvserver/store_split.go | 7 +- 7 files changed, 169 insertions(+), 146 deletions(-) diff --git a/pkg/kv/kvserver/client_replica_test.go b/pkg/kv/kvserver/client_replica_test.go index 71c9b0a0e844..a3d12df4fc79 100644 --- a/pkg/kv/kvserver/client_replica_test.go +++ b/pkg/kv/kvserver/client_replica_test.go @@ -3356,15 +3356,15 @@ func TestProposalOverhead(t *testing.T) { defer tc.Stopper().Stop(ctx) db := tc.Server(0).DB() - // NB: the expected overhead reflects the space overhead currently - // present in Raft commands. This test will fail if that overhead - // changes. Try to make this number go down and not up. It slightly - // undercounts because our proposal filter is called before - // maxLeaseIndex is filled in. The difference between the user and system - // overhead is that users ranges do not have rangefeeds on by default whereas - // system ranges do. + // NB: the expected overhead reflects the space overhead currently present + // in Raft commands. This test will fail if that overhead changes. Try to + // make this number go down and not up. It slightly undercounts because our + // proposal filter is called before MaxLeaseIndex or ClosedTimestamp are + // filled in. The difference between the user and system overhead is that + // users ranges do not have rangefeeds on by default whereas system ranges + // do. const ( - expectedUserOverhead uint32 = 45 + expectedUserOverhead uint32 = 42 ) t.Run("user-key overhead", func(t *testing.T) { userKey := tc.ScratchRange(t) diff --git a/pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go b/pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go index ae64003650e3..7b949c22bbb4 100644 --- a/pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go +++ b/pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go @@ -48,7 +48,7 @@ func (m *Split) Reset() { *m = Split{} } func (m *Split) String() string { return proto.CompactTextString(m) } func (*Split) ProtoMessage() {} func (*Split) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{0} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{0} } func (m *Split) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -83,7 +83,7 @@ func (m *Merge) Reset() { *m = Merge{} } func (m *Merge) String() string { return proto.CompactTextString(m) } func (*Merge) ProtoMessage() {} func (*Merge) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{1} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{1} } func (m *Merge) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -117,7 +117,7 @@ type ChangeReplicas struct { func (m *ChangeReplicas) Reset() { *m = ChangeReplicas{} } func (*ChangeReplicas) ProtoMessage() {} func (*ChangeReplicas) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{2} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{2} } func (m *ChangeReplicas) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -169,7 +169,7 @@ func (m *ComputeChecksum) Reset() { *m = ComputeChecksum{} } func (m *ComputeChecksum) String() string { return proto.CompactTextString(m) } func (*ComputeChecksum) ProtoMessage() {} func (*ComputeChecksum) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{3} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{3} } func (m *ComputeChecksum) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -206,7 +206,7 @@ func (m *Compaction) Reset() { *m = Compaction{} } func (m *Compaction) String() string { return proto.CompactTextString(m) } func (*Compaction) ProtoMessage() {} func (*Compaction) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{4} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{4} } func (m *Compaction) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -243,7 +243,7 @@ func (m *SuggestedCompaction) Reset() { *m = SuggestedCompaction{} } func (m *SuggestedCompaction) String() string { return proto.CompactTextString(m) } func (*SuggestedCompaction) ProtoMessage() {} func (*SuggestedCompaction) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{5} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{5} } func (m *SuggestedCompaction) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -305,7 +305,7 @@ func (m *ReplicatedEvalResult) Reset() { *m = ReplicatedEvalResult{} } func (m *ReplicatedEvalResult) String() string { return proto.CompactTextString(m) } func (*ReplicatedEvalResult) ProtoMessage() {} func (*ReplicatedEvalResult) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{6} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{6} } func (m *ReplicatedEvalResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -349,7 +349,7 @@ func (m *ReplicatedEvalResult_AddSSTable) Reset() { *m = ReplicatedEvalR func (m *ReplicatedEvalResult_AddSSTable) String() string { return proto.CompactTextString(m) } func (*ReplicatedEvalResult_AddSSTable) ProtoMessage() {} func (*ReplicatedEvalResult_AddSSTable) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{6, 0} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{6, 0} } func (m *ReplicatedEvalResult_AddSSTable) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -386,7 +386,7 @@ func (m *WriteBatch) Reset() { *m = WriteBatch{} } func (m *WriteBatch) String() string { return proto.CompactTextString(m) } func (*WriteBatch) ProtoMessage() {} func (*WriteBatch) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{7} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{7} } func (m *WriteBatch) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -423,7 +423,7 @@ func (m *LogicalOpLog) Reset() { *m = LogicalOpLog{} } func (m *LogicalOpLog) String() string { return proto.CompactTextString(m) } func (*LogicalOpLog) ProtoMessage() {} func (*LogicalOpLog) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{8} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{8} } func (m *LogicalOpLog) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -519,8 +519,11 @@ type RaftCommand struct { // in a command-specific way. If the value is not zero, the value is greater // or equal to that of the previous commands (and all before it). // - // This field is set through ClosedTimestampFooter hackery. - ClosedTimestamp hlc.Timestamp `protobuf:"bytes,17,opt,name=closed_timestamp,json=closedTimestamp,proto3" json:"closed_timestamp"` + // This field is set through ClosedTimestampFooter hackery. Unlike in the + // ClosedTimestampFooter, the field is nullable here so that it does not get + // encoded when empty. This prevents the field from being encoded twice in the + // combined RaftCommand+ClosedTimestampFooter proto. + ClosedTimestamp *hlc.Timestamp `protobuf:"bytes,17,opt,name=closed_timestamp,json=closedTimestamp,proto3" json:"closed_timestamp,omitempty"` // replicated_eval_result is a set of structured information that instructs // replicated state changes to the part of a Range's replicated state machine // that exists outside of RocksDB. @@ -544,7 +547,7 @@ func (m *RaftCommand) Reset() { *m = RaftCommand{} } func (m *RaftCommand) String() string { return proto.CompactTextString(m) } func (*RaftCommand) ProtoMessage() {} func (*RaftCommand) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{9} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{9} } func (m *RaftCommand) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -583,7 +586,7 @@ func (m *RaftCommandFooter) Reset() { *m = RaftCommandFooter{} } func (m *RaftCommandFooter) String() string { return proto.CompactTextString(m) } func (*RaftCommandFooter) ProtoMessage() {} func (*RaftCommandFooter) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{10} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{10} } func (m *RaftCommandFooter) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -612,6 +615,9 @@ var xxx_messageInfo_RaftCommandFooter proto.InternalMessageInfo // buffer to fill in the closed_timestamp field after most of the proto has been // marshaled already. type ClosedTimestampFooter struct { + // NOTE: unlike in RaftCommand, there's no reason to make this field nullable. + // If we don't want to include the field, we don't need to append the encoded + // footer to an encoded RaftCommand buffer. ClosedTimestamp hlc.Timestamp `protobuf:"bytes,17,opt,name=closed_timestamp,json=closedTimestamp,proto3" json:"closed_timestamp"` } @@ -619,7 +625,7 @@ func (m *ClosedTimestampFooter) Reset() { *m = ClosedTimestampFooter{} } func (m *ClosedTimestampFooter) String() string { return proto.CompactTextString(m) } func (*ClosedTimestampFooter) ProtoMessage() {} func (*ClosedTimestampFooter) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_0b3536bd0bf3d98c, []int{11} + return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{11} } func (m *ClosedTimestampFooter) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1366,16 +1372,18 @@ func (m *RaftCommand) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], v) } } - dAtA[i] = 0x8a - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintProposerKv(dAtA, i, uint64(m.ClosedTimestamp.Size())) - n21, err := m.ClosedTimestamp.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.ClosedTimestamp != nil { + dAtA[i] = 0x8a + i++ + dAtA[i] = 0x1 + i++ + i = encodeVarintProposerKv(dAtA, i, uint64(m.ClosedTimestamp.Size())) + n21, err := m.ClosedTimestamp.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n21 } - i += n21 return i, nil } @@ -1666,8 +1674,10 @@ func (m *RaftCommand) Size() (n int) { n += mapEntrySize + 2 + sovProposerKv(uint64(mapEntrySize)) } } - l = m.ClosedTimestamp.Size() - n += 2 + l + sovProposerKv(uint64(l)) + if m.ClosedTimestamp != nil { + l = m.ClosedTimestamp.Size() + n += 2 + l + sovProposerKv(uint64(l)) + } return n } @@ -3411,6 +3421,9 @@ func (m *RaftCommand) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + if m.ClosedTimestamp == nil { + m.ClosedTimestamp = &hlc.Timestamp{} + } if err := m.ClosedTimestamp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3691,100 +3704,101 @@ var ( ) func init() { - proto.RegisterFile("kv/kvserver/kvserverpb/proposer_kv.proto", fileDescriptor_proposer_kv_0b3536bd0bf3d98c) -} - -var fileDescriptor_proposer_kv_0b3536bd0bf3d98c = []byte{ - // 1453 bytes of a gzipped FileDescriptorProto - 0x1f, 0x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0xd1, 0xfd, 0xb2, 0x1e, 0x67, 0xd1, - 0x96, 0x5c, 0x81, 0x63, 0x25, 0xb4, 0x01, 0xba, 0xc7, 0x2c, 0x9f, 0x12, 0x46, 0xad, 0x88, 0x3e, - 0xea, 0x53, 0xc6, 0x8d, 0x05, 0x59, 0xd8, 0x05, 0x8f, 0xed, 0x09, 0x31, 0x8e, 0xa5, 0x68, 0x1b, - 0x72, 0x23, 0x92, 0x35, 0x34, 0x69, 0xeb, 0xbf, 0x13, 0xb6, 0x44, 0x7b, 0x9a, 0x6d, 0xdf, 0x36, - 0x0f, 0x93, 0x43, 0xa3, 0xda, 0x4d, 0x04, 0xe8, 0x0e, 0xe8, 0x0e, 0x0d, 0x23, 0x2a, 0xa3, 0xa8, - 0x68, 0x13, 0xde, 0x82, 0x36, 0x71, 0x71, 0xac, 0x2e, 0xb9, 0x12, 0x7d, 0x0e, 0x45, 0x5b, 0xb2, - 0x93, 0x15, 0x29, 0x7a, 0x32, 0x96, 0x24, 0x60, 0xf5, 0xf4, 0xd4, 0x4f, 0xb1, 0x1a, 0x2e, 0xd8, - 0xd3, 0xcc, 0x78, 0x01, 0x0a, 0x11, 0x79, 0xc8, 0x2d, 0x3f, 0x70, 0x95, 0xa7, 0xcb, 0xb2, 0x73, - 0x96, 0x84, 0x74, 0x2f, 0x70, 0x63, 0xfb, 0x8f, 0x20, 0x4f, 0x1c, 0xc7, 0x62, 0x8c, 0x93, 0x96, - 0x4f, 0x8d, 0x15, 0x69, 0xfb, 0xfa, 0xac, 0x55, 0x30, 0x55, 0x4b, 0xe6, 0xb6, 0xe3, 0x34, 0x9b, - 0x87, 0x02, 0xa7, 0x56, 0x10, 0xf4, 0x36, 0xfe, 0xc6, 0x40, 0x1c, 0xa7, 0x19, 0xdb, 0x40, 0x37, - 0x21, 0x1b, 0xfb, 0x83, 0xa4, 0xb1, 0x77, 0x67, 0x8a, 0x9c, 0xf4, 0x56, 0x25, 0x24, 0x56, 0x47, - 0x5f, 0xa5, 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0x18, 0x17, 0xef, 0x9c, 0x96, 0xe7, 0x91, - 0xaa, 0x4a, 0xb3, 0xd0, 0xad, 0x7c, 0xbf, 0x00, 0x79, 0x4c, 0x1e, 0xf2, 0x7a, 0xd0, 0xed, 0x92, + proto.RegisterFile("kv/kvserver/kvserverpb/proposer_kv.proto", fileDescriptor_proposer_kv_4be80e2a938c97b0) +} + +var fileDescriptor_proposer_kv_4be80e2a938c97b0 = []byte{ + // 1459 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x5f, 0x6f, 0x13, 0xc7, + 0x16, 0x8f, 0x63, 0x3b, 0x59, 0x1f, 0x27, 0xf6, 0x66, 0x08, 0xb0, 0x37, 0xf7, 0x5e, 0x3b, 0xf2, + 0xe5, 0xa2, 0xdc, 0x5b, 0xba, 0x46, 0x49, 0x2b, 0x55, 0x80, 0x2a, 0x62, 0x07, 0x4a, 0x4c, 0x92, + 0xc2, 0x38, 0xd0, 0x8a, 0x3e, 0xac, 0xc6, 0xbb, 0xc3, 0x7a, 0xeb, 0xb5, 0x77, 0xd9, 0x19, 0x1b, + 0xf2, 0x29, 0xda, 0x4a, 0x95, 0xda, 0xa7, 0x96, 0xc7, 0x7e, 0x8d, 0xbe, 0xf1, 0xc8, 0x23, 0xea, + 0x83, 0x55, 0xc2, 0x4b, 0x3f, 0x03, 0x4f, 0xd5, 0xcc, 0xce, 0xfa, 0x0f, 0x0a, 0x8d, 0xa1, 0x6f, + 0xb3, 0x67, 0xe6, 0xfc, 0xce, 0x99, 0xf3, 0xe7, 0x77, 0x66, 0x61, 0xa3, 0x33, 0xa8, 0x76, 0x06, + 0x8c, 0x46, 0x03, 0x1a, 0x8d, 0x16, 0x61, 0xab, 0x1a, 0x46, 0x41, 0x18, 0x30, 0x1a, 0x59, 0x9d, + 0x81, 0x19, 0x46, 0x01, 0x0f, 0x50, 0xd9, 0x0e, 0xec, 0x4e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xab, 0x2a, 0x37, 0x9c, 0x3a, 0x37, + 0x06, 0xc4, 0xc7, 0x94, 0xf5, 0x7d, 0x41, 0x23, 0x59, 0xc9, 0x47, 0xaa, 0xfb, 0x3f, 0x3c, 0xd5, + 0xa0, 0x42, 0x11, 0x2c, 0x40, 0x71, 0xac, 0x8b, 0xae, 0x41, 0x96, 0x09, 0xa6, 0x51, 0x5e, 0x5f, + 0x3c, 0x15, 0x44, 0xf2, 0x12, 0x8e, 0x95, 0x84, 0x76, 0x57, 0x74, 0xbf, 0xac, 0xc7, 0x59, 0xb4, + 0x25, 0x57, 0xe0, 0x58, 0x09, 0x6d, 0x80, 0xee, 0x31, 0xcb, 0xa7, 0x84, 0x51, 0x2b, 0xa2, 0x8f, + 0xfa, 0x94, 0x71, 0x63, 0x41, 0x16, 0x76, 0xc1, 0x63, 0x7b, 0x42, 0x8c, 0x63, 0x29, 0xda, 0x86, + 0xdc, 0x88, 0x64, 0x0d, 0x4d, 0xda, 0xfa, 0xf7, 0x84, 0x2d, 0xd1, 0x9e, 0x66, 0xdb, 0xb7, 0xcd, + 0xc3, 0xe4, 0xd0, 0xa8, 0x76, 0x13, 0x01, 0xba, 0x03, 0xba, 0x43, 0xc3, 0x88, 0xca, 0x28, 0x2a, + 0xda, 0x84, 0x77, 0xa0, 0x4d, 0x5c, 0x1c, 0xab, 0x4b, 0xae, 0x44, 0x5f, 0x42, 0xd1, 0x96, 0xec, + 0x64, 0x45, 0x8a, 0x9e, 0x8c, 0x25, 0x09, 0x58, 0x3d, 0x3d, 0xf5, 0x53, 0xac, 0x86, 0x0b, 0xf6, + 0x34, 0x33, 0x5e, 0x80, 0x42, 0x44, 0x1e, 0x72, 0xcb, 0x0f, 0x5c, 0xe5, 0xe9, 0xb2, 0xec, 0x9c, + 0x25, 0x21, 0xdd, 0x0b, 0xdc, 0xd8, 0xfe, 0x23, 0xc8, 0x13, 0xc7, 0xb1, 0x18, 0xe3, 0xa4, 0xe5, + 0x53, 0x63, 0x45, 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x56, 0x1b, 0x09, + 0xd6, 0xae, 0x41, 0x61, 0xda, 0x0c, 0xd2, 0x21, 0x9d, 0xbc, 0x42, 0x72, 0x58, 0x2c, 0xc5, 0xfb, + 0x67, 0x40, 0xfc, 0x7e, 0x3c, 0x85, 0x73, 0x38, 0xfe, 0xb8, 0x32, 0xff, 0x89, 0x68, 0xd6, 0xb4, + 0x9e, 0x19, 0xb5, 0xec, 0xbc, 0x9e, 0x8e, 0xdb, 0xf1, 0xe7, 0x83, 0xca, 0x55, 0x58, 0x99, 0xb8, + 0xca, 0xcd, 0x20, 0xe0, 0x34, 0x9a, 0xb5, 0x3d, 0x2a, 0x2e, 0x9c, 0xad, 0x4f, 0xfb, 0xa9, 0x00, + 0x0e, 0xde, 0xf3, 0xde, 0xaa, 0x96, 0xde, 0xbc, 0x7d, 0xed, 0xd2, 0xb3, 0x97, 0xa5, 0xb9, 0x67, + 0xc7, 0xa5, 0xd4, 0xf3, 0xe3, 0x52, 0xea, 0xc5, 0x71, 0x29, 0xf5, 0xfb, 0x71, 0x29, 0xf5, 0xed, + 0xab, 0xd2, 0xdc, 0xf3, 0x57, 0xa5, 0xb9, 0x17, 0xaf, 0x4a, 0x73, 0x0f, 0x60, 0xfc, 0x6b, 0xd4, + 0x5a, 0x90, 0x7f, 0x39, 0x5b, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0x67, 0x8b, 0xdb, 0x5f, 0x00, + 0x0e, 0x00, 0x00, } diff --git a/pkg/kv/kvserver/kvserverpb/proposer_kv.proto b/pkg/kv/kvserver/kvserverpb/proposer_kv.proto index 249b4e45ca58..391588572755 100644 --- a/pkg/kv/kvserver/kvserverpb/proposer_kv.proto +++ b/pkg/kv/kvserver/kvserverpb/proposer_kv.proto @@ -255,8 +255,11 @@ message RaftCommand { // in a command-specific way. If the value is not zero, the value is greater // or equal to that of the previous commands (and all before it). // - // This field is set through ClosedTimestampFooter hackery. - util.hlc.Timestamp closed_timestamp = 17 [(gogoproto.nullable) = false]; + // This field is set through ClosedTimestampFooter hackery. Unlike in the + // ClosedTimestampFooter, the field is nullable here so that it does not get + // encoded when empty. This prevents the field from being encoded twice in the + // combined RaftCommand+ClosedTimestampFooter proto. + util.hlc.Timestamp closed_timestamp = 17; reserved 3; @@ -298,5 +301,8 @@ message RaftCommandFooter { // buffer to fill in the closed_timestamp field after most of the proto has been // marshaled already. message ClosedTimestampFooter { + // NOTE: unlike in RaftCommand, there's no reason to make this field nullable. + // If we don't want to include the field, we don't need to append the encoded + // footer to an encoded RaftCommand buffer. util.hlc.Timestamp closed_timestamp = 17 [(gogoproto.nullable) = false]; } diff --git a/pkg/kv/kvserver/replica_application_state_machine.go b/pkg/kv/kvserver/replica_application_state_machine.go index 7793ca520fdd..69130255ea85 100644 --- a/pkg/kv/kvserver/replica_application_state_machine.go +++ b/pkg/kv/kvserver/replica_application_state_machine.go @@ -445,7 +445,7 @@ func (b *replicaAppBatch) Stage(cmdI apply.Command) (apply.CheckedCommand, error cmd.raftCmd.ReplicatedEvalResult = kvserverpb.ReplicatedEvalResult{} cmd.raftCmd.WriteBatch = nil cmd.raftCmd.LogicalOpLog = nil - cmd.raftCmd.ClosedTimestamp.Reset() + cmd.raftCmd.ClosedTimestamp = nil } else { // Assert that we're not writing under the closed timestamp. We can only do // these checks on IsIntentWrite requests, since others (for example, @@ -639,7 +639,7 @@ func (b *replicaAppBatch) runPreApplyTriggersAfterStagingWriteBatch( // // Alternatively if we discover that the RHS has already been removed // from this store, clean up its data. - splitPreApply(ctx, b.batch, res.Split.SplitTrigger, b.r, cmd.raftCmd.ClosedTimestamp) + splitPreApply(ctx, b.r, b.batch, res.Split.SplitTrigger, cmd.raftCmd.ClosedTimestamp) // The rangefeed processor will no longer be provided logical ops for // its entire range, so it needs to be shut down and all registrations @@ -823,13 +823,13 @@ func (b *replicaAppBatch) stageTrivialReplicatedEvalResult( if leaseAppliedIndex := cmd.leaseIndex; leaseAppliedIndex != 0 { b.state.LeaseAppliedIndex = leaseAppliedIndex } - if cts := cmd.raftCmd.ClosedTimestamp; !cts.IsEmpty() { + if cts := cmd.raftCmd.ClosedTimestamp; cts != nil && !cts.IsEmpty() { if cts.Less(b.state.ClosedTimestamp) { log.Fatalf(ctx, "closed timestamp regressing from %s to %s when applying command %x", b.state.ClosedTimestamp, cts, cmd.idKey) } - b.state.ClosedTimestamp = cts + b.state.ClosedTimestamp = *cts if clockTS, ok := cts.TryToClockTimestamp(); ok { b.maxTS.Forward(clockTS) } diff --git a/pkg/kv/kvserver/replica_proposal_buf_test.go b/pkg/kv/kvserver/replica_proposal_buf_test.go index 8b7df4c5c981..0fdf329f933d 100644 --- a/pkg/kv/kvserver/replica_proposal_buf_test.go +++ b/pkg/kv/kvserver/replica_proposal_buf_test.go @@ -716,7 +716,12 @@ func TestProposalBufferClosedTimestamp(t *testing.T) { type reqType int checkClosedTS := func(t *testing.T, r *testProposerRaft, exp hlc.Timestamp) { require.Len(t, r.lastProps, 1) - require.Equal(t, exp, r.lastProps[0].ClosedTimestamp) + if exp.IsEmpty() { + require.Nil(t, r.lastProps[0].ClosedTimestamp) + } else { + require.NotNil(t, r.lastProps[0].ClosedTimestamp) + require.Equal(t, exp, *r.lastProps[0].ClosedTimestamp) + } } // The lease that the proposals are made under. diff --git a/pkg/kv/kvserver/stateloader/stateloader.go b/pkg/kv/kvserver/stateloader/stateloader.go index a6610a807d39..a0da9c082c76 100644 --- a/pkg/kv/kvserver/stateloader/stateloader.go +++ b/pkg/kv/kvserver/stateloader/stateloader.go @@ -298,24 +298,23 @@ func (rsl StateLoader) LoadMVCCStats( // keys. We now deem those keys to be "legacy" because they have been replaced // by the range applied state key. // -// TODO(andrei): closedTimestamp is a pointer to avoid an allocation when -// putting it in RangeAppliedState. RangeAppliedState.ClosedTimestamp is made -// non-nullable (see comments on the field), this argument should be taken by -// value. +// TODO(andrei): closedTS is a pointer to avoid an allocation when putting it in +// RangeAppliedState. RangeAppliedState.ClosedTimestamp is made non-nullable +// (see comments on the field), this argument should be taken by value. func (rsl StateLoader) SetRangeAppliedState( ctx context.Context, readWriter storage.ReadWriter, appliedIndex, leaseAppliedIndex uint64, newMS *enginepb.MVCCStats, - closedTimestamp *hlc.Timestamp, + closedTS *hlc.Timestamp, ) error { as := enginepb.RangeAppliedState{ RaftAppliedIndex: appliedIndex, LeaseAppliedIndex: leaseAppliedIndex, RangeStats: newMS.ToPersistentStats(), } - if closedTimestamp != nil && !closedTimestamp.IsEmpty() { - as.ClosedTimestamp = closedTimestamp + if closedTS != nil && !closedTS.IsEmpty() { + as.ClosedTimestamp = closedTS } // The RangeAppliedStateKey is not included in stats. This is also reflected // in C.MVCCComputeStats and ComputeStatsForRange. @@ -498,7 +497,7 @@ func (rsl StateLoader) SetMVCCStats( // SetClosedTimestamp overwrites the closed timestamp. func (rsl StateLoader) SetClosedTimestamp( - ctx context.Context, readWriter storage.ReadWriter, closedTS hlc.Timestamp, + ctx context.Context, readWriter storage.ReadWriter, closedTS *hlc.Timestamp, ) error { as, err := rsl.LoadRangeAppliedState(ctx, readWriter) if err != nil { @@ -506,7 +505,7 @@ func (rsl StateLoader) SetClosedTimestamp( } return rsl.SetRangeAppliedState( ctx, readWriter, as.RaftAppliedIndex, as.LeaseAppliedIndex, - as.RangeStats.ToStatsPtr(), &closedTS) + as.RangeStats.ToStatsPtr(), closedTS) } // SetLegacyRaftTruncatedState overwrites the truncated state. diff --git a/pkg/kv/kvserver/store_split.go b/pkg/kv/kvserver/store_split.go index 7f8dccbfa3c4..9ec16989e7f7 100644 --- a/pkg/kv/kvserver/store_split.go +++ b/pkg/kv/kvserver/store_split.go @@ -30,11 +30,10 @@ import ( // split commit. func splitPreApply( ctx context.Context, + r *Replica, readWriter storage.ReadWriter, split roachpb.SplitTrigger, - r *Replica, - // The closed timestamp used to initialize the RHS. - closedTS hlc.Timestamp, + initClosedTS *hlc.Timestamp, ) { // Sanity check that the store is in the split. // @@ -123,7 +122,7 @@ func splitPreApply( } // Persist the closed timestamp. - if err := rsl.SetClosedTimestamp(ctx, readWriter, closedTS); err != nil { + if err := rsl.SetClosedTimestamp(ctx, readWriter, initClosedTS); err != nil { log.Fatalf(ctx, "%s", err) } From e46511aaf77d1c670837939d6e87a75bf9d58cbb Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Tue, 23 Feb 2021 01:59:57 -0500 Subject: [PATCH 2/2] kv/kvserverpb: rename RaftCommandFooter to MaxLeaseFooter Now that `ClosedTimestampFooter` exists, be more specific and symmetric. --- pkg/kv/kvserver/kvserverpb/proposer_kv.go | 10 +- pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go | 113 ++++++++++--------- pkg/kv/kvserver/kvserverpb/proposer_kv.proto | 13 ++- pkg/kv/kvserver/replica_proposal.go | 2 +- pkg/kv/kvserver/replica_proposal_buf_test.go | 2 +- pkg/kv/kvserver/replica_raft.go | 4 +- 6 files changed, 77 insertions(+), 67 deletions(-) diff --git a/pkg/kv/kvserver/kvserverpb/proposer_kv.go b/pkg/kv/kvserver/kvserverpb/proposer_kv.go index 14fc1ca2d064..801c05ceb86d 100644 --- a/pkg/kv/kvserver/kvserverpb/proposer_kv.go +++ b/pkg/kv/kvserver/kvserverpb/proposer_kv.go @@ -16,7 +16,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/hlc" ) -var maxRaftCommandFooterSize = (&RaftCommandFooter{ +var maxMaxLeaseFooterSize = (&MaxLeaseFooter{ MaxLeaseIndex: math.MaxUint64, }).Size() @@ -28,10 +28,10 @@ var maxClosedTimestampFooterSize = (&ClosedTimestampFooter{ }, }).Size() -// MaxRaftCommandFooterSize returns the maximum possible size of an -// encoded RaftCommandFooter proto. -func MaxRaftCommandFooterSize() int { - return maxRaftCommandFooterSize +// MaxMaxLeaseFooterSize returns the maximum possible size of an encoded +// MaxLeaseFooter proto. +func MaxMaxLeaseFooterSize() int { + return maxMaxLeaseFooterSize } // MaxClosedTimestampFooterSize returns the maximmum possible size of an encoded diff --git a/pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go b/pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go index 7b949c22bbb4..6e5a6185c5a2 100644 --- a/pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go +++ b/pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go @@ -48,7 +48,7 @@ func (m *Split) Reset() { *m = Split{} } func (m *Split) String() string { return proto.CompactTextString(m) } func (*Split) ProtoMessage() {} func (*Split) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{0} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{0} } func (m *Split) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -83,7 +83,7 @@ func (m *Merge) Reset() { *m = Merge{} } func (m *Merge) String() string { return proto.CompactTextString(m) } func (*Merge) ProtoMessage() {} func (*Merge) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{1} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{1} } func (m *Merge) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -117,7 +117,7 @@ type ChangeReplicas struct { func (m *ChangeReplicas) Reset() { *m = ChangeReplicas{} } func (*ChangeReplicas) ProtoMessage() {} func (*ChangeReplicas) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{2} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{2} } func (m *ChangeReplicas) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -169,7 +169,7 @@ func (m *ComputeChecksum) Reset() { *m = ComputeChecksum{} } func (m *ComputeChecksum) String() string { return proto.CompactTextString(m) } func (*ComputeChecksum) ProtoMessage() {} func (*ComputeChecksum) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{3} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{3} } func (m *ComputeChecksum) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -206,7 +206,7 @@ func (m *Compaction) Reset() { *m = Compaction{} } func (m *Compaction) String() string { return proto.CompactTextString(m) } func (*Compaction) ProtoMessage() {} func (*Compaction) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{4} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{4} } func (m *Compaction) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -243,7 +243,7 @@ func (m *SuggestedCompaction) Reset() { *m = SuggestedCompaction{} } func (m *SuggestedCompaction) String() string { return proto.CompactTextString(m) } func (*SuggestedCompaction) ProtoMessage() {} func (*SuggestedCompaction) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{5} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{5} } func (m *SuggestedCompaction) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -305,7 +305,7 @@ func (m *ReplicatedEvalResult) Reset() { *m = ReplicatedEvalResult{} } func (m *ReplicatedEvalResult) String() string { return proto.CompactTextString(m) } func (*ReplicatedEvalResult) ProtoMessage() {} func (*ReplicatedEvalResult) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{6} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{6} } func (m *ReplicatedEvalResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -349,7 +349,7 @@ func (m *ReplicatedEvalResult_AddSSTable) Reset() { *m = ReplicatedEvalR func (m *ReplicatedEvalResult_AddSSTable) String() string { return proto.CompactTextString(m) } func (*ReplicatedEvalResult_AddSSTable) ProtoMessage() {} func (*ReplicatedEvalResult_AddSSTable) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{6, 0} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{6, 0} } func (m *ReplicatedEvalResult_AddSSTable) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -386,7 +386,7 @@ func (m *WriteBatch) Reset() { *m = WriteBatch{} } func (m *WriteBatch) String() string { return proto.CompactTextString(m) } func (*WriteBatch) ProtoMessage() {} func (*WriteBatch) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{7} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{7} } func (m *WriteBatch) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -423,7 +423,7 @@ func (m *LogicalOpLog) Reset() { *m = LogicalOpLog{} } func (m *LogicalOpLog) String() string { return proto.CompactTextString(m) } func (*LogicalOpLog) ProtoMessage() {} func (*LogicalOpLog) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{8} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{8} } func (m *LogicalOpLog) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -506,7 +506,12 @@ type RaftCommand struct { // updated accordingly. Managing retry of proposals becomes trickier as // well as that uproots whatever ordering was originally envisioned. // - // This field is set through RaftCommandFooter hackery. + // This field is set through MaxLeaseFooter hackery. Unlike with the + // ClosedTimestamp, which needs to be nullable in this proto (see comment), + // there are no nullability concerns with this field. This is because + // max_lease_index is a primitive type, so it does not get encoded when zero. + // This alone ensures that the field is not encoded twice in the combined + // RaftCommand+MaxLeaseFooter proto. MaxLeaseIndex uint64 `protobuf:"varint,4,opt,name=max_lease_index,json=maxLeaseIndex,proto3" json:"max_lease_index,omitempty"` // The closed timestamp carried by this command. Once a follower is told to // apply this command, it knows that there will be no further writes at @@ -547,7 +552,7 @@ func (m *RaftCommand) Reset() { *m = RaftCommand{} } func (m *RaftCommand) String() string { return proto.CompactTextString(m) } func (*RaftCommand) ProtoMessage() {} func (*RaftCommand) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{9} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{9} } func (m *RaftCommand) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -572,26 +577,26 @@ func (m *RaftCommand) XXX_DiscardUnknown() { var xxx_messageInfo_RaftCommand proto.InternalMessageInfo -// RaftCommandFooter contains a subset of the fields in RaftCommand. It is used +// MaxLeaseFooter contains a subset of the fields in RaftCommand. It is used // to optimize a pattern where most of the fields in RaftCommand are marshaled // outside of a heavily contended critical section, except for the fields in the // footer, which are assigned and marhsaled inside of the critical section and // appended to the marshaled byte buffer. This minimizes the memory allocation // and marshaling work performed under lock. -type RaftCommandFooter struct { +type MaxLeaseFooter struct { MaxLeaseIndex uint64 `protobuf:"varint,4,opt,name=max_lease_index,json=maxLeaseIndex,proto3" json:"max_lease_index,omitempty"` } -func (m *RaftCommandFooter) Reset() { *m = RaftCommandFooter{} } -func (m *RaftCommandFooter) String() string { return proto.CompactTextString(m) } -func (*RaftCommandFooter) ProtoMessage() {} -func (*RaftCommandFooter) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{10} +func (m *MaxLeaseFooter) Reset() { *m = MaxLeaseFooter{} } +func (m *MaxLeaseFooter) String() string { return proto.CompactTextString(m) } +func (*MaxLeaseFooter) ProtoMessage() {} +func (*MaxLeaseFooter) Descriptor() ([]byte, []int) { + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{10} } -func (m *RaftCommandFooter) XXX_Unmarshal(b []byte) error { +func (m *MaxLeaseFooter) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *RaftCommandFooter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MaxLeaseFooter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { b = b[:cap(b)] n, err := m.MarshalTo(b) if err != nil { @@ -599,19 +604,19 @@ func (m *RaftCommandFooter) XXX_Marshal(b []byte, deterministic bool) ([]byte, e } return b[:n], nil } -func (dst *RaftCommandFooter) XXX_Merge(src proto.Message) { - xxx_messageInfo_RaftCommandFooter.Merge(dst, src) +func (dst *MaxLeaseFooter) XXX_Merge(src proto.Message) { + xxx_messageInfo_MaxLeaseFooter.Merge(dst, src) } -func (m *RaftCommandFooter) XXX_Size() int { +func (m *MaxLeaseFooter) XXX_Size() int { return m.Size() } -func (m *RaftCommandFooter) XXX_DiscardUnknown() { - xxx_messageInfo_RaftCommandFooter.DiscardUnknown(m) +func (m *MaxLeaseFooter) XXX_DiscardUnknown() { + xxx_messageInfo_MaxLeaseFooter.DiscardUnknown(m) } -var xxx_messageInfo_RaftCommandFooter proto.InternalMessageInfo +var xxx_messageInfo_MaxLeaseFooter proto.InternalMessageInfo -// ClosedTimestampFooter is similar to RaftCommandFooter, allowing the proposal +// ClosedTimestampFooter is similar to MaxLeaseFooter, allowing the proposal // buffer to fill in the closed_timestamp field after most of the proto has been // marshaled already. type ClosedTimestampFooter struct { @@ -625,7 +630,7 @@ func (m *ClosedTimestampFooter) Reset() { *m = ClosedTimestampFooter{} } func (m *ClosedTimestampFooter) String() string { return proto.CompactTextString(m) } func (*ClosedTimestampFooter) ProtoMessage() {} func (*ClosedTimestampFooter) Descriptor() ([]byte, []int) { - return fileDescriptor_proposer_kv_4be80e2a938c97b0, []int{11} + return fileDescriptor_proposer_kv_7221db15568d8c0d, []int{11} } func (m *ClosedTimestampFooter) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -663,7 +668,7 @@ func init() { proto.RegisterType((*LogicalOpLog)(nil), "cockroach.kv.kvserver.storagepb.LogicalOpLog") proto.RegisterType((*RaftCommand)(nil), "cockroach.kv.kvserver.storagepb.RaftCommand") proto.RegisterMapType((map[string]string)(nil), "cockroach.kv.kvserver.storagepb.RaftCommand.TraceDataEntry") - proto.RegisterType((*RaftCommandFooter)(nil), "cockroach.kv.kvserver.storagepb.RaftCommandFooter") + proto.RegisterType((*MaxLeaseFooter)(nil), "cockroach.kv.kvserver.storagepb.MaxLeaseFooter") proto.RegisterType((*ClosedTimestampFooter)(nil), "cockroach.kv.kvserver.storagepb.ClosedTimestampFooter") } func (this *Split) Equal(that interface{}) bool { @@ -1387,7 +1392,7 @@ func (m *RaftCommand) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *RaftCommandFooter) Marshal() (dAtA []byte, err error) { +func (m *MaxLeaseFooter) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -1397,7 +1402,7 @@ func (m *RaftCommandFooter) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *RaftCommandFooter) MarshalTo(dAtA []byte) (int, error) { +func (m *MaxLeaseFooter) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -1681,7 +1686,7 @@ func (m *RaftCommand) Size() (n int) { return n } -func (m *RaftCommandFooter) Size() (n int) { +func (m *MaxLeaseFooter) Size() (n int) { if m == nil { return 0 } @@ -3449,7 +3454,7 @@ func (m *RaftCommand) Unmarshal(dAtA []byte) error { } return nil } -func (m *RaftCommandFooter) Unmarshal(dAtA []byte) error { +func (m *MaxLeaseFooter) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3472,10 +3477,10 @@ func (m *RaftCommandFooter) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RaftCommandFooter: wiretype end group for non-group") + return fmt.Errorf("proto: MaxLeaseFooter: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RaftCommandFooter: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MaxLeaseFooter: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 4: @@ -3704,14 +3709,14 @@ var ( ) func init() { - proto.RegisterFile("kv/kvserver/kvserverpb/proposer_kv.proto", fileDescriptor_proposer_kv_4be80e2a938c97b0) + proto.RegisterFile("kv/kvserver/kvserverpb/proposer_kv.proto", fileDescriptor_proposer_kv_7221db15568d8c0d) } -var fileDescriptor_proposer_kv_4be80e2a938c97b0 = []byte{ - // 1459 bytes of a gzipped FileDescriptorProto +var fileDescriptor_proposer_kv_7221db15568d8c0d = []byte{ + // 1460 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x5f, 0x6f, 0x13, 0xc7, 0x16, 0x8f, 0x63, 0x3b, 0x59, 0x1f, 0x27, 0xf6, 0x66, 0x08, 0xb0, 0x37, 0xf7, 0x5e, 0x3b, 0xf2, - 0xe5, 0xa2, 0xdc, 0x5b, 0xba, 0x46, 0x49, 0x2b, 0x55, 0x80, 0x2a, 0x62, 0x07, 0x4a, 0x4c, 0x92, + 0xe5, 0xa2, 0xdc, 0x5b, 0xba, 0x46, 0x49, 0x2b, 0x21, 0x8a, 0x2a, 0x62, 0x07, 0x4a, 0x4c, 0x92, 0xc2, 0x38, 0xd0, 0x8a, 0x3e, 0xac, 0xc6, 0xbb, 0xc3, 0x7a, 0xeb, 0xb5, 0x77, 0xd9, 0x19, 0x1b, 0xf2, 0x29, 0xda, 0x4a, 0x95, 0xda, 0xa7, 0x96, 0xc7, 0x7e, 0x8d, 0xbe, 0xf1, 0xc8, 0x23, 0xea, 0x83, 0x55, 0xc2, 0x4b, 0x3f, 0x03, 0x4f, 0xd5, 0xcc, 0xce, 0xfa, 0x0f, 0x0a, 0x8d, 0xa1, 0x6f, @@ -3729,7 +3734,7 @@ var fileDescriptor_proposer_kv_4be80e2a938c97b0 = []byte{ 0xcf, 0x87, 0xe5, 0x14, 0x4e, 0x34, 0xd1, 0x21, 0xe4, 0xa2, 0x36, 0xb3, 0x1c, 0xea, 0x73, 0x62, 0xcc, 0x4b, 0x98, 0xff, 0x4e, 0xc0, 0xa8, 0xeb, 0x99, 0xc9, 0xf5, 0xcc, 0xfd, 0xfb, 0xf5, 0x7a, 0x93, 0x13, 0xce, 0x6a, 0xba, 0x00, 0x3b, 0x1e, 0x96, 0x35, 0x7c, 0xab, 0xb9, 0x23, 0xd4, 0xb1, - 0x16, 0xb5, 0x99, 0x5c, 0x5d, 0xc9, 0xfc, 0xf1, 0xb4, 0x9c, 0xaa, 0x60, 0xc8, 0xee, 0xd3, 0xc8, + 0x16, 0xb5, 0x99, 0x5c, 0x5d, 0xcd, 0xfc, 0xf1, 0xb4, 0x9c, 0xaa, 0x60, 0xc8, 0xee, 0xd3, 0xc8, 0xa5, 0xb3, 0x79, 0x2a, 0x8f, 0xbe, 0xdd, 0x53, 0x85, 0xe9, 0x40, 0xa1, 0xde, 0x26, 0x3d, 0x97, 0x62, 0x1a, 0xfa, 0x9e, 0x4d, 0x18, 0xda, 0x7b, 0x13, 0x7c, 0xe3, 0x04, 0xf0, 0x69, 0x9d, 0xbf, 0xb2, 0xf2, 0xe3, 0xd3, 0xf2, 0x5c, 0xe5, 0xe5, 0x3c, 0x14, 0xeb, 0x41, 0x37, 0xec, 0x73, 0x5a, @@ -3783,22 +3788,22 @@ var fileDescriptor_proposer_kv_4be80e2a938c97b0 = []byte{ 0xc1, 0xcb, 0x5d, 0xf2, 0x44, 0x66, 0x63, 0x57, 0x08, 0xd1, 0x21, 0xfc, 0x63, 0xa2, 0x53, 0x47, 0xef, 0x46, 0xa9, 0x27, 0x67, 0x5b, 0x7e, 0xd3, 0x38, 0x61, 0x7e, 0xc5, 0x84, 0x71, 0x7e, 0xac, 0x7a, 0x47, 0x69, 0xca, 0x0d, 0x34, 0x80, 0xf3, 0xd3, 0x50, 0x16, 0x13, 0xe4, 0xd2, 0xb3, 0xa9, - 0xe4, 0x9c, 0x74, 0xed, 0xd3, 0xd7, 0xc3, 0xf2, 0x95, 0x77, 0x1a, 0x01, 0x12, 0xb8, 0xa9, 0x50, + 0xe4, 0x9c, 0x74, 0xed, 0xd3, 0xd7, 0xc3, 0xf2, 0xd5, 0x77, 0x1a, 0x01, 0x12, 0xb8, 0xa9, 0x50, 0xf0, 0xd9, 0x70, 0xd2, 0x5e, 0x22, 0x46, 0x8f, 0xe0, 0x5c, 0x34, 0xea, 0x38, 0x8b, 0x0e, 0x88, 0x6f,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d, 0x7a, 0xf6, 0xb2, 0x34, 0xf7, + 0xec, 0xb8, 0x94, 0x7a, 0x7e, 0x5c, 0x4a, 0xbd, 0x38, 0x2e, 0xa5, 0x7e, 0x3f, 0x2e, 0xa5, 0xbe, + 0x7d, 0x55, 0x9a, 0x7b, 0xfe, 0xaa, 0x34, 0xf7, 0xe2, 0x55, 0x69, 0xee, 0x01, 0x8c, 0xff, 0x8b, + 0x5a, 0x0b, 0xf2, 0x17, 0x67, 0xeb, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x05, 0x7f, 0x93, 0xe3, + 0xfd, 0x0d, 0x00, 0x00, } diff --git a/pkg/kv/kvserver/kvserverpb/proposer_kv.proto b/pkg/kv/kvserver/kvserverpb/proposer_kv.proto index 391588572755..f0a7e355cc90 100644 --- a/pkg/kv/kvserver/kvserverpb/proposer_kv.proto +++ b/pkg/kv/kvserver/kvserverpb/proposer_kv.proto @@ -241,7 +241,12 @@ message RaftCommand { // updated accordingly. Managing retry of proposals becomes trickier as // well as that uproots whatever ordering was originally envisioned. // - // This field is set through RaftCommandFooter hackery. + // This field is set through MaxLeaseFooter hackery. Unlike with the + // ClosedTimestamp, which needs to be nullable in this proto (see comment), + // there are no nullability concerns with this field. This is because + // max_lease_index is a primitive type, so it does not get encoded when zero. + // This alone ensures that the field is not encoded twice in the combined + // RaftCommand+MaxLeaseFooter proto. uint64 max_lease_index = 4; // The closed timestamp carried by this command. Once a follower is told to @@ -287,17 +292,17 @@ message RaftCommand { reserved 1, 2, 10001 to 10014; } -// RaftCommandFooter contains a subset of the fields in RaftCommand. It is used +// MaxLeaseFooter contains a subset of the fields in RaftCommand. It is used // to optimize a pattern where most of the fields in RaftCommand are marshaled // outside of a heavily contended critical section, except for the fields in the // footer, which are assigned and marhsaled inside of the critical section and // appended to the marshaled byte buffer. This minimizes the memory allocation // and marshaling work performed under lock. -message RaftCommandFooter { +message MaxLeaseFooter { uint64 max_lease_index = 4; } -// ClosedTimestampFooter is similar to RaftCommandFooter, allowing the proposal +// ClosedTimestampFooter is similar to MaxLeaseFooter, allowing the proposal // buffer to fill in the closed_timestamp field after most of the proto has been // marshaled already. message ClosedTimestampFooter { diff --git a/pkg/kv/kvserver/replica_proposal.go b/pkg/kv/kvserver/replica_proposal.go index 5ccc84b1025f..c170a2c6cc17 100644 --- a/pkg/kv/kvserver/replica_proposal.go +++ b/pkg/kv/kvserver/replica_proposal.go @@ -81,7 +81,7 @@ type ProposalData struct { quotaAlloc *quotapool.IntAlloc // tmpFooter is used to avoid an allocation. - tmpFooter kvserverpb.RaftCommandFooter + tmpFooter kvserverpb.MaxLeaseFooter // ec.done is called after command application to update the timestamp // cache and optionally release latches and exits lock wait-queues. diff --git a/pkg/kv/kvserver/replica_proposal_buf_test.go b/pkg/kv/kvserver/replica_proposal_buf_test.go index 0fdf329f933d..62de4020aeae 100644 --- a/pkg/kv/kvserver/replica_proposal_buf_test.go +++ b/pkg/kv/kvserver/replica_proposal_buf_test.go @@ -219,7 +219,7 @@ func (pc proposalCreator) newProposal(ba roachpb.BatchRequest) (*ProposalData, [ func (pc proposalCreator) encodeProposal(p *ProposalData) []byte { cmdLen := p.command.Size() needed := raftCommandPrefixLen + cmdLen + - kvserverpb.MaxRaftCommandFooterSize() + + kvserverpb.MaxMaxLeaseFooterSize() + kvserverpb.MaxClosedTimestampFooterSize() data := make([]byte, raftCommandPrefixLen, needed) encodeRaftCommandPrefix(data, raftVersionStandard, p.idKey) diff --git a/pkg/kv/kvserver/replica_raft.go b/pkg/kv/kvserver/replica_raft.go index 2568c9b44158..e1ffbafea801 100644 --- a/pkg/kv/kvserver/replica_raft.go +++ b/pkg/kv/kvserver/replica_raft.go @@ -261,7 +261,7 @@ func (r *Replica) propose( // Make sure the maximum lease index is unset. This field will be set in // propBuf.Insert and its encoded bytes will be appended to the encoding - // buffer as a RaftCommandFooter. + // buffer as a MaxLeaseFooter. p.command.MaxLeaseIndex = 0 // Determine the encoding style for the Raft command. @@ -320,7 +320,7 @@ func (r *Replica) propose( // Allocate the data slice with enough capacity to eventually hold the two // "footers" that are filled later. needed := preLen + cmdLen + - kvserverpb.MaxRaftCommandFooterSize() + + kvserverpb.MaxMaxLeaseFooterSize() + kvserverpb.MaxClosedTimestampFooterSize() data := make([]byte, preLen, needed) // Encode prefix with command ID, if necessary.