Documentation ¶
Overview ¶
Package storagebase is a generated protocol buffer package.
It is generated from these files:
cockroach/pkg/storage/storagebase/proposer_kv.proto cockroach/pkg/storage/storagebase/state.proto
It has these top-level messages:
Split Merge ChangeReplicas ReplicatedProposalData ReplicaState RangeInfo
Index ¶
- Variables
- type ApplyFilterArgs
- type ChangeReplicas
- func (*ChangeReplicas) Descriptor() ([]byte, []int)
- func (m *ChangeReplicas) Marshal() (dAtA []byte, err error)
- func (m *ChangeReplicas) MarshalTo(dAtA []byte) (int, error)
- func (*ChangeReplicas) ProtoMessage()
- func (m *ChangeReplicas) Reset()
- func (m *ChangeReplicas) Size() (n int)
- func (m *ChangeReplicas) String() string
- func (m *ChangeReplicas) Unmarshal(dAtA []byte) error
- type CmdIDKey
- type FilterArgs
- type Merge
- func (*Merge) Descriptor() ([]byte, []int)
- func (m *Merge) Marshal() (dAtA []byte, err error)
- func (m *Merge) MarshalTo(dAtA []byte) (int, error)
- func (*Merge) ProtoMessage()
- func (m *Merge) Reset()
- func (m *Merge) Size() (n int)
- func (m *Merge) String() string
- func (m *Merge) Unmarshal(dAtA []byte) error
- type RangeInfo
- func (*RangeInfo) Descriptor() ([]byte, []int)
- func (m *RangeInfo) Marshal() (dAtA []byte, err error)
- func (m *RangeInfo) MarshalTo(dAtA []byte) (int, error)
- func (*RangeInfo) ProtoMessage()
- func (m *RangeInfo) Reset()
- func (m *RangeInfo) Size() (n int)
- func (m *RangeInfo) String() string
- func (m *RangeInfo) Unmarshal(dAtA []byte) error
- type ReplicaApplyFilter
- type ReplicaCommandFilter
- type ReplicaResponseFilter
- type ReplicaState
- func (*ReplicaState) Descriptor() ([]byte, []int)
- func (s ReplicaState) IsFrozen() bool
- func (m *ReplicaState) Marshal() (dAtA []byte, err error)
- func (m *ReplicaState) MarshalTo(dAtA []byte) (int, error)
- func (*ReplicaState) ProtoMessage()
- func (m *ReplicaState) Reset()
- func (m *ReplicaState) Size() (n int)
- func (m *ReplicaState) String() string
- func (m *ReplicaState) Unmarshal(dAtA []byte) error
- type ReplicaState_FrozenEnum
- type ReplicatedProposalData
- func (*ReplicatedProposalData) Descriptor() ([]byte, []int)
- func (m *ReplicatedProposalData) Marshal() (dAtA []byte, err error)
- func (m *ReplicatedProposalData) MarshalTo(dAtA []byte) (int, error)
- func (*ReplicatedProposalData) ProtoMessage()
- func (m *ReplicatedProposalData) Reset()
- func (m *ReplicatedProposalData) Size() (n int)
- func (m *ReplicatedProposalData) String() string
- func (rpd *ReplicatedProposalData) Strip()
- func (m *ReplicatedProposalData) Unmarshal(dAtA []byte) error
- type ReplicatedProposalData_WriteBatch
- func (*ReplicatedProposalData_WriteBatch) Descriptor() ([]byte, []int)
- func (m *ReplicatedProposalData_WriteBatch) Marshal() (dAtA []byte, err error)
- func (m *ReplicatedProposalData_WriteBatch) MarshalTo(dAtA []byte) (int, error)
- func (*ReplicatedProposalData_WriteBatch) ProtoMessage()
- func (m *ReplicatedProposalData_WriteBatch) Reset()
- func (m *ReplicatedProposalData_WriteBatch) Size() (n int)
- func (m *ReplicatedProposalData_WriteBatch) String() string
- func (m *ReplicatedProposalData_WriteBatch) Unmarshal(dAtA []byte) error
- type Split
- func (*Split) Descriptor() ([]byte, []int)
- func (m *Split) Marshal() (dAtA []byte, err error)
- func (m *Split) MarshalTo(dAtA []byte) (int, error)
- func (*Split) ProtoMessage()
- func (m *Split) Reset()
- func (m *Split) Size() (n int)
- func (m *Split) String() string
- func (m *Split) Unmarshal(dAtA []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthProposerKv = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowProposerKv = fmt.Errorf("proto: integer overflow") )
var ( ErrInvalidLengthState = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowState = fmt.Errorf("proto: integer overflow") )
var ReplicaState_FrozenEnum_name = map[int32]string{
0: "FROZEN_UNSPECIFIED",
1: "FROZEN",
2: "UNFROZEN",
}
var ReplicaState_FrozenEnum_value = map[string]int32{
"FROZEN_UNSPECIFIED": 0,
"FROZEN": 1,
"UNFROZEN": 2,
}
Functions ¶
This section is empty.
Types ¶
type ApplyFilterArgs ¶
type ApplyFilterArgs struct { ReplicatedProposalData CmdID CmdIDKey RangeID roachpb.RangeID StoreID roachpb.StoreID }
ApplyFilterArgs groups the arguments to a ReplicaApplyFilter.
type ChangeReplicas ¶
type ChangeReplicas struct {
cockroach_roachpb1.ChangeReplicasTrigger `protobuf:"bytes,1,opt,name=trigger,embedded=trigger" json:"trigger"`
}
ChangeReplicas is emitted by a Replica which commits a transaction with a ChangeReplicasTrigger.
func (*ChangeReplicas) Descriptor ¶
func (*ChangeReplicas) Descriptor() ([]byte, []int)
func (*ChangeReplicas) Marshal ¶
func (m *ChangeReplicas) Marshal() (dAtA []byte, err error)
func (*ChangeReplicas) ProtoMessage ¶
func (*ChangeReplicas) ProtoMessage()
func (*ChangeReplicas) Reset ¶
func (m *ChangeReplicas) Reset()
func (*ChangeReplicas) Size ¶
func (m *ChangeReplicas) Size() (n int)
func (*ChangeReplicas) String ¶
func (m *ChangeReplicas) String() string
func (*ChangeReplicas) Unmarshal ¶
func (m *ChangeReplicas) Unmarshal(dAtA []byte) error
type FilterArgs ¶
type FilterArgs struct { Ctx context.Context CmdID CmdIDKey Index int Sid roachpb.StoreID Req roachpb.Request Hdr roachpb.Header }
FilterArgs groups the arguments to a ReplicaCommandFilter.
func (*FilterArgs) InRaftCmd ¶
func (f *FilterArgs) InRaftCmd() bool
InRaftCmd returns true if the filter is running in the context of a Raft command (it could be running outside of one, for example for a read).
type Merge ¶
type Merge struct {
cockroach_roachpb1.MergeTrigger `protobuf:"bytes,1,opt,name=trigger,embedded=trigger" json:"trigger"`
}
Merge is emitted by a Replica which commits a transaction with a MergeTrigger (i.e. absorbs its right neighbor).
func (*Merge) Descriptor ¶
func (*Merge) ProtoMessage ¶
func (*Merge) ProtoMessage()
type RangeInfo ¶
type RangeInfo struct { ReplicaState `protobuf:"bytes,1,opt,name=state,embedded=state" json:"state"` // The highest (and last) index in the Raft log. LastIndex uint64 `protobuf:"varint,2,opt,name=lastIndex,proto3" json:"lastIndex,omitempty"` NumPending uint64 `protobuf:"varint,3,opt,name=num_pending,json=numPending,proto3" json:"num_pending,omitempty"` NumDropped uint64 `protobuf:"varint,5,opt,name=num_dropped,json=numDropped,proto3" json:"num_dropped,omitempty"` // raft_log_size may be initially inaccurate after a server restart. // See storage.Replica.mu.raftLogSize. RaftLogSize int64 `protobuf:"varint,6,opt,name=raft_log_size,json=raftLogSize,proto3" json:"raft_log_size,omitempty"` }
func (*RangeInfo) Descriptor ¶
func (*RangeInfo) ProtoMessage ¶
func (*RangeInfo) ProtoMessage()
type ReplicaApplyFilter ¶
type ReplicaApplyFilter func(args ApplyFilterArgs) *roachpb.Error
A ReplicaApplyFilter can be used in testing to influence the error returned from proposals after they apply.
type ReplicaCommandFilter ¶
type ReplicaCommandFilter func(args FilterArgs) *roachpb.Error
ReplicaCommandFilter may be used in tests through the StorageTestingMocker to intercept the handling of commands and artificially generate errors. Return nil to continue with regular processing or non-nil to terminate processing with the returned error. Note that in a multi-replica test this filter will be run once for each replica and must produce consistent results each time.
TODO(tschottdorf): clean this up. Tests which use this all need to be refactored to use explicitly a proposal-intercepting filter (not written yet, but it's basically this one here when proposer-evaluated KV is on) or a ReplicaApplyFilter (see below).
type ReplicaResponseFilter ¶
type ReplicaResponseFilter func(roachpb.BatchRequest, *roachpb.BatchResponse) *roachpb.Error
ReplicaResponseFilter is used in unittests to modify the outbound response returned to a waiting client after a replica command has been processed. This filter is invoked only by the command proposer.
type ReplicaState ¶
type ReplicaState struct { // The highest (and last) index applied to the state machine. RaftAppliedIndex uint64 `protobuf:"varint,1,opt,name=raft_applied_index,json=raftAppliedIndex,proto3" json:"raft_applied_index,omitempty"` // The highest (and last) lease index applied to the state machine. LeaseAppliedIndex uint64 `protobuf:"varint,2,opt,name=lease_applied_index,json=leaseAppliedIndex,proto3" json:"lease_applied_index,omitempty"` // The Range descriptor. // The pointer may change, but the referenced RangeDescriptor struct itself // must be treated as immutable; it is leaked out of the lock. // // Changes of the descriptor should always go through one of the // (*Replica).setDesc* methods. Desc *cockroach_roachpb.RangeDescriptor `protobuf:"bytes,3,opt,name=desc" json:"desc,omitempty"` // The latest lease, if any. Lease *cockroach_roachpb1.Lease `protobuf:"bytes,4,opt,name=lease" json:"lease,omitempty"` // The truncation state of the Raft log. TruncatedState *cockroach_roachpb4.RaftTruncatedState `protobuf:"bytes,5,opt,name=truncated_state,json=truncatedState" json:"truncated_state,omitempty"` // gcThreshold is the GC threshold of the Range, typically updated when keys // are garbage collected. Reads and writes at timestamps <= this time will // not be served. // // TODO(tschottdorf): should be nullable to keep ReplicaState small as we are // sending it over the wire. Since we only ever increase gc_threshold, that's // the only upshot - fields which can return to the zero value must // special-case that value simply because otherwise there's no way of // distinguishing "no update" to and updating to the zero value. GCThreshold cockroach_util_hlc.Timestamp `protobuf:"bytes,6,opt,name=gc_threshold,json=gcThreshold" json:"gc_threshold"` Stats cockroach_storage_engine_enginepb.MVCCStats `protobuf:"bytes,7,opt,name=stats" json:"stats"` // txn_span_gc_threshold is the (maximum) timestamp below which transaction // records may have been garbage collected (as measured by txn.LastActive()). // Transaction at lower timestamps must not be allowed to write their initial // transaction entry. // // TODO(tschottdorf): should be nullable; see gc_threshold. TxnSpanGCThreshold cockroach_util_hlc.Timestamp `protobuf:"bytes,9,opt,name=txn_span_gc_threshold,json=txnSpanGcThreshold" json:"txn_span_gc_threshold"` Frozen ReplicaState_FrozenEnum `` /* 126-byte string literal not displayed */ }
ReplicaState is the part of the Range Raft state machine which is cached in memory and which is manipulated exclusively through consensus.
The struct is also used to transfer state to Replicas in the context of proposer-evaluated Raft, in which case it does not represent a complete state but instead an update to be applied to an existing state, with each field specified in the update overwriting its counterpart on the receiving ReplicaState.
For the ReplicaState persisted on the Replica, all optional fields are populated (i.e. no nil pointers or enums with the default value).
func (*ReplicaState) Descriptor ¶
func (*ReplicaState) Descriptor() ([]byte, []int)
func (ReplicaState) IsFrozen ¶
func (s ReplicaState) IsFrozen() bool
IsFrozen returns true if the underlying ReplicaState indicates that the Replica is frozen.
func (*ReplicaState) Marshal ¶
func (m *ReplicaState) Marshal() (dAtA []byte, err error)
func (*ReplicaState) ProtoMessage ¶
func (*ReplicaState) ProtoMessage()
func (*ReplicaState) Reset ¶
func (m *ReplicaState) Reset()
func (*ReplicaState) Size ¶
func (m *ReplicaState) Size() (n int)
func (*ReplicaState) String ¶
func (m *ReplicaState) String() string
func (*ReplicaState) Unmarshal ¶
func (m *ReplicaState) Unmarshal(dAtA []byte) error
type ReplicaState_FrozenEnum ¶
type ReplicaState_FrozenEnum int32
Use an enum because proto3 does not give nullable primitive values, and we need to be able to send ProposalData which don't specify frozen.
const ( ReplicaState_FROZEN_UNSPECIFIED ReplicaState_FrozenEnum = 0 ReplicaState_FROZEN ReplicaState_FrozenEnum = 1 ReplicaState_UNFROZEN ReplicaState_FrozenEnum = 2 )
func (ReplicaState_FrozenEnum) EnumDescriptor ¶
func (ReplicaState_FrozenEnum) EnumDescriptor() ([]byte, []int)
func (ReplicaState_FrozenEnum) String ¶
func (x ReplicaState_FrozenEnum) String() string
type ReplicatedProposalData ¶
type ReplicatedProposalData struct { RangeID github_com_cockroachdb_cockroach_pkg_roachpb.RangeID `` /* 128-byte string literal not displayed */ OriginReplica cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,2,opt,name=origin_replica,json=originReplica" json:"origin_replica"` Cmd *cockroach_roachpb3.BatchRequest `protobuf:"bytes,3,opt,name=cmd" json:"cmd,omitempty"` // When the command is applied, its result is an error if the lease log // counter has already reached (or exceeded) max_lease_index. // // The lease index is a replay protection mechanism. Similar to the Raft // applied index, it is strictly increasing, but may have gaps. A command // will only apply successfully if its max_lease_index has not been surpassed // by the Range's applied lease index (in which case the command may need // to be retried, that is, regenerated with a higher max_lease_index). // When the command applies, the new lease index will increase to // max_lease_index (so a potential later replay will fail). // // This mechanism was introduced as a simpler alternative to using the Raft // applied index, which is fraught with complexity due to the need to predict // exactly the log position at which a command will apply, even when the Raft // leader is not colocated with the lease holder (which usually proposes all // commands). // // Pinning the lease-index to the assigned slot (as opposed to allowing gaps // as we do now) is an interesting venue to explore from the standpoint of // parallelization: One could hope to enforce command ordering in that way // (without recourse to a higher-level locking primitive such as the command // queue). This is a hard problem: First of all, managing the pending // commands gets more involved; a command must not be removed if others have // been added after it, and on removal, the assignment counters must be // updated accordingly. Managing retry of proposals becomes trickier as // well as that uproots whatever ordering was originally envisioned. MaxLeaseIndex uint64 `protobuf:"varint,4,opt,name=max_lease_index,json=maxLeaseIndex" json:"max_lease_index"` // Whether to block concurrent readers while processing the proposal data. BlockReads bool `protobuf:"varint,10001,opt,name=block_reads,json=blockReads" json:"block_reads"` // Updates to the Replica's ReplicaState. By convention and as outlined on // the comment on the ReplicaState message, this field is sparsely populated // and any field set overwrites the corresponding field in the state, perhaps // which additional side effects (for instance on a descriptor update). State ReplicaState `protobuf:"bytes,10002,opt,name=state" json:"state"` Split *Split `protobuf:"bytes,10003,opt,name=split" json:"split,omitempty"` Merge *Merge `protobuf:"bytes,10004,opt,name=merge" json:"merge,omitempty"` // TODO(tschottdorf): trim this down; we shouldn't need the whole request. ComputeChecksum *cockroach_roachpb3.ComputeChecksumRequest `protobuf:"bytes,10005,opt,name=compute_checksum,json=computeChecksum" json:"compute_checksum,omitempty"` IsLeaseRequest bool `protobuf:"varint,10006,opt,name=is_lease_request,json=isLeaseRequest" json:"is_lease_request"` IsFreeze bool `protobuf:"varint,10007,opt,name=is_freeze,json=isFreeze" json:"is_freeze"` // Denormalizes BatchRequest.Timestamp during the transition period for // proposer-evaluated KV. Only used to verify lease coverage. Timestamp cockroach_util_hlc.Timestamp `protobuf:"bytes,10008,opt,name=timestamp" json:"timestamp"` IsConsistencyRelated bool `protobuf:"varint,10009,opt,name=is_consistency_related,json=isConsistencyRelated" json:"is_consistency_related"` // The stats delta corresponding to the data in this WriteBatch. On // a split, contains only the contributions to the left-hand side. Delta cockroach_storage_engine_enginepb.MVCCStats `protobuf:"bytes,10010,opt,name=delta" json:"delta"` // TODO(tschottdorf): using an extra message here (and not just `bytes`) to // allow the generated ReplicatedProposalData to be compared directly. If // this costs an extra large allocation, we need to do something different. WriteBatch *ReplicatedProposalData_WriteBatch `protobuf:"bytes,10011,opt,name=write_batch,json=writeBatch" json:"write_batch,omitempty"` ChangeReplicas *ChangeReplicas `protobuf:"bytes,10012,opt,name=change_replicas,json=changeReplicas" json:"change_replicas,omitempty"` }
ReplicaProposalData is the structured information which together with a RocksDB WriteBatch constitutes the proposal payload in proposer-evaluated KV. For the majority of proposals, we expect ReplicatedProposalData to be trivial; only changes to the metadata state (splits, merges, rebalances, leases, log truncation, ...) of the Replica or certain special commands must sideline information here based on which all Replicas must take action.
TODO(tschottdorf): We may need to add a lease identifier to allow the followers to reliably produce errors for proposals which apply after a lease change.
func (*ReplicatedProposalData) Descriptor ¶
func (*ReplicatedProposalData) Descriptor() ([]byte, []int)
func (*ReplicatedProposalData) Marshal ¶
func (m *ReplicatedProposalData) Marshal() (dAtA []byte, err error)
func (*ReplicatedProposalData) MarshalTo ¶
func (m *ReplicatedProposalData) MarshalTo(dAtA []byte) (int, error)
func (*ReplicatedProposalData) ProtoMessage ¶
func (*ReplicatedProposalData) ProtoMessage()
func (*ReplicatedProposalData) Reset ¶
func (m *ReplicatedProposalData) Reset()
func (*ReplicatedProposalData) Size ¶
func (m *ReplicatedProposalData) Size() (n int)
func (*ReplicatedProposalData) String ¶
func (m *ReplicatedProposalData) String() string
func (*ReplicatedProposalData) Strip ¶
func (rpd *ReplicatedProposalData) Strip()
Strip removes all state changes from the ReplicatedProposalData, leaving only metadata behind.
func (*ReplicatedProposalData) Unmarshal ¶
func (m *ReplicatedProposalData) Unmarshal(dAtA []byte) error
type ReplicatedProposalData_WriteBatch ¶
type ReplicatedProposalData_WriteBatch struct {
Data []byte `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
}
func (*ReplicatedProposalData_WriteBatch) Descriptor ¶
func (*ReplicatedProposalData_WriteBatch) Descriptor() ([]byte, []int)
func (*ReplicatedProposalData_WriteBatch) Marshal ¶
func (m *ReplicatedProposalData_WriteBatch) Marshal() (dAtA []byte, err error)
func (*ReplicatedProposalData_WriteBatch) MarshalTo ¶
func (m *ReplicatedProposalData_WriteBatch) MarshalTo(dAtA []byte) (int, error)
func (*ReplicatedProposalData_WriteBatch) ProtoMessage ¶
func (*ReplicatedProposalData_WriteBatch) ProtoMessage()
func (*ReplicatedProposalData_WriteBatch) Reset ¶
func (m *ReplicatedProposalData_WriteBatch) Reset()
func (*ReplicatedProposalData_WriteBatch) Size ¶
func (m *ReplicatedProposalData_WriteBatch) Size() (n int)
func (*ReplicatedProposalData_WriteBatch) String ¶
func (m *ReplicatedProposalData_WriteBatch) String() string
func (*ReplicatedProposalData_WriteBatch) Unmarshal ¶
func (m *ReplicatedProposalData_WriteBatch) Unmarshal(dAtA []byte) error
type Split ¶
type Split struct { cockroach_roachpb1.SplitTrigger `protobuf:"bytes,1,opt,name=trigger,embedded=trigger" json:"trigger"` // RHSDelta holds the statistics for what was written to what is now the // right-hand side of the split during the batch which executed it. // The on-disk state of the right-hand side is already correct, but the // Store must learn about this delta to update its counters appropriately. RHSDelta cockroach_storage_engine_enginepb.MVCCStats `protobuf:"bytes,2,opt,name=rhs_delta,json=rhsDelta" json:"rhs_delta"` }
Split is emitted when a Replica commits a split trigger. It signals that the Replica has prepared the on-disk state for both the left and right hand sides of the split, and that the left hand side Replica should be updated as well as the right hand side created.
func (*Split) Descriptor ¶
func (*Split) ProtoMessage ¶
func (*Split) ProtoMessage()