Skip to content

Commit

Permalink
storage: Omit empty fields from rangelog json
Browse files Browse the repository at this point in the history
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 cockroachdb#21260.

Release note (sql change): Reduced size of entries stored in the
system.rangelog table by not storing empty JSON fields.
  • Loading branch information
a-robinson committed Jan 8, 2018
1 parent 742b93b commit 3593a8e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 50 deletions.
90 changes: 46 additions & 44 deletions pkg/storage/log.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pkg/storage/log.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down

0 comments on commit 3593a8e

Please sign in to comment.