storagebase

package
v0.0.0-...-fb4b6e5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

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
ReplicatedEvalResult
WriteBatch
RaftCommand
ReplicaState
RangeInfo

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthProposerKv = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowProposerKv   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	ErrInvalidLengthState = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowState   = fmt.Errorf("proto: integer overflow")
)
View Source
var ReplicaState_FrozenEnum_name = map[int32]string{
	0: "FROZEN_UNSPECIFIED",
	1: "FROZEN",
	2: "UNFROZEN",
}
View Source
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 {
	ReplicatedEvalResult
	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) MarshalTo

func (m *ChangeReplicas) MarshalTo(dAtA []byte) (int, 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 CmdIDKey

type CmdIDKey string

CmdIDKey is a Raft command id.

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) Descriptor() ([]byte, []int)

func (*Merge) Marshal

func (m *Merge) Marshal() (dAtA []byte, err error)

func (*Merge) MarshalTo

func (m *Merge) MarshalTo(dAtA []byte) (int, error)

func (*Merge) ProtoMessage

func (*Merge) ProtoMessage()

func (*Merge) Reset

func (m *Merge) Reset()

func (*Merge) Size

func (m *Merge) Size() (n int)

func (*Merge) String

func (m *Merge) String() string

func (*Merge) Unmarshal

func (m *Merge) Unmarshal(dAtA []byte) error

type RaftCommand

type RaftCommand struct {
	// origin_replica is the replica which proposed this command, to be
	// used for lease validation.
	OriginReplica cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,2,opt,name=origin_replica,json=originReplica" json:"origin_replica"`
	// origin_lease is provided to verify at raft command apply-time that
	// the lease under which the command was proposed remains in effect.
	// If the command was proposed prior to the introduction of epoch leases,
	// origin_lease will be nil, but the combination of origin_replica and
	// the request timestamp are used to verify an expiration-based lease.
	OriginLease *cockroach_roachpb1.Lease `protobuf:"bytes,5,opt,name=origin_lease,json=originLease" json:"origin_lease,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"`
	// batch_request is the KV command to apply.
	// TODO(bdarnell): Should not be set when propEvalKV is used, but is currently
	// required to support test filters.
	BatchRequest         *cockroach_roachpb3.BatchRequest `protobuf:"bytes,3,opt,name=batch_request,json=batchRequest" json:"batch_request,omitempty"`
	ReplicatedEvalResult *ReplicatedEvalResult            `protobuf:"bytes,10013,opt,name=replicated_eval_result,json=replicatedEvalResult" json:"replicated_eval_result,omitempty"`
	// TODO(tschottdorf): using an extra message here (and not just `bytes`) to
	// allow the generated RaftCommand to be compared directly. If
	// this costs an extra large allocation, we need to do something different.
	WriteBatch *WriteBatch `protobuf:"bytes,10014,opt,name=write_batch,json=writeBatch" json:"write_batch,omitempty"`
}

RaftCommand is the message written to the raft log. It contains some metadata about the proposal itself, then either a BatchRequest (legacy mode) or a ReplicatedEvalResult + WriteBatch (proposer-evaluated KV mode).

func (*RaftCommand) Descriptor

func (*RaftCommand) Descriptor() ([]byte, []int)

func (*RaftCommand) Marshal

func (m *RaftCommand) Marshal() (dAtA []byte, err error)

func (*RaftCommand) MarshalTo

func (m *RaftCommand) MarshalTo(dAtA []byte) (int, error)

func (*RaftCommand) ProtoMessage

func (*RaftCommand) ProtoMessage()

func (*RaftCommand) Reset

func (m *RaftCommand) Reset()

func (*RaftCommand) Size

func (m *RaftCommand) Size() (n int)

func (*RaftCommand) String

func (m *RaftCommand) String() string

func (*RaftCommand) Unmarshal

func (m *RaftCommand) Unmarshal(dAtA []byte) error

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) Descriptor() ([]byte, []int)

