github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/config/zonepb/zone.proto (about)

     1  // Copyright 2015 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  syntax = "proto2";
    12  package cockroach.config.zonepb;
    13  option go_package = "zonepb";
    14  
    15  import "gogoproto/gogo.proto";
    16  
    17  // GCPolicy defines garbage collection policies which apply to MVCC
    18  // values within a zone.
    19  //
    20  // TODO(spencer): flesh this out to include maximum number of values
    21  //   as well as whether there's an intersection between max values
    22  //   and TTL or a union.
    23  message GCPolicy {
    24    option (gogoproto.equal) = true;
    25    option (gogoproto.populate) = true;
    26  
    27    // TTLSeconds specifies the maximum age of a value before it's
    28    // garbage collected. Only older versions of values are garbage
    29    // collected. Specifying <=0 mean older versions are never GC'd.
    30    optional int32 ttl_seconds = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "TTLSeconds"];
    31  }
    32  
    33  // Constraint constrains the stores a replica can be stored on.
    34  message Constraint {
    35    option (gogoproto.equal) = true;
    36    option (gogoproto.goproto_stringer) = false;
    37    option (gogoproto.populate) = true;
    38  
    39    enum Type {
    40      // DEPRECATED_POSITIVE has no effect on a replica's placement.
    41      DEPRECATED_POSITIVE = 0;
    42      // REQUIRED ensures all replicas are placed on stores that match the
    43      // constraint. Replication will fail if there aren't any such stores.
    44      REQUIRED = 1;
    45      // PROHIBITED will prevent replicas from having this key, value.
    46      PROHIBITED = 2;
    47    }
    48    optional Type type = 1 [(gogoproto.nullable) = false];
    49    // Key is only set if this is a constraint on locality.
    50    optional string key = 2 [(gogoproto.nullable) = false];
    51    // Value to constrain to.
    52    optional string value = 3 [(gogoproto.nullable) = false];
    53  }
    54  
    55  // ConstraintsConjunction is a set of constraints that need to be satisfied
    56  // together by a replica (i.e. by the replica's store).
    57  message ConstraintsConjunction {
    58    option (gogoproto.equal) = true;
    59    option (gogoproto.goproto_stringer) = false;
    60    option (gogoproto.populate) = true;
    61  
    62    // The number of replicas that should abide by the constraints below. If left
    63    // unspecified (i.e. set to 0), the constraints will apply to all replicas of
    64    // the range.
    65    // As of v2.0, only REQUIRED constraints are allowed when num_replicas is
    66    // set to a non-zero value.
    67    optional int32 num_replicas = 7 [(gogoproto.nullable) = false];
    68  
    69    // The set of attributes and/or localities that need to be satisfied by the
    70    // store.
    71    repeated Constraint constraints = 6 [(gogoproto.nullable) = false];
    72  }
    73  
    74  // LeasePreference specifies a preference about where range leases should be
    75  // located.
    76  message LeasePreference {
    77    option (gogoproto.equal) = true;
    78    option (gogoproto.populate) = true;
    79  
    80    repeated Constraint constraints = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"constraints,flow\""];
    81  }
    82  
    83  // ZoneConfig holds configuration that applies to one or more ranges.
    84  //
    85  // Note: when adding.removing fields here, be sure to update
    86  // supportedZoneConfigOptions in the sql package, to synchronize
    87  // with the code for ALTER ... CONFIGURE ZONE.
    88  message ZoneConfig {
    89    option (gogoproto.equal) = true;
    90    option (gogoproto.populate) = true;
    91  
    92    reserved 1;
    93    optional int64 range_min_bytes = 2 [(gogoproto.moretags) = "yaml:\"range_min_bytes\""];
    94    optional int64 range_max_bytes = 3 [(gogoproto.moretags) = "yaml:\"range_max_bytes\""];
    95    // If GC policy is not set, uses the next highest, non-null policy
    96    // in the zone config hierarchy, up to the default policy if necessary.
    97    optional GCPolicy gc = 4 [(gogoproto.customname) = "GC"];
    98    // NumReplicas specifies the desired number of replicas
    99    optional int32 num_replicas = 5 [(gogoproto.moretags) = "yaml:\"num_replicas\""];
   100    // Constraints constrains which stores the replicas can be stored on. The
   101    // order in which the constraints are stored is arbitrary and may change.
   102    // https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/20160706_expressive_zone_config.md#constraint-system
   103    //
   104    // NOTE: The sum of the num_replicas fields of the Constraints must add up to
   105    // ZoneConfig.num_replicas, or there must be no more than a single Constraints
   106    // field with num_replicas set to 0.
   107    repeated ConstraintsConjunction constraints = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"constraints,flow\""];
   108  
   109    // InheritedContraints specifies if the value in the Constraints field was
   110    // inherited from the zone's parent or specified explicitly by the user.
   111    optional bool inherited_constraints = 10 [(gogoproto.nullable) = false];
   112  
   113    // LeasePreference stores information about where the user would prefer for
   114    // range leases to be placed. Leases are allowed to be placed elsewhere if
   115    // needed, but will follow the provided preference when possible.
   116    //
   117    // More than one lease preference is allowed, but they should be ordered from
   118    // most preferred to lease preferred. The first preference that an existing
   119    // replica of a range matches will take priority.
   120    repeated LeasePreference lease_preferences = 9 [(gogoproto.nullable) = false,
   121             (gogoproto.moretags) = "yaml:\"lease_preferences,flow\""];
   122  
   123    // InheritedLeasePreferences specifies if the value in the LeasePreferences field
   124    // was inherited from the zone's parent or specified explicitly by the user.
   125    optional bool inherited_lease_preferences = 11 [(gogoproto.nullable) = false];
   126  
   127    // Subzones stores config overrides for "subzones", each of which represents
   128    // either a SQL table index or a partition of a SQL table index. Subzones are
   129    // not applicable when the zone does not represent a SQL table (i.e., when the
   130    // zone represents a database, a special system range, or is itself a
   131    // subzone.)
   132    repeated Subzone subzones = 8 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"-\""];
   133  
   134    // SubzoneSpans maps each key span in a subzone to the slice index of an entry
   135    // in SubzoneConfig. Spans are non-overlapping and sorted by start key to
   136    // allow binary searching. SubzoneSpans can be easily derived from a
   137    // TableDescriptor, but are denormalized here to make GetZoneConfigForKey
   138    // lookups efficient.
   139    repeated SubzoneSpan subzone_spans = 7 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"-\""];
   140  }
   141  
   142  message Subzone {
   143    option (gogoproto.equal) = true;
   144    option (gogoproto.populate) = true;
   145  
   146    // IndexID is the ID of the SQL table index that the subzone represents.
   147    // Always set.
   148    optional uint32 index_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "IndexID"];
   149  
   150    // PartitionName is the partition of the SQL table index that the subzone
   151    // represents. It is empty when the subzone represents the entire index.
   152    optional string partition_name = 2 [(gogoproto.nullable) = false];
   153  
   154    // Config stores the ZoneConfig that applies to this Subzone. It never
   155    // contains nested subzones.
   156    optional ZoneConfig config = 3 [(gogoproto.nullable) = false];
   157  }
   158  
   159  message SubzoneSpan {
   160    option (gogoproto.equal) = true;
   161    option (gogoproto.populate) = true;
   162  
   163    // Key stores a key suffix that represents the inclusive lower bound for this
   164    // span. The SQL table prefix, like /Table/51/, is omitted.
   165    //
   166    // Both Key and EndKey, below, are cast to roachpb.Key for convenience, but
   167    // there's no technical restriction that prevents switching them to []byte or
   168    // another type that communicates their missing prefix.
   169    optional bytes key = 1 [(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.Key"];
   170  
   171    // EndKey stores a key suffix that represents the exclusive upper bound for
   172    // this span. Like with Key, the SQL table prefix is omitted. If EndKey is
   173    // empty, it is assumed to be Key.PrefixEnd().
   174    optional bytes end_key = 2 [(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.Key"];
   175  
   176    // SubzoneIndex is the slice index of the Subzone this span belongs to in the
   177    // parent ZoneConfig's Subzones field.
   178    optional int32 subzone_index = 3 [(gogoproto.nullable) = false];
   179  }