package
25.1.0+incompatible
Repository: https://github.com/cockroachdb/cockroach.git
Documentation: pkg.go.dev

# Packages

Package apply provides abstractions and routines associated with the application of committed raft entries to a replicated state machine.
Copyright 2023 The Cockroach Authors.
Package concurrency provides a concurrency manager structure that encapsulates the details of concurrency control and contention handling for serializable key-value transactions.
Package gc contains the logic to run scan a range for garbage and issue GC requests to remove that garbage.
Package kvadmission is the integration layer between KV and admission control.
Package kvflowcontrol provides flow control for replication traffic in KV.
Package kvstorage houses the logic that manages the on-disk state for the Replicas housed on a Store.
Package logstore implements the Raft log storage.
Package protectedts exports the interface to the protected timestamp subsystem which allows clients to prevent GC of expired data.
Package raftentry provides a cache for entries to avoid extra deserializations.
Package rangelog implements kvserver.RangeLogWriter.
Package spanlatch provides a latch management structure for serializing access to keys and key ranges.
Package tenantrate contains logic for rate limiting client requests on a per-tenant basis.
Package tscache provides a timestamp cache structure that records the maximum timestamp that key ranges were read from and written to.
Package uncertainty contains logic and documentation related to transaction uncertainty intervals, which are time windows following readers' timestamps within which a reading transaction cannot make real-time ordering guarantees.

# Functions