func (*RangeInfo) Marshal

func (m *RangeInfo) Marshal() (dAtA []byte, err error)

func (*RangeInfo) MarshalTo

func (m *RangeInfo) MarshalTo(dAtA []byte) (int, error)

func (*RangeInfo) ProtoMessage

func (*RangeInfo) ProtoMessage()

func (*RangeInfo) Reset

func (m *RangeInfo) Reset()

func (*RangeInfo) Size

func (m *RangeInfo) Size() (n int)

func (*RangeInfo) String

func (m *RangeInfo) String() string

func (*RangeInfo) Unmarshal

func (m *RangeInfo) Unmarshal(dAtA []byte) error

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 range 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) MarshalTo

func (m *ReplicaState) MarshalTo(dAtA []byte) (int, 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 EvalResults 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 ReplicatedEvalResult

type ReplicatedEvalResult struct {
	// 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"`
	ChangeReplicas *ChangeReplicas                             `protobuf:"bytes,10012,opt,name=change_replicas,json=changeReplicas" json:"change_replicas,omitempty"`
	RaftLogDelta   *int64                                      `protobuf:"varint,10013,opt,name=raft_log_delta,json=raftLogDelta" json:"raft_log_delta,omitempty"`
}

ReplicatedEvalResult 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 ReplicatedEvalResult 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 (*ReplicatedEvalResult) Descriptor

func (*ReplicatedEvalResult) Descriptor() ([]byte, []int)

func (*ReplicatedEvalResult) Marshal

func (m *ReplicatedEvalResult) Marshal() (dAtA []byte, err error)

func (*ReplicatedEvalResult) MarshalTo

func (m *ReplicatedEvalResult) MarshalTo(dAtA []byte) (int, error)

func (*ReplicatedEvalResult) ProtoMessage

func (*ReplicatedEvalResult) ProtoMessage()

func (*ReplicatedEvalResult) Reset

func (m *ReplicatedEvalResult) Reset()

func (*ReplicatedEvalResult) Size

func (m *ReplicatedEvalResult) Size() (n int)

func (*ReplicatedEvalResult) String

func (m *ReplicatedEvalResult) String() string

func (*ReplicatedEvalResult) Unmarshal

func (m *ReplicatedEvalResult) 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) Descriptor() ([]byte, []int)

func (*Split) Marshal

func (m *Split) Marshal() (dAtA []byte, err error)

func (*Split) MarshalTo

func (m *Split) MarshalTo(dAtA []byte) (int, error)

func (*Split) ProtoMessage

func (*Split) ProtoMessage()

func (*Split) Reset

func (m *Split) Reset()

func (*Split) Size

func (m *Split) Size() (n int)

func (*Split) String

func (m *Split) String() string

func (*Split) Unmarshal

func (m *Split) Unmarshal(dAtA []byte) error

type WriteBatch

type WriteBatch struct {
	Data []byte `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
}

WriteBatch is the serialized representation of a RocksDB write batch. A wrapper message is used so that the absence of the field can be distinguished from a zero-length batch, and so structs containing pointers to it can be compared with the == operator (we rely on this in storage.EvalResult)

func (*WriteBatch) Descriptor

func (*WriteBatch) Descriptor() ([]byte, []int)

func (*WriteBatch) Marshal

func (m *WriteBatch) Marshal() (dAtA []byte, err error)

func (*WriteBatch) MarshalTo

func (m *WriteBatch) MarshalTo(dAtA []byte) (int, error)

func (*WriteBatch) ProtoMessage

func (*WriteBatch) ProtoMessage()

func (*WriteBatch) Reset

func (m *WriteBatch) Reset()

func (*WriteBatch) Size

func (m *WriteBatch) Size() (n int)

func (*WriteBatch) String

func (m *WriteBatch) String() string

func (*WriteBatch) Unmarshal

func (m *WriteBatch) Unmarshal(dAtA []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL