github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/kvserverpb/state.proto (about)

     1  // Copyright 2016 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 = "proto3";
    12  package cockroach.kv.kvserver.storagepb;
    13  option go_package = "kvserverpb";
    14  
    15  import "storage/enginepb/mvcc.proto";
    16  import "roachpb/internal_raft.proto";
    17  import "roachpb/metadata.proto";
    18  import "roachpb/data.proto";
    19  import "util/hlc/timestamp.proto";
    20  
    21  import "gogoproto/gogo.proto";
    22  
    23  // ReplicaState is the part of the Range Raft state machine which is cached in
    24  // memory and which is manipulated exclusively through consensus.
    25  //
    26  // The struct is also used to transfer state to Replicas in the context of
    27  // proposer-evaluated Raft, in which case it does not represent a complete
    28  // state but instead an update to be applied to an existing state, with each
    29  // field specified in the update overwriting its counterpart on the receiving
    30  // ReplicaState.
    31  //
    32  // For the ReplicaState persisted on the Replica, all optional fields are
    33  // populated (i.e. no nil pointers or enums with the default value).
    34  message ReplicaState {
    35    option (gogoproto.equal) = true;
    36  
    37    // The highest (and last) index applied to the state machine.
    38    uint64 raft_applied_index = 1;
    39    // The highest (and last) lease index applied to the state machine.
    40    uint64 lease_applied_index = 2;
    41    // The Range descriptor.
    42    // The pointer may change, but the referenced RangeDescriptor struct itself
    43    // must be treated as immutable; it is leaked out of the lock.
    44    //
    45    // Changes of the descriptor should always go through one of the
    46    // (*Replica).setDesc* methods.
    47    roachpb.RangeDescriptor desc = 3;
    48    // The latest range lease.
    49    //
    50    // Note that this message is both sent over the network and used to model
    51    // replica state in memory. In memory (storage.Replica.mu.state), the lease
    52    // is never nil (and never zero-valued), but it may be nil when sent over
    53    // the network as part of ReplicatedEvalResult.
    54    roachpb.Lease lease = 4;
    55    // The truncation state of the Raft log.
    56    roachpb.RaftTruncatedState truncated_state = 5;
    57    // gcThreshold is the GC threshold of the Range, typically updated when keys
    58    // are garbage collected. Reads and writes at timestamps <= this time will
    59    // not be served.
    60    util.hlc.Timestamp gc_threshold = 6 [(gogoproto.customname) = "GCThreshold"];
    61    storage.enginepb.MVCCStats stats = 7;
    62    // using_applied_state_key specifies whether the Range has been upgraded
    63    // to begin using the RangeAppliedState key. This key holds a combination
    64    // of the Raft applied index, the lease applied index, and the MVCC stats.
    65    //
    66    // When set to true in a ReplicatedEvalResult, the flag indicates that the
    67    // range should begin using the RangeAppliedState key. Handling of this flag
    68    // is idempotent by Replica state machines, meaning that it is ok for multiple
    69    // Raft commands to set it to true.
    70    bool using_applied_state_key = 11;
    71  
    72    reserved 8, 9, 10;
    73  }
    74  
    75  // RangeInfo is used for reporting status information about a range out through
    76  // the status server.
    77  message RangeInfo {
    78    option (gogoproto.equal) = true;
    79  
    80    ReplicaState state = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
    81    // The highest (and last) index in the Raft log.
    82    uint64 last_index = 2;
    83    uint64 num_pending = 3;
    84    reserved 4; // previously last verification timestamp for verify queue.
    85    uint64 num_dropped = 5;
    86    // raft_log_size may be inaccurate, see storage.Replica.mu.raftLogSizeTrusted.
    87    int64 raft_log_size = 6;
    88    bool raft_log_size_trusted = 10;
    89    // Approximately the amount of quota available.
    90    int64 approximate_proposal_quota = 7;
    91    // Index for which quota has already been released.
    92    int64 proposal_quota_base_index = 14;
    93    // Quota amounts for commands which the leader has applied but for which we're
    94    // still waiting for followers to ack the corresponding entries. First entry
    95    // corresponds to base_index+1 above.
    96    repeated int64 proposal_quota_release_queue = 15;
    97    // The max size the range can grow to before it will be split.
    98    int64 range_max_bytes = 8;
    99    reserved 9;
   100    message CTEntry {
   101      option (gogoproto.equal) = true;
   102      int32 node_id = 1 [(gogoproto.customname) = "NodeID",
   103        (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.NodeID"];
   104      util.hlc.Timestamp closed_timestamp = 2 [(gogoproto.nullable) = false];
   105      int64 mlai = 3 [(gogoproto.customname) = "MLAI"];
   106      int64 epoch = 4;
   107    }
   108    // The highest closed timestamp known to have data for this replica, taken
   109    // across the data received from all nodes. This does not reflect whether
   110    // the replica can use this closed timestamp (it may, for example, not have
   111    // caught up sufficiently to do so).
   112    CTEntry newest_closed_timestamp = 11 [(gogoproto.nullable) = false];
   113    // The closed timestamp active on the replica when the info was generated.
   114    // This is the actual timestamp at or below which requests can be served from
   115    // this replica at this moment (assuming it is not the leaseholder). This takes
   116    // into account the lease start time, the current lease applied index, and the
   117    // closed timestamp information received from other nodes, among other things.
   118    // In practice, this should not usually trail newest_closed_timestamp except
   119    // for a short moment after newest_closed_timestamp gets updated.
   120    util.hlc.Timestamp active_closed_timestamp = 12 [(gogoproto.nullable) = false];
   121    // The number of Rangefeed registrations attached to the Replica.
   122    int64 rangefeed_registrations = 13;
   123  }
   124  
   125  // LatchManagerInfo is used for reporting status information about a spanlatch
   126  // manager out through the status server.
   127  message LatchManagerInfo {
   128    int64 read_count = 1;
   129    int64 write_count = 2;
   130  }