BatchCanBeEvaluatedOnFollower determines if a batch consists exclusively of requests that can be evaluated on a follower replica, given a sufficiently advanced closed timestamp.
CalcReplicaDigest computes the SHA512 hash and MVCC stats of the replica data at the given snapshot.
CheckStoreAgainstLeasePreferences returns whether the given store would violate, be less preferred or ok, leaseholder, according the the lease preferences.
CreateAndAddRules initializes all KV metric rules and adds them to the rule registry for tracking.
EnableLeaseHistoryForTesting turns on the lease history for testing purposes.
HasRaftLeader returns true if the raft group has a raft leader currently.
IsIllegalReplicationChangeError detects whether an error (assumed to have been emitted by a replication change) indicates that the replication change is illegal, meaning that it's unlikely to be handled through a retry.
IsLeaseTransferRejectedBecauseTargetCannotReceiveLease returns true if err (assumed to have been emitted by the current leaseholder when processing a lease transfer request) indicates that the target replica is not qualified to receive the lease.
IsLeaseTransferRejectedBecauseTargetMayNeedSnapshotError detects whether an error (assumed to have been emitted by a lease transfer request) indicates that the lease transfer failed because the current leaseholder could not prove that the lease transfer target did not need a Raft snapshot.
IsPurgatoryError returns true iff the given error is a purgatory error.
IsRangeDescriptorKey returns nil if the key decodes as a RangeDescriptor.
IsReplicationChangeInProgressError detects whether an error (assumed to have been emitted by a replication change) indicates that the replication change failed because another replication change was in progress on the range.
IsRetriableReplicationChangeError detects whether an error (which is assumed to have been emitted by the KV layer during a replication change operation) is likely to succeed when retried with an updated descriptor.
MakeServer returns a new instance of Server.
MakeStoresForFlowControl returns the canonical StoresForFlowControl implementation.
MakeStoresForStoreLiveness casts Stores into StoresForStoreLiveness.
MakeStoresIterator returns a new StoresIterator instance.
MaybeAddRuleToRegistry validates a rule and adds it to the rule registry.
NewDummyRaftTransport returns a dummy raft transport for use in tests which need a non-nil raft transport that need not function.
NewPinnedLeases creates a PinnedLeasesKnob.
NewRaftTransport creates a new RaftTransport.
NewReplicaAccumulator returns a new rrAccumulator.
NewReplicaEvalContext returns a batcheval.EvalContext to use for command evaluation.
NewReplicaRankings returns a new ReplicaRankings struct.
NewReplicaRankingsMap returns a new ReplicaRankingMap struct.
NewSSTSnapshotStorage creates a new SST snapshot storage.
NewStorageEngineClient constructs a new StorageEngineClient.
NewStore returns a new instance of a store.
NewStoreGossip returns a new StoreGosip which may be used for gossiping the store descriptor: both proactively, calling Gossip() and reacively on capacity/load changes.
NewStoreRebalancer creates a StoreRebalancer to work in tandem with the provided replicateQueue.
NewStores returns a local-only sender which directly accesses a collection of stores.
NewTenantReplicaAccumulator returns a new RRAccumulatorByTenant.
OverrideDefaultLeaseType overrides the default lease type for the cluster settings, regardless of any metamorphic constants.
OverrideLeaderLeaseMetamorphism overrides the default lease type to be epoch based leases, regardless of whether leader leases were metamorphically enabled or not.
PrintEngineKeyValue attempts to print the given key-value pair to os.Stdout, utilizing SprintMVCCKeyValue in the case of an MVCCKeyValue.
PrintEngineRangeKeyValue attempts to print the given key-value pair to os.Stdout, utilizing SprintMVCCKeyValue in the case of an MVCCRangeKeyValue.
PrintMVCCKeyValue attempts to pretty-print the specified MVCCKeyValue to os.Stdout, falling back to '%q' formatting.
PrintMVCCRangeKeyValue attempts to pretty-print the specified MVCCRangeKeyValue to os.Stdout, falling back to '%q' formatting.
ReadHLCUpperBound returns the upper bound to the wall time of the HLC If this value does not exist 0 is returned.
ReadMaxHLCUpperBound returns the maximum of the stored hlc upper bounds among all the engines.
RelocateOne returns a suggested replication change and lease transfer that should occur next, to relocate the range onto the given voter and non-voter targets.
ResolveLBRebalancingObjective returns the load based rebalancing objective for the cluster.
SendEmptySnapshot creates an OutgoingSnapshot for the input range descriptor and seeds it with an empty range.
ShouldRequeue determines whether a replica should be requeued into the replicate queue, using the planned change and error returned from either application or planning.
SimulatorStoreRebalancer returns a StoreRebalancer with the given function pointers, for the purposes of breaking dependencies on real code paths.
SprintEngineKey pretty-prints the specified EngineKey, using the correct MVCC or Lock Table version formatting.
SprintEngineKeyValue is like PrintEngineKeyValue, but returns a string.
SprintEngineRangeKey pretty-prints the specified engine range key.
SprintEngineRangeKeyValue is like PrintEngineRangeKeyValue, but returns a string.
SprintIntent pretty-prints the specified intent value.
SprintKeySpan pretty-prints a key span.
SprintMVCCKey pretty-prints the specified MVCCKey.
SprintMVCCKeyValue is like PrintMVCCKeyValue, but returns a string.
SprintMVCCRangeKey pretty-prints the specified MVCCRangeKey.
SprintMVCCRangeKeyValue is like PrintMVCCRangeKeyValue, but returns a string.
SynthesizeTargetsByChangeType groups replication changes in the manner they are intended to be executed by AdminChangeReplicas.
TestGetReplicaRangefeedProcessor exposes rangefeed processor for test introspection.
TestStoreConfig has some fields initialized with values relevant in tests.
TestStoreConfigWithVersion is the same as TestStoreConfig but allows to pass a cluster version.
WithReplicasInOrder is a VisitReplicasOption that ensures replicas are visited in increasing RangeID order.
WriteInitialClusterData writes initialization data to an engine.

# Constants

Ordering options for VisitKeyRange.
Ordering options for VisitKeyRange.
GossipWhenRangeCountDeltaExceeds specifies the absolute change from the last gossiped store capacity range count which needs to be exceeded before the store will gossip immediately without waiting for the periodic gossip interval.
IntersectingSnapshotMsg is part of the error message returned from canAcceptSnapshotLocked and is exposed here so testing can rely on it.
LBRebalancingCPU is a rebalance objective that aims balances the store CPU usage.
LBRebalancingLeasesAndReplicas means that we rebalance both leases and replicas based on store-level load imbalances.
LBRebalancingLeasesOnly means that we rebalance leases based on store-level load imbalances.
LBRebalancingOff means that we do not do store-level rebalancing based on load statistics.
LBRebalancingQueries is a rebalancing objective that aims to balances queries (QPS) among stores in the cluster.
LeasePreferencesLessPreferred indicates the checked store satisfies _some_ preference, however not the most preferred.
LeasePreferencesOK indicates the checked store satisfies the first preference, or no lease preferences are applied.
LeasePreferencesViolating indicates the checked store does not satisfy any lease preference applied.
NoRebalanceNeeded indicates that the state of the local store is within the target goal for load and does not need rebalancing.
NoRebalanceTarget indicates that the state of the local store is outside of the target goal for load however no rebalancing opportunities were found.
RaftLogQueueStaleSize is the minimum size of the Raft log that we'll truncate even if there are fewer than RaftLogQueueStaleThreshold entries to truncate.
RaftLogQueueStaleThreshold is the minimum threshold for stale raft log entries.
RebalanceTargetFound indicates that the state local store is outside of the target goal for load and a rebalance target was found.
ReplicaGCQueueCheckInterval is the inactivity duration after which a range will be considered for garbage collection.
ReplicaGCQueueSuspectCheckInterval is the duration after which a Replica which is suspected to be removed should be considered for garbage collection.
daily.
8MB.

