From 3593a8e92c371703ac5a5349fcd71269b0ced806 Mon Sep 17 00:00:00 2001 From: Alex Robinson Date: Mon, 8 Jan 2018 10:56:39 -0500 Subject: [PATCH] storage: Omit empty fields from rangelog json This shrinks the size of the info field in rangelog entries. gogoproto automatically adds the omitempty json tag for all proto3 fields (that aren't explicitly marked as nullable with a gogoproto tag), but it can't do so if the user specifies a custom jsontag. I don't know for sure why we initially added these, but now I can't remove them without messing up backwards compatibility with the old json field names, so just add the necessary omitempty annotations. Helps with range log size as related to #21260. Release note (sql change): Reduced size of entries stored in the system.rangelog table by not storing empty JSON fields. --- pkg/storage/log.pb.go | 90 ++++++++++++++++++++++--------------------- pkg/storage/log.proto | 12 +++--- 2 files changed, 52 insertions(+), 50 deletions(-) diff --git a/pkg/storage/log.pb.go b/pkg/storage/log.pb.go index 8345f6ba19b1..fca096dc3319 100644 --- a/pkg/storage/log.pb.go +++ b/pkg/storage/log.pb.go @@ -65,12 +65,12 @@ func (*RangeLogEvent) ProtoMessage() {} func (*RangeLogEvent) Descriptor() ([]byte, []int) { return fileDescriptorLog, []int{0} } type RangeLogEvent_Info struct { - UpdatedDesc *cockroach_roachpb.RangeDescriptor `protobuf:"bytes,1,opt,name=updated_desc,json=updatedDesc" json:"UpdatedDesc"` - NewDesc *cockroach_roachpb.RangeDescriptor `protobuf:"bytes,2,opt,name=new_desc,json=newDesc" json:"NewDesc"` - AddedReplica *cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,3,opt,name=added_replica,json=addedReplica" json:"AddReplica"` - RemovedReplica *cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,4,opt,name=removed_replica,json=removedReplica" json:"RemovedReplica"` - Reason RangeLogEventReason `protobuf:"bytes,5,opt,name=reason,proto3,casttype=RangeLogEventReason" json:"Reason"` - Details string `protobuf:"bytes,6,opt,name=details,proto3" json:"Details"` + UpdatedDesc *cockroach_roachpb.RangeDescriptor `protobuf:"bytes,1,opt,name=updated_desc,json=updatedDesc" json:"UpdatedDesc,omitempty"` + NewDesc *cockroach_roachpb.RangeDescriptor `protobuf:"bytes,2,opt,name=new_desc,json=newDesc" json:"NewDesc,omitempty"` + AddedReplica *cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,3,opt,name=added_replica,json=addedReplica" json:"AddReplica,omitempty"` + RemovedReplica *cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,4,opt,name=removed_replica,json=removedReplica" json:"RemovedReplica,omitempty"` + Reason RangeLogEventReason `protobuf:"bytes,5,opt,name=reason,proto3,casttype=RangeLogEventReason" json:"Reason,omitempty"` + Details string `protobuf:"bytes,6,opt,name=details,proto3" json:"Details,omitempty"` } func (m *RangeLogEvent_Info) Reset() { *m = RangeLogEvent_Info{} } @@ -822,42 +822,44 @@ var ( func init() { proto.RegisterFile("storage/log.proto", fileDescriptorLog) } var fileDescriptorLog = []byte{ - // 589 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0x86, 0xe3, 0xdc, 0x9c, 0x4c, 0xd2, 0x34, 0x19, 0x10, 0x8a, 0xb2, 0xf0, 0xa4, 0x15, 0x95, - 0x22, 0x16, 0xb6, 0xd4, 0xb2, 0xe9, 0x12, 0x37, 0x48, 0x04, 0x21, 0x90, 0x86, 0x82, 0x04, 0x0b, - 0xa2, 0x89, 0x67, 0xe2, 0x58, 0x4d, 0x3c, 0x96, 0x3d, 0x69, 0xd5, 0xb7, 0xe8, 0x63, 0x45, 0xac, - 0xba, 0x64, 0x65, 0xc0, 0xec, 0xf2, 0x08, 0x5d, 0x21, 0xcf, 0x38, 0x37, 0x75, 0xc1, 0xa5, 0xbb, - 0x73, 0xfd, 0x7c, 0xe6, 0x3f, 0xc7, 0xa0, 0x15, 0x09, 0x1e, 0x12, 0x97, 0x59, 0x53, 0xee, 0x9a, - 0x41, 0xc8, 0x05, 0x87, 0x2d, 0x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0x34, 0xc2, 0x1d, 0x1f, 0x9e, 0x82, 0x72, 0xc8, 0x48, 0xc4, 0x7d, 0x79, 0x0d, - 0x55, 0xfb, 0x60, 0x19, 0xa3, 0x32, 0x96, 0x91, 0xbb, 0x18, 0x3d, 0xda, 0x59, 0x91, 0x0a, 0xe3, - 0xac, 0x01, 0x1e, 0x01, 0x9d, 0x32, 0x41, 0xbc, 0x69, 0x24, 0x77, 0x5c, 0x55, 0xfa, 0xf4, 0x55, - 0x08, 0xaf, 0x72, 0xcf, 0x4e, 0x40, 0xeb, 0xde, 0x5d, 0xc2, 0x2a, 0x28, 0x45, 0xc1, 0xd4, 0x13, - 0xcd, 0x1c, 0xd4, 0x41, 0x81, 0x50, 0xda, 0xd4, 0x20, 0x48, 0x47, 0x49, 0x87, 0x6b, 0xe6, 0xed, - 0x83, 0xc5, 0x4f, 0x23, 0xb7, 0x48, 0x0c, 0xed, 0x36, 0x31, 0xb4, 0x6f, 0x89, 0xa1, 0xfd, 0x48, - 0x0c, 0xed, 0xe6, 0x97, 0x91, 0xfb, 0xac, 0x67, 0xd7, 0x33, 0x2a, 0xcb, 0xbf, 0xff, 0xe4, 0x77, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x12, 0xfe, 0xcf, 0x8a, 0xa8, 0x04, 0x00, 0x00, + // 610 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0x4d, 0x6f, 0xd3, 0x4c, + 0x10, 0xc7, 0xe3, 0x36, 0xad, 0x93, 0x6d, 0x9a, 0x27, 0xd9, 0xa7, 0x45, 0x26, 0x42, 0xde, 0x50, + 0x81, 0x14, 0x01, 0xb2, 0xa5, 0x96, 0x0b, 0x47, 0x9c, 0x20, 0x11, 0x09, 0x81, 0x64, 0xc2, 0x85, + 0x03, 0x61, 0xe3, 0xdd, 0x38, 0x56, 0x62, 0xaf, 0x65, 0x6f, 0x5a, 0xe5, 0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+ 0x00, 0x00, } diff --git a/pkg/storage/log.proto b/pkg/storage/log.proto index fb45a5f18198..22ddd83ee9af 100644 --- a/pkg/storage/log.proto +++ b/pkg/storage/log.proto @@ -33,15 +33,15 @@ enum RangeLogEventType { message RangeLogEvent { message Info { - roachpb.RangeDescriptor updated_desc = 1 [(gogoproto.jsontag) = "UpdatedDesc"]; - roachpb.RangeDescriptor new_desc = 2 [(gogoproto.jsontag) = "NewDesc"]; - roachpb.ReplicaDescriptor added_replica = 3 [(gogoproto.jsontag) = "AddReplica"]; - roachpb.ReplicaDescriptor removed_replica = 4 [(gogoproto.jsontag) = "RemovedReplica"]; + roachpb.RangeDescriptor updated_desc = 1 [(gogoproto.jsontag) = "UpdatedDesc,omitempty"]; + roachpb.RangeDescriptor new_desc = 2 [(gogoproto.jsontag) = "NewDesc,omitempty"]; + roachpb.ReplicaDescriptor added_replica = 3 [(gogoproto.jsontag) = "AddReplica,omitempty"]; + roachpb.ReplicaDescriptor removed_replica = 4 [(gogoproto.jsontag) = "RemovedReplica,omitempty"]; string reason = 5 [ - (gogoproto.jsontag) = "Reason", + (gogoproto.jsontag) = "Reason,omitempty", (gogoproto.casttype) = "RangeLogEventReason" ]; - string details = 6 [(gogoproto.jsontag) = "Details"]; + string details = 6 [(gogoproto.jsontag) = "Details,omitempty"]; } google.protobuf.Timestamp timestamp = 1 [