vitess.io/vitess@v0.16.2/proto/topodata.proto (about)

     1  /*
     2  Copyright 2019 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  // This file contains the Vitess topology related data structures.
    18  // Very few of these structures are exchanged over the wire (only
    19  // TabletType and KeyRange), but they are all used by the topology
    20  // service.
    21  
    22  syntax = "proto3";
    23  option go_package = "vitess.io/vitess/go/vt/proto/topodata";
    24  
    25  option java_package="io.vitess.proto";
    26  
    27  package topodata;
    28  
    29  import "vttime.proto";
    30  
    31  // KeyRange describes a range of sharding keys, when range-based
    32  // sharding is used.
    33  message KeyRange {
    34    bytes start = 1;
    35    bytes end = 2;
    36  }
    37  
    38  // KeyspaceType describes the type of the keyspace
    39  enum KeyspaceType {
    40    // NORMAL is the default value
    41    NORMAL = 0;
    42  
    43    // SNAPSHOT is when we are creating a snapshot keyspace
    44    SNAPSHOT = 1;
    45  }
    46  
    47  // TabletAlias is a globally unique tablet identifier.
    48  message TabletAlias {
    49    // cell is the cell (or datacenter) the tablet is in
    50    string cell = 1;
    51  
    52    // uid is a unique id for this tablet within the shard
    53    // (this is the MySQL server id as well).
    54    uint32 uid = 2;
    55  }
    56  
    57  // TabletType represents the type of a given tablet.
    58  enum TabletType {
    59    option allow_alias = true; // so we can have RDONLY and BATCH co-exist
    60  
    61    // UNKNOWN is not a valid value.
    62    UNKNOWN = 0;
    63  
    64    // PRIMARY is the primary server for the shard. Only PRIMARY allows DMLs.
    65    PRIMARY = 1;
    66  
    67    // DEPRECATED
    68    MASTER = 1;
    69  
    70    // REPLICA replicates from primary. It is used to serve live traffic.
    71    // A REPLICA can be promoted to PRIMARY. A demoted PRIMARY will go to REPLICA.
    72    REPLICA = 2;
    73  
    74    // RDONLY (old name) / BATCH (new name) is used to serve traffic for
    75    // long-running jobs. It is a separate type from REPLICA so
    76    // long-running queries don't affect web-like traffic.
    77    RDONLY = 3;
    78    BATCH = 3;
    79  
    80    // SPARE is a type of servers that cannot serve queries, but is available
    81    // in case an extra server is needed.
    82    SPARE = 4;
    83  
    84    // EXPERIMENTAL is like SPARE, except it can serve queries. This
    85    // type can be used for usages not planned by Vitess, like online
    86    // export to another storage engine.
    87    EXPERIMENTAL = 5;
    88  
    89    // BACKUP is the type a server goes to when taking a backup. No queries
    90    // can be served in BACKUP mode.
    91    BACKUP = 6;
    92  
    93    // RESTORE is the type a server uses when restoring a backup, at
    94    // startup time.  No queries can be served in RESTORE mode.
    95    RESTORE = 7;
    96  
    97    // DRAINED is the type a server goes into when used by Vitess tools
    98    // to perform an offline action. It is a serving type (as
    99    // the tools processes may need to run queries), but it's not used
   100    // to route queries from Vitess users. In this state,
   101    // this tablet is dedicated to the process that uses it.
   102    DRAINED = 8;
   103  }
   104  
   105  // Tablet represents information about a running instance of vttablet.
   106  message Tablet {
   107    // alias is the unique name of the tablet.
   108    TabletAlias alias = 1;
   109  
   110    // Fully qualified domain name of the host.
   111    string hostname = 2;
   112  
   113    // Map of named ports. Normally this should include vt and grpc.
   114    // Going forward, the mysql port will be stored in mysql_port
   115    // instead of here.
   116    // For accessing mysql port, use topoproto.MysqlPort to fetch, and
   117    // topoproto.SetMysqlPort to set. These wrappers will ensure
   118    // legacy behavior is supported.
   119    map<string, int32> port_map = 4;
   120  
   121    // Keyspace name.
   122    string keyspace = 5;
   123  
   124    // Shard name. If range based sharding is used, it should match
   125    // key_range.
   126    string shard = 6;
   127  
   128    // If range based sharding is used, range for the tablet's shard.
   129    KeyRange key_range = 7;
   130  
   131    // type is the current type of the tablet.
   132    TabletType type = 8;
   133  
   134    // It this is set, it is used as the database name instead of the
   135    // normal "vt_" + keyspace.
   136    string db_name_override = 9;
   137  
   138    // tablet tags
   139    map<string, string> tags = 10;
   140  
   141    // MySQL hostname.
   142    string mysql_hostname = 12;
   143  
   144    // MySQL port. Use topoproto.MysqlPort and topoproto.SetMysqlPort
   145    // to access this variable. The functions provide support
   146    // for legacy behavior.
   147    int32 mysql_port = 13;
   148  
   149    // primary_term_start_time is the time (in UTC) at which the current term of
   150    // the current tablet began as primary. If this tablet is not currently the
   151    // primary, this value is ignored.
   152    //
   153    // A new primary term begins any time an authoritative decision is communicated
   154    // about which tablet should be the primary, such as via Vitess
   155    // replication-management commands like PlannedReparentShard,
   156    // EmergencyReparentShard, and TabletExternallyReparented.
   157    //
   158    vttime.Time primary_term_start_time = 14;
   159  
   160    // db_server_version represents the database version used by the tablet.
   161    string db_server_version = 15;
   162  
   163    // default_conn_collation is the default connection collation used by this tablet.
   164    uint32 default_conn_collation = 16;
   165  
   166    // OBSOLETE: ip and tablet health information
   167    // string ip = 3;
   168    // map<string, string> health_map = 11;
   169    reserved 3, 11;
   170  }
   171  
   172  // A Shard contains data about a subset of the data whithin a keyspace.
   173  message Shard {
   174    // primary_alias is the tablet alias of the primary for the shard.
   175    // If it is unset, then there is no primary in this shard yet.
   176    // No lock is necessary to update this field, when for instance
   177    // TabletExternallyReparented updates this. However, we lock the
   178    // shard for reparenting operations (InitShardPrimary,
   179    // PlannedReparentShard,EmergencyReparentShard), to guarantee
   180    // exclusive operation.
   181    TabletAlias primary_alias = 1;
   182  
   183    // primary_term_start_time is the time (in UTC) at which the current term of
   184    // the primary specified in primary_alias began.
   185    //
   186    // A new primary term begins any time an authoritative decision is communicated
   187    // about which tablet should be the primary, such as via Vitess
   188    // replication-management commands like PlannedReparentShard,
   189    // EmergencyReparentShard, and TabletExternallyReparented.
   190    //
   191    // The primary_alias should only ever be changed if the new primary's term began
   192    // at a later time than this. Note that a new term can start for the tablet
   193    // that is already the primary. In that case, the primary_term_start_time would
   194    // be increased without changing the primary_alias.
   195    vttime.Time primary_term_start_time = 8;
   196  
   197    // key_range is the KeyRange for this shard. It can be unset if:
   198    // - we are not using range-based sharding in this shard.
   199    // - the shard covers the entire keyrange.
   200    // This must match the shard name based on our other conventions, but
   201    // helpful to have it decomposed here.
   202    // Once set at creation time, it is never changed.
   203    KeyRange key_range = 2;
   204  
   205    // Deprecated: served_types = 3
   206    reserved 3;
   207  
   208    // SourceShard represents a data source for filtered replication
   209    // across shards. When this is used in a destination shard, the primary
   210    // of that shard will run filtered replication.
   211    message SourceShard {
   212      // Uid is the unique ID for this SourceShard object.
   213      uint32 uid = 1;
   214  
   215      // the source keyspace
   216      string keyspace = 2;
   217  
   218      // the source shard
   219      string shard = 3;
   220  
   221      // the source shard keyrange
   222      KeyRange key_range = 4;
   223  
   224      // the source table list to replicate
   225      repeated string tables = 5;
   226    }
   227  
   228    // SourceShards is the list of shards we're replicating from,
   229    // using filtered replication.
   230    // The keyspace lock is always taken when changing this.
   231    repeated SourceShard source_shards = 4;
   232  
   233    // TabletControl controls tablet's behavior
   234    message TabletControl {
   235      // which tablet type is affected
   236      TabletType tablet_type = 1;
   237      repeated string cells = 2;
   238  
   239      // OBSOLETE: disable_query_service 3
   240      reserved 3;
   241  
   242      repeated string denied_tables = 4;
   243  
   244      // frozen is set if we've started failing over traffic for
   245      // the primary. If set, this record should not be removed.
   246      bool frozen = 5;
   247    }
   248  
   249    // tablet_controls has at most one entry per TabletType.
   250    // The keyspace lock is always taken when changing this.
   251    repeated TabletControl tablet_controls = 6;
   252  
   253    // is_primary_serving sets whether this shard primary is serving traffic or not.
   254    // The keyspace lock is always taken when changing this.
   255    bool is_primary_serving = 7;
   256  
   257    // OBSOLETE cells (5)
   258    reserved 5;
   259  }
   260  
   261  // A Keyspace contains data about a keyspace.
   262  message Keyspace {
   263    // OBSOLETE string sharding_column_name = 1;
   264    reserved 1;
   265  
   266    // OBSOLETE KeyspaceIdType sharding_column_type = 2;
   267    reserved 2;
   268  
   269    // OBSOLETE int32 split_shard_count = 3;
   270    reserved 3;
   271  
   272    // ServedFrom indicates a relationship between a TabletType and the
   273    // keyspace name that's serving it.
   274    message ServedFrom {
   275      // the tablet type (key for the map)
   276      TabletType tablet_type = 1;
   277  
   278      // the cells to limit this to
   279      repeated string cells = 2;
   280  
   281      // the keyspace name that's serving it
   282      string keyspace = 3;
   283    }
   284  
   285    // ServedFrom will redirect the appropriate traffic to
   286    // another keyspace.
   287    repeated ServedFrom served_froms = 4;
   288  
   289    // keyspace_type will determine how this keyspace is treated by
   290    // vtgate / vschema. Normal keyspaces are routable by
   291    // any query. Snapshot keyspaces are only accessible
   292    // by explicit addresssing or by calling "use keyspace" first
   293    KeyspaceType keyspace_type = 5;
   294  
   295    // base_keyspace is the base keyspace from which a snapshot
   296    // keyspace is created. empty for normal keyspaces
   297    string base_keyspace = 6;
   298    
   299    // snapshot_time (in UTC) is a property of snapshot
   300    // keyspaces which tells us what point in time
   301    // the snapshot is of
   302    vttime.Time snapshot_time = 7;
   303  
   304    // DurabilityPolicy is the durability policy to be
   305    // used for the keyspace.
   306    string durability_policy = 8;
   307  
   308    // ThrottlerConfig has the configuration for the tablet
   309    // server's lag throttler, and applies to the entire
   310    // keyspace, across all shards and tablets.
   311    ThrottlerConfig throttler_config = 9;
   312  }
   313  
   314  // ShardReplication describes the MySQL replication relationships
   315  // whithin a cell.
   316  message ShardReplication {
   317  
   318    // Node describes a tablet instance within the cell
   319    message Node {
   320      TabletAlias tablet_alias = 1;
   321    }
   322  
   323    // Note there can be only one Node in this array
   324    // for a given tablet.
   325    repeated Node nodes = 1;
   326  }
   327  
   328  // ShardReplicationError describes the error being fixed by
   329  // ShardReplicationFix.
   330  message ShardReplicationError {
   331    enum Type {
   332      // UNKNOWN is not a valid value.
   333      UNKNOWN = 0;
   334      // NOT_FOUND occurs when a tablet is in the ShardReplication record
   335      // but does not exist in the topology.
   336      NOT_FOUND = 1;
   337      // TOPOLOGY_MISMATCH occurs when a tablet is in the replication graph and
   338      // exists in the topology, but at least one of the Keyspace, Shard, or Cell
   339      // fields for that tablet does not match the ShardReplication record.
   340      TOPOLOGY_MISMATCH = 2;
   341    }
   342  
   343    // Type is the category of problem being fixed.
   344    Type type = 1;
   345    // TabletAlias is the tablet record that has the problem.
   346    topodata.TabletAlias tablet_alias = 2;
   347  }
   348  
   349  // ShardReference is used as a pointer from a SrvKeyspace to a Shard
   350  message ShardReference {
   351    // Copied from Shard.
   352    string name = 1;
   353    KeyRange key_range = 2;
   354    // Disable query serving in this shard
   355  }
   356  
   357  // ShardTabletControl is used as a pointer from a SrvKeyspace to a Shard
   358  message ShardTabletControl {
   359    // Copied from Shard.
   360    string name = 1;
   361    KeyRange key_range = 2;
   362    // Disable query serving in this shard
   363    bool query_service_disabled = 3;
   364  }
   365  
   366  message ThrottlerConfig {
   367    // Enabled indicates that the throttler is actually checking state for
   368    // requests. When disabled, it automatically returns 200 OK for all
   369    // checks.
   370    bool enabled = 1;
   371  
   372    // Threshold is the threshold for either the default check (heartbeat
   373    // lag) or custom check.
   374    double threshold = 2;
   375  
   376    // CustomQuery is an optional query that overrides the default check
   377    // query.
   378    string custom_query = 3;
   379  
   380    // CheckAsCheckSelf indicates whether a throttler /check request
   381    // should behave like a /check-self.
   382    bool check_as_check_self = 4;
   383  }
   384  
   385  // SrvKeyspace is a rollup node for the keyspace itself.
   386  message SrvKeyspace {
   387    message KeyspacePartition {
   388      // The type this partition applies to.
   389      TabletType served_type = 1;
   390  
   391      // List of non-overlapping continuous shards sorted by range.
   392      repeated ShardReference shard_references = 2;
   393  
   394      // List of shard tablet controls
   395      repeated ShardTabletControl shard_tablet_controls = 3;
   396    }
   397  
   398    // The partitions this keyspace is serving, per tablet type.
   399    repeated KeyspacePartition partitions = 1;
   400  
   401    // ServedFrom indicates a relationship between a TabletType and the
   402    // keyspace name that's serving it.
   403    message ServedFrom {
   404      // the tablet type
   405      TabletType tablet_type = 1;
   406  
   407      // the keyspace name that's serving it
   408      string keyspace = 2;
   409    }
   410  
   411    // copied from Keyspace
   412    // OBSOLETE string sharding_column_name = 2;
   413    reserved 2;
   414  
   415    // OBSOLETE KeyspaceIdType sharding_column_type = 3;
   416    reserved 3;
   417  
   418    repeated ServedFrom served_from = 4;
   419  
   420    // OBSOLETE int32 split_shard_count = 5;
   421    reserved 5;
   422  
   423    // ThrottlerConfig has the configuration for the tablet server's
   424    // lag throttler, and applies to the entire keyspace, across all
   425    // shards and tablets. This is copied from the global keyspace
   426    // object.
   427    ThrottlerConfig throttler_config = 6;
   428  }
   429  
   430  // CellInfo contains information about a cell. CellInfo objects are
   431  // stored in the global topology server, and describe how to reach
   432  // local topology servers.
   433  message CellInfo {
   434    // ServerAddress contains the address of the server for the cell.
   435    // The syntax of this field is topology implementation specific.
   436    // For instance, for Zookeeper, it is a comma-separated list of
   437    // server addresses.
   438    string server_address = 1;
   439  
   440    // Root is the path to store data in. It is only used when talking
   441    // to server_address.
   442    string root = 2;
   443  
   444    // OBSOLETE: region 3
   445    reserved 3;
   446  }
   447  
   448  // CellsAlias 
   449  message CellsAlias {
   450    // Cells that map to this alias
   451    repeated string cells = 2;
   452  }
   453  
   454  message TopoConfig {
   455    string topo_type = 1;
   456    string server = 2;
   457    string root = 3;
   458  }
   459  
   460  message ExternalVitessCluster {
   461    TopoConfig topo_config = 1;
   462  }
   463  
   464  // ExternalClusters
   465  message ExternalClusters {
   466    repeated ExternalVitessCluster vitess_cluster = 1;
   467  }