# Variables

ConcurrentRangefeedItersLimit limits concurrent rangefeed catchup iterators.
DebugSprintMVCCKeyValueDecoders allows injecting alternative debug decoders.
DebugSprintMVCCRangeKeyValueDecoders allows injecting alternative debug decoders.
DisableExpirationLeasesOnly is an escape hatch for ExpirationLeasesOnly, which can be used to hard-disable expiration-based leases e.g.
EagerLeaseAcquisitionConcurrency is the number of concurrent, eager lease acquisitions made during Raft ticks, across all stores.
EnableEstimatedMVCCStatsInSplit controls whether the MVCC stats produced during splits are estimated (when enabled) or 100% accurate (when disabled).
EnableEstimatedStatsForExternalBytes controls whether we should bypass normal stats recalcuation during splits if the underlying store has external bytes (i.e.
EnableMVCCStatsRecomputationInSplit controls whether the MVCC stats for a range are re-computed at the beginning of the split (in AdminSplit).
EnqueueInMvccGCQueueOnSpanConfigUpdateEnabled controls whether replicas are enqueued into the mvcc gc queue, following a span config update which affects the replica.
EnqueueInReplicateQueueOnSpanConfigUpdateEnabled controls whether replicas are enqueued into the replicate queue, following a span config update which affects the replica.
EnqueueProblemRangeInReplicateQueueInterval controls the interval at which problem ranges are enqueued into the replicate queue for processing, outside of the normal scanner interval.
ExpirationLeasesMaxReplicasPerNode converts from expiration back to epoch leases if there are too many replicas on a node.
FollowerReadsEnabled controls whether replicas attempt to serve follower reads.
LeaseCheckPreferencesOnAcquisitionEnabled controls whether lease preferences are checked upon acquiring a new lease.
LeaseTransferPerIterationTimeout is the timeout for a single iteration of draining range leases.
LoadBasedRebalancingMode controls whether range rebalancing takes additional variables such as write load and disk usage into account.
LoadBasedRebalancingObjective is a cluster setting that defines the load balancing objective of the cluster.
LoadBasedRebalancingObjectiveMap maps the LoadBasedRebalancingObjective enum value to a string.
MaxQueueOnDelegateLimit is used to control how long the outgoing snapshot queue can be before we reject delegation requests.
MaxSnapshotSSTableSize is the maximum size of an sstable containing MVCC/user keys in a snapshot before we truncate and write a new snapshot sstable.
MergeQueueInterval is a setting that controls how often the merge queue waits between processing replicas.
MinIOOverloadLeaseShedInterval controls how frequently a store may decide to shed all leases due to becoming IO overloaded.
MinLeaseTransferInterval controls how frequently leases can be transferred for rebalancing.
NumDelegateLimit is used to control the number of delegate followers to use for snapshots.
RaftLeaderFortificationFractionEnabled controls the fraction of ranges for which the raft leader fortification protocol is enabled.
RangefeedEnabled is a cluster setting that enables rangefeed requests.
RangeFeedLaggingCTCancelDuration is the duration threshold for lagging rangefeeds to be cancelled when the closed timestamp is lagging behind the current time by more than: `kv.rangefeed.lagging_closed_timestamp_cancel_multiple` * `kv.closed_timestamp.target_duration` e.g., if the closed timestamp target duration is 3s (current default) and the multiple is 2, then the lagging rangefeed will be canceled if the closed timestamp is more than 6s behind the current time, for at least laggingRangeFeedCTCancelDurationThreshold: closed_ts = -7s (relative to now) target_closed_ts = -3s multiple = 2.0 lagging_duration_threshold = 60s In the above example, the rangefeed will be canceled if this state is sustained for at least 60s.
RangeFeedLaggingCTCancelMultiple is the multiple of the closed timestamp target duration that a rangefeed's closed timestamp can lag behind the current time before the rangefeed is cancelled, if the duration threshold is also met, see RangeFeedLaggingCTCancelDuration.
RangeFeedRefreshInterval controls the frequency with which we deliver closed timestamp updates to rangefeeds.
RangeFeedSmearInterval controls the frequency with which the rangefeed updater loop wakes up to deliver closed timestamp updates to rangefeeds.
RangefeedUseBufferedSender controls whether rangefeed uses a node level buffered sender to buffer events instead of buffering events separately in a channel at a per client per registration level.
RangeFeedUseScheduler controls type of rangefeed processor is used to process raft updates and sends updates to clients.
ReadSummaryGlobalBudget controls the maximum number of bytes that will be used to summarize the global segment of the timestamp cache during lease transfers and range merges.
ReadSummaryLocalBudget controls the maximum number of bytes that will be used to summarize the local segment of the timestamp cache during lease transfers and range merges.
RejectLeaseOnLeaderUnknown controls whether a replica that does not know the current raft leader rejects a lease request.
SkipMergeQueueForExternalBytes is a setting that controls whether replicas with external bytes should be processed by the merge queue.
SnapshotSendLimit specifies the maximum number of snapshots that are permitted to be sent concurrently.
SplitByLoadCPUThreshold wraps "kv.range_split.load_cpu_threshold".
SplitByLoadEnabled wraps "kv.range_split.by_load.enabled".
SplitByLoadQPSThreshold wraps "kv.range_split.load_qps_threshold".
StrictGCEnforcement controls whether requests are rejected based on the GC threshold and the current GC TTL (true) or just based on the GC threshold (false).

# Structs

A ConsistencyCheckResult contains the outcome of a CollectChecksum call.
ConsistencyTestingKnobs is a BatchEvalTestingKnobs struct used to control the behavior of the consistency checker for tests.
HotReplicaInfo contains a range descriptor and its QPS.
IncomingSnapshot contains the data for an incoming streaming snapshot message.
NodeLivenessTestingKnobs allows tests to override some node liveness controls.
NoopRaftTransportDisconnectListener is a no-op implementation of the RaftTransportDisconnectListener interface.
NoopStoresFlowControlIntegration is a no-op implementation of the StoresForFlowControl interface.
OutgoingSnapshot contains the data required to stream a snapshot to a recipient.
PinnedLeasesKnob is a testing know for controlling what store can acquire a lease for specific ranges.
ProposalData is data about a command which allows it to be evaluated, proposed to raft, and for the result of the command to be returned to the caller.
RaftTransport handles the rpc messages for raft.
RaftTransportMetrics is the set of metrics for a given RaftTransport.
RaftTransportTestingKnobs provide fine-grained control over the RaftTransport for tests.
RebalanceContext maintains the current state for calls to rebalanceStore.
RebalanceObjectiveManager implements the RebalanceObjectiveProvider interface and registers a callback at creation time, that will be called on a reblanace objective change.
RemoveOptions bundles boolean parameters for Store.RemoveReplica.
A Replica is a contiguous keyspace with writes managed via an instance of the Raft consensus algorithm.
ReplicaDigest holds a summary of the replicated state on a replica.
ReplicaGCQueueMetrics is the set of metrics for the replica GC queue.
ReplicaMetrics contains details on the current status of the replica.
ReplicaPlaceholder represents a "lock" of a part of the keyspace on a given *Store for the receipt and application of a raft snapshot.
ReplicaRankingMap maintains top-k orderings of the replicas per tenant in a store by QPS.
ReplicaRankings maintains top-k orderings of the replicas in a store by QPS.
ReplicateQueueMetrics is the set of metrics for the replicate queue.
RRAccumulator is used to update the replicas tracked by ReplicaRankings.
RRAccumulatorByTenant accumulates replicas per tenant to update the replicas tracked by ReplicaRankingMap.
Server implements PerReplicaServer.
SpanSetReplicaEvalContext is a testing-only implementation of ReplicaEvalContext which verifies that access to state is registered in the SpanSet if one is given.
SplitQueueMetrics is the set of metrics for the split queue.
SSTSnapshotStorage provides an interface to create scratches and owns the directory of scratches created.
SSTSnapshotStorageFile is an SST file managed by a SSTSnapshotStorageScratch.
SSTSnapshotStorageScratch keeps track of the SST files incrementally created when receiving a snapshot.
StorageEngineClient is used to connect and make requests to a store.
A Store maintains a set of Replicas whose data is stored on a storage.Engine usually corresponding to a dedicated storage medium.
A StoreConfig encompasses the auxiliary objects and configuration required to create a store.
StoreGossip is responsible for gossiping the store descriptor.
StoreGossipTestingKnobs defines the testing knobs specific to StoreGossip.
StoreMetrics is the set of metrics for a given store.
StoreRebalancer is responsible for examining how the associated store's load compares to the load on other stores in the cluster and transferring leases or replicas away if the local store is overloaded.
StoreRebalancerMetrics is the set of metrics for the store-level rebalancer.
Stores provides methods to access a collection of stores.
StoreTestingKnobs is a part of the context used to control parts of the system.
TargetsForReplicationChanges is a grouped representation of a replication change.
TenantsStorageMetrics are metrics which are aggregated over all tenants present on the server.
TrackedRequestToken represents the result of propBuf.TrackEvaluatingRequest: a token to be later used for untracking the respective request.

# Interfaces

CandidateReplica is a replica that is being tracked as a potential candidate for rebalancing activities.
DBOrTxn is used to provide flexibility for logging rangelog events either transactionally (using a Txn), or non-transactionally (using a DB).
DiskStatsMonitor abstracts disk.Monitor for testing purposes.
IncomingRaftMessageHandler is the interface that must be implemented by arguments to RaftTransport.ListenIncomingRaftMessages.
InfoGossiper provides a method to add a message to gossip.
InspectAllStoreLiveness is an interface that allows for per-store Store Liveness state to be combined into a per-node view.
OutgoingRaftMessageHandler is the interface that must be implemented by arguments to RaftTransport.ListenOutgoingMessage.
PiggybackedAdmittedResponseScheduler routes followers piggybacked admitted response messages to the relevant ranges, and schedules those ranges for processing.
PurgatoryError indicates a replica processing failure which indicates the replica can be placed into purgatory for faster retries than the replica scanner's interval.
RaftMessageResponseStream is the subset of the MultiRaft_RaftMessageServer interface that is needed for sending responses.
RaftTransportDisconnectListener observes every instance of the raft transport disconnecting replication traffic to the given (remote) stores.
RangeLogWriter is used to write range log events to the rangelog table.
RangeRebalancer handles replica moves and lease transfers.
RebalanceObjectiveManager provides a method to get the rebalance objective of the cluster.
RelocateOneOptions contains methods that return the information necssary to generate the next suggested replication change for a relocate range command.
ReplicaLeaseMover handles lease transfers for a single range.
SnapshotResponseStream is the subset of the MultiRaft_RaftSnapshotServer interface that is needed for sending responses.
SnapshotStorePool narrows StorePool to make sendSnapshotUsingDelegate easier to test.
StoreDescriptorProvider provides a method to access the store descriptor.
StoresForFlowControl is used to integrate with replication flow control.
StoresForRACv2 implements various interfaces to route to the relevant range's Processor.
TimeSeriesDataStore is an interface defined in the storage package that can be implemented by the higher-level time series system.

# Type aliases

CapacityChangeEvent represents a change in a store's capacity for either leases or replicas.
DestroyReason indicates if a replica is alive, destroyed, corrupted or pending destruction.
IterationOrder specifies the order in which replicas will be iterated through by VisitKeyRange.
LBRebalancingMode controls if and when we do store-level rebalancing based on load.
LBRebalancingObjective controls the objective of load based rebalancing.
LeasePreferencesStatus represents the state of satisfying lease preferences.
RebalanceSearchOutcome returns the result of a rebalance target search.
ReplicaMutex is an RWMutex.
StoresForStoreLiveness is a wrapper around Stores that implements InspectAllStoreLiveness.
StoresIterator is the concrete implementation of kvserverbase.StoresIterator.
VisitReplicasOption optionally modifies store.VisitReplicas.