cockroach: Index | Files

package base

import ""


Package Files

addr_validation.go cluster_id.go config.go constants.go docs.go license.go node_id.go store_spec.go test_server_args.go testclusterreplicationmode_string.go testing_knobs.go zone.go


const (

    // From IANA Service Name and Transport Protocol Port Number Registry. See
    // This is used for both RPC and SQL connections unless --sql-addr
    // is used on the command line and/or SQLAddr is set in the Config object.
    DefaultPort = "26257"

    // The default port for HTTP-for-humans.
    DefaultHTTPPort = "8080"

    // NetworkTimeout is the timeout used for network operations.
    NetworkTimeout = 3 * time.Second

    // DefaultCertsDirectory is the default value for the cert directory flag.
    DefaultCertsDirectory = "${HOME}/.cockroach-certs"

    // NB: this can't easily become a variable as the UI hard-codes it to 10s.
    // See
    DefaultMetricsSampleInterval = 10 * time.Second

    // DefaultDescriptorLeaseDuration is the default mean duration a
    // lease will be acquired for. The actual duration is jittered using
    // the jitter fraction. Jittering is done to prevent multiple leases
    // from being renewed simultaneously if they were all acquired
    // simultaneously.
    DefaultDescriptorLeaseDuration = 5 * time.Minute

    // DefaultDescriptorLeaseJitterFraction is the default factor
    // that we use to randomly jitter the lease duration when acquiring a
    // new lease and the lease renewal timeout.
    DefaultDescriptorLeaseJitterFraction = 0.05

    // DefaultDescriptorLeaseRenewalTimeout is the default time
    // before a lease expires when acquisition to renew the lease begins.
    DefaultDescriptorLeaseRenewalTimeout = time.Minute

Base config defaults.

const (
    // DefaultTempStorageMaxSizeBytes is the default maximum budget
    // for temp storage.
    DefaultTempStorageMaxSizeBytes = 32 * 1024 * 1024 * 1024 /* 32GB */
    // DefaultInMemTempStorageMaxSizeBytes is the default maximum budget
    // for in-memory temp storages.
    DefaultInMemTempStorageMaxSizeBytes = 100 * 1024 * 1024 /* 100MB */
const (
    // DefaultMaxClockOffset is the default maximum acceptable clock offset value.
    // On Azure, clock offsets between 250ms and 500ms are common. On AWS and GCE,
    // clock offsets generally stay below 250ms. See comments on Config.MaxOffset
    // for more on this setting.
    DefaultMaxClockOffset = 500 * time.Millisecond

    // DefaultTxnHeartbeatInterval is how often heartbeats are sent from the
    // transaction coordinator to a live transaction. These keep it from
    // being preempted by other transactions writing the same keys. If a
    // transaction fails to be heartbeat within 5x the heartbeat interval,
    // it may be aborted by conflicting txns.
    DefaultTxnHeartbeatInterval = 1 * time.Second

    // SlowRequestThreshold is the amount of time to wait before considering a
    // request to be "slow".
    SlowRequestThreshold = 60 * time.Second

    // ChunkRaftCommandThresholdBytes is the threshold in bytes at which
    // to chunk or otherwise limit commands being sent to Raft.
    ChunkRaftCommandThresholdBytes = 256 * 1000

    // HeapProfileDir is the directory name where the heap profiler stores profiles
    // when there is a potential OOM situation.
    HeapProfileDir = "heap_profiler"

    // GoroutineDumpDir is the directory name where the goroutine dumper
    // stores dump when one of the dump heuristics is triggered.
    GoroutineDumpDir = "goroutine_dump"

    // MinRangeMaxBytes is the minimum value for range max bytes.
    MinRangeMaxBytes = 64 << 10 // 64 KB
const AuxiliaryDir = "auxiliary"

AuxiliaryDir is the path of the auxiliary dir relative to an engine.Engine's root directory. It must not be changed without a proper migration.

const MinimumStoreSize = 10 * 64 << 20

MinimumStoreSize is the smallest size in bytes that a store can have. This number is based on config's defaultZoneConfig's RangeMaxBytes, which is extremely stable. To avoid adding the dependency on config here, it is just hard coded to 640MiB.


var CheckEnterpriseEnabled = func(_ *cluster.Settings, _ uuid.UUID, org, feature string) error {
    return errors.New("OSS binaries do not include enterprise features")

CheckEnterpriseEnabled returns a non-nil error if the requested enterprise feature is not enabled, including information or a link explaining how to enable it.

This function is overridden by an init hook in CCL builds.

var (
    // DefaultTestStoreSpec is just a single in memory store of 100 MiB
    // with no special attributes.
    DefaultTestStoreSpec = StoreSpec{
        InMemory: true,
var DocsURLBase = "" + build.VersionPrefix()

DocsURLBase is the root URL for the version of the docs associated with this binary.

var LicenseType = func(st *cluster.Settings) (string, error) {
    return "OSS", nil

LicenseType returns what type of license the cluster is running with, or "OSS" if it is an OSS build.

This function is overridden by an init hook in CCL builds.

var TestingIDContainer = func() *SQLIDContainer {
    var c NodeIDContainer
    c.Set(context.Background(), 1)
    return NewSQLIDContainer(10, &c)

TestingIDContainer is an SQLIDContainer with hard-coded SQLInstanceID of 10 and NodeID of 1.

func DefaultHistogramWindowInterval Uses

func DefaultHistogramWindowInterval() time.Duration

DefaultHistogramWindowInterval returns the default rotation window for histograms.

func DefaultRetryOptions Uses

func DefaultRetryOptions() retry.Options

DefaultRetryOptions should be used for retrying most network-dependent operations.

func DocsURL Uses

func DocsURL(pageName string) string

DocsURL generates the URL to pageName in the version of the docs associated with this binary.

func GetAbsoluteStorePath Uses

func GetAbsoluteStorePath(fieldName string, p string) (string, error)

GetAbsoluteStorePath takes a (possibly relative) and returns the absolute path. Returns an error if the path begins with '~' or Abs fails. 'fieldName' is used in error strings.

func LookupAddr Uses

func LookupAddr(ctx context.Context, resolver *net.Resolver, host string) (string, error)

LookupAddr resolves the given address/host to an IP address. If multiple addresses are resolved, it returns the first IPv4 address available if there is one, otherwise the first address.

func PreventedStartupFile Uses

func PreventedStartupFile(dir string) string

PreventedStartupFile is the filename (relative to 'dir') used for files that can block server startup.

func UpdateAddrs Uses

func UpdateAddrs(ctx context.Context, addr, advAddr *string, ln net.Addr) error

UpdateAddrs updates the listen and advertise port numbers with those found during the call to net.Listen().

After ValidateAddrs() the actual listen addr should be equal to the one requested; only the port number can change because of auto-allocation. We do check this equality here and report a warning if any discrepancy is found.

type ClusterIDContainer Uses

type ClusterIDContainer struct {
    // contains filtered or unexported fields

ClusterIDContainer is used to share a single Cluster ID instance between multiple layers. It allows setting and getting the value. Once a value is set, the value cannot change.

The cluster ID is determined on startup as follows: - If there are existing stores, their cluster ID is used. - If the node is bootstrapping, a new UUID is generated. - Otherwise, it is determined via gossip with other nodes.

func (*ClusterIDContainer) Get Uses

func (c *ClusterIDContainer) Get() uuid.UUID

Get returns the current cluster ID; uuid.Nil if it is unset.

func (*ClusterIDContainer) Reset Uses

func (c *ClusterIDContainer) Reset(val uuid.UUID)

Reset changes the ClusterID regardless of the old value.

Should only be used in testing code.

func (*ClusterIDContainer) Set Uses

func (c *ClusterIDContainer) Set(ctx context.Context, val uuid.UUID)

Set sets the current cluster ID. If it is already set, the value must match.

func (*ClusterIDContainer) String Uses

func (c *ClusterIDContainer) String() string

String returns the cluster ID, or "?" if it is unset.

type Config Uses

type Config struct {
    // Insecure specifies whether to disable security checks throughout
    // the code base.
    // This is really not recommended.
    // See:
    Insecure bool

    // AcceptSQLWithoutTLS, when set, makes it possible for SQL
    // clients to authenticate without TLS on a secure cluster.
    // Authentication is, as usual, subject to the HBA configuration: in
    // the default case, password authentication is still mandatory.
    AcceptSQLWithoutTLS bool

    // SSLCAKey is used to sign new certs.
    SSLCAKey string
    // SSLCertsDir is the path to the certificate/key directory.
    SSLCertsDir string

    // User running this process. It could be the user under which
    // the server is running or the user passed in client calls.
    User string

    // Addr is the address the server is listening on.
    Addr string

    // AdvertiseAddr is the address advertised by the server to other nodes
    // in the cluster. It should be reachable by all other nodes and should
    // route to an interface that Addr is listening on.
    AdvertiseAddr string

    // ClusterName is the name used as a sanity check when a node joins
    // an uninitialized cluster, or when an uninitialized node joins an
    // initialized cluster. The initial RPC handshake verifies that the
    // name matches on both sides. Once the cluster ID has been
    // negotiated on both sides, the cluster name is not used any more.
    ClusterName string

    // DisableClusterNameVerification, when set, alters the cluster name
    // verification to only verify that a non-empty cluster name on
    // both sides match. This is meant for use while rolling an
    // existing cluster into using a new cluster name.
    DisableClusterNameVerification bool

    // SplitListenSQL indicates whether to listen for SQL
    // clients on a separate address from RPC requests.
    SplitListenSQL bool

    // SQLAddr is the configured SQL listen address.
    // This is used if SplitListenSQL is set to true.
    SQLAddr string

    // SQLAdvertiseAddr is the advertised SQL address.
    // This is computed from SQLAddr if specified otherwise Addr.
    SQLAdvertiseAddr string

    // HTTPAddr is the configured HTTP listen address.
    HTTPAddr string

    // DisableTLSForHTTP, if set, disables TLS for the HTTP listener.
    DisableTLSForHTTP bool

    // HTTPAdvertiseAddr is the advertised HTTP address.
    // This is computed from HTTPAddr if specified otherwise Addr.
    HTTPAdvertiseAddr string

    // RPCHeartbeatInterval controls how often a Ping request is sent on peer
    // connections to determine connection health and update the local view
    // of remote clocks.
    RPCHeartbeatInterval time.Duration

    // Enables the use of an PTP hardware clock user space API for HLC current time.
    // This contains the path to the device to be used (i.e. /dev/ptp0)
    ClockDevicePath string

    // AutoInitializeCluster, if set, causes the server to bootstrap the
    // cluster. Note that if two nodes are started with this flag set
    // and also configured to join each other, each node will bootstrap
    // its own unique cluster and the join will fail.
    // The flag exists mostly for the benefit of tests, and for
    // `cockroach start-single-node`.
    AutoInitializeCluster bool

Config is embedded by server.Config. A base config is not meant to be used directly, but embedding configs should call cfg.InitDefaults().

func (*Config) AdminURL Uses

func (cfg *Config) AdminURL() *url.URL

AdminURL returns the URL for the admin UI.

func (*Config) HTTPRequestScheme Uses

func (cfg *Config) HTTPRequestScheme() string

HTTPRequestScheme returns "http" or "https" based on the value of Insecure and DisableTLSForHTTP.

func (*Config) HistogramWindowInterval Uses

func (*Config) HistogramWindowInterval() time.Duration

HistogramWindowInterval is used to determine the approximate length of time that individual samples are retained in in-memory histograms. Currently, it is set to the arbitrary length of six times the Metrics sample interval.

The length of the window must be longer than the sampling interval due to issue #12998, which was causing histograms to return zero values when sampled because all samples had been evicted.

Note that this is only intended to be a temporary fix for the above issue, as our current handling of metric histograms have numerous additional problems. These are tracked in github issue #7896, which has been given a relatively high priority in light of recent confusion around histogram metrics. For more information on the issues underlying our histogram system and the proposed fixes, please see issue #7896.

func (*Config) InitDefaults Uses

func (cfg *Config) InitDefaults()

InitDefaults sets up the default values for a config. This is also used in tests to reset global objects.

func (*Config) ValidateAddrs Uses

func (cfg *Config) ValidateAddrs(ctx context.Context) error

ValidateAddrs controls the address fields in the Config object and "fills in" the blanks: - the host part of Addr and HTTPAddr is resolved to an IP address

if specified (it stays blank if blank to mean "all addresses").

- the host part of AdvertiseAddr is filled in if blank, either

from Addr if non-empty or os.Hostname(). It is also checked
for resolvability.

- non-numeric port numbers are resolved to numeric.

The addresses fields must be guaranteed by the caller to either be completely empty, or have both a host part and a port part separated by a colon. In the latter case either can be empty to indicate it's left unspecified.

type ExternalIODirConfig Uses

type ExternalIODirConfig struct {
    // Disables the use of external HTTP endpoints.
    // This turns off http:// external storage as well as any custom
    // endpoints cloud storage implementations.
    DisableHTTP bool
    // Disables the use of implicit credentials when accessing external services.
    // Implicit credentials are obtained from the system environment.
    // This turns off implicit credentials, and requires the user to provide
    // necessary access keys.
    DisableImplicitCredentials bool

ExternalIODirConfig describes various configuration options pertaining to external storage implementations. TODO(adityamaru): Rename ExternalIODirConfig to ExternalIOConfig because it is now used to configure both ExternalStorage and KMS.

type JoinListType Uses

type JoinListType []string

JoinListType is a slice of strings that implements pflag's value interface.

func (*JoinListType) Set Uses

func (jls *JoinListType) Set(value string) error

Set adds a new value to the JoinListType. It is the important part of pflag's value interface.

func (JoinListType) String Uses

func (jls JoinListType) String() string

String returns a string representation of all the JoinListType. This is part of pflag's value interface.

func (*JoinListType) Type Uses

func (jls *JoinListType) Type() string

Type returns the underlying type in string form. This is part of pflag's value interface.

type LeaseManagerConfig Uses

type LeaseManagerConfig struct {
    // DescriptorLeaseDuration is the mean duration a lease will be
    // acquired for.
    DescriptorLeaseDuration time.Duration

    // DescriptorLeaseJitterFraction is the factor that we use to
    // randomly jitter the lease duration when acquiring a new lease and
    // the lease renewal timeout.
    DescriptorLeaseJitterFraction float64

    // DefaultDescriptorLeaseRenewalTimeout is the default time
    // before a lease expires when acquisition to renew the lease begins.
    DescriptorLeaseRenewalTimeout time.Duration

LeaseManagerConfig holds lease manager parameters.

func NewLeaseManagerConfig Uses

func NewLeaseManagerConfig() *LeaseManagerConfig

NewLeaseManagerConfig initializes a LeaseManagerConfig with default values.

type ModuleTestingKnobs Uses

type ModuleTestingKnobs interface {
    // ModuleTestingKnobs is a dummy function.

ModuleTestingKnobs is an interface for testing knobs for a submodule.

type NodeIDContainer Uses

type NodeIDContainer struct {
    // contains filtered or unexported fields

NodeIDContainer is used to share a single roachpb.NodeID instance between multiple layers. It allows setting and getting the value. Once a value is set, the value cannot change.

func (*NodeIDContainer) Get Uses

func (n *NodeIDContainer) Get() roachpb.NodeID

Get returns the current node ID; 0 if it is unset.

func (*NodeIDContainer) Reset Uses

func (n *NodeIDContainer) Reset(val roachpb.NodeID)

Reset changes the NodeID regardless of the old value.

Should only be used in testing code.

func (*NodeIDContainer) SafeFormat Uses

func (n *NodeIDContainer) SafeFormat(w redact.SafePrinter, _ rune)

SafeFormat implements the redact.SafeFormatter interface.

func (*NodeIDContainer) Set Uses

func (n *NodeIDContainer) Set(ctx context.Context, val roachpb.NodeID)

Set sets the current node ID. If it is already set, the value must match.

func (*NodeIDContainer) String Uses

func (n *NodeIDContainer) String() string

String returns the node ID, or "?" if it is unset.

type RaftConfig Uses

type RaftConfig struct {
    // RaftTickInterval is the resolution of the Raft timer.
    RaftTickInterval time.Duration

    // RaftElectionTimeoutTicks is the number of raft ticks before the
    // previous election expires. This value is inherited by individual stores
    // unless overridden.
    RaftElectionTimeoutTicks int

    // RaftHeartbeatIntervalTicks is the number of ticks that pass between heartbeats.
    RaftHeartbeatIntervalTicks int

    // RangeLeaseRaftElectionTimeoutMultiplier specifies what multiple the leader
    // lease active duration should be of the raft election timeout.
    RangeLeaseRaftElectionTimeoutMultiplier float64

    // RaftLogTruncationThreshold controls how large a single Range's Raft log
    // can grow. When a Range's Raft log grows above this size, the Range will
    // begin performing log truncations.
    RaftLogTruncationThreshold int64

    // RaftProposalQuota controls the maximum aggregate size of Raft commands
    // that a leader is allowed to propose concurrently.
    // By default, the quota is set to a fraction of the Raft log truncation
    // threshold. In doing so, we ensure all replicas have sufficiently up to
    // date logs so that when the log gets truncated, the followers do not need
    // non-preemptive snapshots. Changing this deserves care. Too low and
    // everything comes to a grinding halt, too high and we're not really
    // throttling anything (we'll still generate snapshots).
    RaftProposalQuota int64

    // RaftMaxUncommittedEntriesSize controls how large the uncommitted tail of
    // the Raft log can grow. The limit is meant to provide protection against
    // unbounded Raft log growth when quorum is lost and entries stop being
    // committed but continue to be proposed.
    RaftMaxUncommittedEntriesSize uint64

    // RaftMaxSizePerMsg controls the maximum aggregate byte size of Raft log
    // entries the leader will send to followers in a single MsgApp. Smaller
    // value lowers the raft recovery cost (during initial probing and after
    // message loss during normal operation). On the other hand, it limits the
    // throughput during normal replication.
    RaftMaxSizePerMsg uint64

    // RaftMaxCommittedSizePerReady controls the maximum aggregate byte size of
    // committed Raft log entries a replica will receive in a single Ready.
    RaftMaxCommittedSizePerReady uint64

    // RaftMaxInflightMsgs controls how many "inflight" MsgApps Raft will send
    // to a follower without hearing a response. The total number of Raft log
    // entries is a combination of this setting and RaftMaxSizePerMsg. The
    // current default settings provide for up to 4 MB of raft log to be sent
    // without acknowledgement. With an average entry size of 1 KB that
    // translates to ~4096 commands that might be executed in the handling of a
    // single raft.Ready operation.
    RaftMaxInflightMsgs int

    // Splitting a range which has a replica needing a snapshot results in two
    // ranges in that state. The delay configured here slows down splits when in
    // that situation (limiting to those splits not run through the split
    // queue). The most important target here are the splits performed by
    // backup/restore.
    // -1 to disable.
    RaftDelaySplitToSuppressSnapshotTicks int

RaftConfig holds raft tuning parameters.

func (RaftConfig) NodeLivenessDurations Uses

func (cfg RaftConfig) NodeLivenessDurations() (livenessActive, livenessRenewal time.Duration)

NodeLivenessDurations computes durations for node liveness expiration and renewal based on a default multiple of Raft election timeout.

func (RaftConfig) RaftElectionTimeout Uses

func (cfg RaftConfig) RaftElectionTimeout() time.Duration

RaftElectionTimeout returns the raft election timeout, as computed from the tick interval and number of election timeout ticks.

func (RaftConfig) RangeLeaseActiveDuration Uses

func (cfg RaftConfig) RangeLeaseActiveDuration() time.Duration

RangeLeaseActiveDuration is the duration of the active period of leader leases requested.

func (RaftConfig) RangeLeaseDurations Uses

func (cfg RaftConfig) RangeLeaseDurations() (rangeLeaseActive, rangeLeaseRenewal time.Duration)

RangeLeaseDurations computes durations for range lease expiration and renewal based on a default multiple of Raft election timeout.

func (RaftConfig) RangeLeaseRenewalDuration Uses

func (cfg RaftConfig) RangeLeaseRenewalDuration() time.Duration

RangeLeaseRenewalDuration specifies a time interval at the end of the active lease interval (i.e. bounded to the right by the start of the stasis period) during which operations will trigger an asynchronous renewal of the lease.

func (RaftConfig) SentinelGossipTTL Uses

func (cfg RaftConfig) SentinelGossipTTL() time.Duration

SentinelGossipTTL is time-to-live for the gossip sentinel. The sentinel informs a node whether or not it's connected to the primary gossip network and not just a partition. As such it must expire fairly quickly and be continually re-gossiped as a connected gossip network is necessary to propagate liveness. The replica which is the lease holder of the first range gossips it.

func (*RaftConfig) SetDefaults Uses

func (cfg *RaftConfig) SetDefaults()

SetDefaults initializes unset fields.

type SQLIDContainer Uses

type SQLIDContainer struct {
    // contains filtered or unexported fields

SQLIDContainer wraps a SQLInstanceID and optionally a NodeID.

func NewSQLIDContainer Uses

func NewSQLIDContainer(sqlInstanceID SQLInstanceID, nodeID *NodeIDContainer) *SQLIDContainer

NewSQLIDContainer sets up an SQLIDContainer. It is handed either a positive SQLInstanceID (on tenants) or a positive NodeID, but not both.

A zero sqlInstanceID falls back to the NodeID in SQLInstanceID(). This is used in single-tenant deployments.

func (*SQLIDContainer) OptionalNodeID Uses

func (c *SQLIDContainer) OptionalNodeID() (roachpb.NodeID, bool)

OptionalNodeID returns the NodeID and true, if the former is exposed. Otherwise, returns zero and false.

func (*SQLIDContainer) OptionalNodeIDErr Uses

func (c *SQLIDContainer) OptionalNodeIDErr(issue int) (roachpb.NodeID, error)

OptionalNodeIDErr is like OptionalNodeID, but returns an error (referring to the optionally supplied Github issues) if the ID is not present.

func (*SQLIDContainer) SQLInstanceID Uses

func (c *SQLIDContainer) SQLInstanceID() SQLInstanceID

SQLInstanceID returns the wrapped SQLInstanceID.

type SQLInstanceID Uses

type SQLInstanceID int32

A SQLInstanceID is an ephemeral ID assigned to a running instance of the SQL server. This is distinct from a NodeID, which is a long-lived identifier assigned to a node in the KV layer which is unique across all KV nodes in the cluster and persists across restarts. Instead, a Instance is similar to a process ID from the unix world: an integer assigned to the SQL server on process start which is unique across all SQL server processes running on behalf of the tenant, while the SQL server is running.

NB: until is addressed, the properties of the SQLInstanceID hold trivially due to the constraint that only one SQL server must be running on behalf of the tenant at any given time. After that, it's likely that we'll allocate these IDs off a counter, so they will be completely unique (per tenant).

func (SQLInstanceID) String Uses

func (s SQLInstanceID) String() string

type SizeSpec Uses

type SizeSpec struct {
    // InBytes is used for calculating free space and making rebalancing
    // decisions. Zero indicates that there is no maximum size. This value is not
    // actually used by the engine and thus not enforced.
    InBytes int64
    Percent float64

SizeSpec contains size in different kinds of formats supported by CLI(%age, bytes).

func NewSizeSpec Uses

func NewSizeSpec(
    value string, bytesRange *intInterval, percentRange *floatInterval,
) (SizeSpec, error)

NewSizeSpec parses the string passed into a --size flag and returns a SizeSpec if it is correctly parsed.

func (*SizeSpec) Set Uses

func (ss *SizeSpec) Set(value string) error

Set adds a new value to the StoreSpecValue. It is the important part of pflag's value interface.

func (*SizeSpec) String Uses

func (ss *SizeSpec) String() string

String returns a string representation of the SizeSpec. This is part of pflag's value interface.

func (*SizeSpec) Type Uses

func (ss *SizeSpec) Type() string

Type returns the underlying type in string form. This is part of pflag's value interface.

type StorageConfig Uses

type StorageConfig struct {
    Attrs roachpb.Attributes
    // Dir is the data directory for the Pebble instance.
    Dir string
    // If true, creating the instance fails if the target directory does not hold
    // an initialized instance.
    // Makes no sense for in-memory instances.
    MustExist bool
    // MaxSize is used for calculating free space and making rebalancing
    // decisions. Zero indicates that there is no maximum size.
    MaxSize int64
    // Settings instance for cluster-wide knobs.
    Settings *cluster.Settings
    // UseFileRegistry is true if the file registry is needed (eg: encryption-at-rest).
    // This may force the store version to versionFileRegistry if currently lower.
    UseFileRegistry bool
    // ExtraOptions is a serialized protobuf set by Go CCL code and passed through
    // to C CCL code.
    ExtraOptions []byte

StorageConfig contains storage configs for all storage engine.

type StoreSpec Uses

type StoreSpec struct {
    Path       string
    Size       SizeSpec
    InMemory   bool
    Attributes roachpb.Attributes
    // StickyInMemoryEngineID is a unique identifier associated with a given
    // store which will remain in memory even after the default Engine close
    // until it has been explicitly cleaned up by CleanupStickyInMemEngine[s]
    // or the process has been terminated.
    // This only applies to in-memory storage engine.
    StickyInMemoryEngineID string
    // UseFileRegistry is true if the "file registry" store version is desired.
    // This is set by CCL code when encryption-at-rest is in use.
    UseFileRegistry bool
    // RocksDBOptions contains RocksDB specific options using a semicolon
    // separated key-value syntax ("key1=value1; key2=value2").
    RocksDBOptions string
    // PebbleOptions contains Pebble-specific options in the same format as a
    // Pebble OPTIONS file but treating any whitespace as a newline:
    // (Eg, "[Options] delete_range_flush_delay=2s flush_split_bytes=4096")
    PebbleOptions string
    // ExtraOptions is a serialized protobuf set by Go CCL code and passed through
    // to C CCL code.
    ExtraOptions []byte

StoreSpec contains the details that can be specified in the cli pertaining to the --store flag.

func NewStoreSpec Uses

func NewStoreSpec(value string) (StoreSpec, error)

NewStoreSpec parses the string passed into a --store flag and returns a StoreSpec if it is correctly parsed. There are four possible fields that can be passed in, comma separated: - path=xxx The directory in which to the rocks db instance should be

located, required unless using a in memory storage.

- type=mem This specifies that the store is an in memory storage instead of

an on disk one. mem is currently the only other type available.

- size=xxx The optional maximum size of the storage. This can be in one of a

few different formats.
- 10000000000     -> 10000000000 bytes
- 20GB            -> 20000000000 bytes
- 20GiB           -> 21474836480 bytes
- 0.02TiB         -> 21474836480 bytes
- 20%             -> 20% of the available space
- 0.2             -> 20% of the available space

- attrs=xxx:yyy:zzz A colon separated list of optional attributes. Note that commas are forbidden within any field name or value.

func (StoreSpec) PreventedStartupFile Uses

func (ss StoreSpec) PreventedStartupFile() string

PreventedStartupFile returns the path to a file which, if it exists, should prevent the server from starting up. Returns an empty string for in-memory engines.

func (StoreSpec) String Uses

func (ss StoreSpec) String() string

String returns a fully parsable version of the store spec.

type StoreSpecList Uses

type StoreSpecList struct {
    Specs []StoreSpec
    // contains filtered or unexported fields

StoreSpecList contains a slice of StoreSpecs that implements pflag's value interface.

func (StoreSpecList) PriorCriticalAlertError Uses

func (ssl StoreSpecList) PriorCriticalAlertError() (err error)

PriorCriticalAlertError attempts to read the PreventedStartupFile for each store directory and returns their contents as a structured error.

These files typically request operator intervention after a corruption event by preventing the affected node(s) from starting back up.

func (*StoreSpecList) Set Uses

func (ssl *StoreSpecList) Set(value string) error

Set adds a new value to the StoreSpecValue. It is the important part of pflag's value interface.

func (StoreSpecList) String Uses

func (ssl StoreSpecList) String() string

String returns a string representation of all the StoreSpecs. This is part of pflag's value interface.

func (*StoreSpecList) Type Uses

func (ssl *StoreSpecList) Type() string

Type returns the underlying type in string form. This is part of pflag's value interface.

type SubzoneID Uses

type SubzoneID uint32

SubzoneID represents a subzone within a zone. It's the subzone's index within the parent zone + 1; there's no subzone 0 so that 0 can be used as a sentinel.

func SubzoneIDFromIndex Uses

func SubzoneIDFromIndex(idx int) SubzoneID

SubzoneIDFromIndex turns a subzone's index within its parent zone into its SubzoneID.

func (SubzoneID) ToSubzoneIndex Uses

func (id SubzoneID) ToSubzoneIndex() int32

ToSubzoneIndex turns a SubzoneID into the index corresponding to the correct Subzone within the parent zone's Subzones slice.

type TempStorageConfig Uses

type TempStorageConfig struct {
    // InMemory specifies whether the temporary storage will remain
    // in-memory or occupy a temporary subdirectory on-disk.
    InMemory bool
    // Path is the filepath of the temporary subdirectory created for
    // the temp storage.
    Path string
    // Mon will be used by the temp storage to register all its capacity requests.
    // It can be used to limit the disk or memory that temp storage is allowed to
    // use. If InMemory is set, than this has to be a memory monitor; otherwise it
    // has to be a disk monitor.
    Mon *mon.BytesMonitor
    // Spec stores the StoreSpec this TempStorageConfig will use.
    Spec StoreSpec

TempStorageConfig contains the details that can be specified in the cli pertaining to temp storage flags, specifically --temp-dir and --max-disk-temp-storage.

func DefaultTestTempStorageConfig Uses

func DefaultTestTempStorageConfig(st *cluster.Settings) TempStorageConfig

DefaultTestTempStorageConfig is the associated temp storage for DefaultTestStoreSpec that is in-memory. It has a maximum size of 100MiB.

func DefaultTestTempStorageConfigWithSize Uses

func DefaultTestTempStorageConfigWithSize(
    st *cluster.Settings, maxSizeBytes int64,
) TempStorageConfig

DefaultTestTempStorageConfigWithSize is the associated temp storage for DefaultTestStoreSpec that is in-memory with the customized maximum size.

func TempStorageConfigFromEnv Uses

func TempStorageConfigFromEnv(
    ctx context.Context,
    st *cluster.Settings,
    useStore StoreSpec,
    parentDir string,
    maxSizeBytes int64,
) TempStorageConfig

TempStorageConfigFromEnv creates a TempStorageConfig. If parentDir is not specified and the specified store is in-memory, then the temp storage will also be in-memory.

type TestClusterArgs Uses

type TestClusterArgs struct {
    // ServerArgs will be copied and potentially adjusted according to the
    // ReplicationMode for each constituent TestServer. Used for all the servers
    // not overridden in ServerArgsPerNode.
    ServerArgs TestServerArgs
    // ReplicationMode controls how replication is to be done in the cluster.
    ReplicationMode TestClusterReplicationMode
    // If true, nodes will be started in parallel. This is useful in
    // testing certain recovery scenarios, although it makes store/node
    // IDs unpredictable. Even in ParallelStart mode, StartTestCluster
    // waits for all nodes to start before returning.
    ParallelStart bool

    // ServerArgsPerNode override the default ServerArgs with the value in this
    // map. The map's key is an index within TestCluster.Servers. If there is
    // no entry in the map for a particular server, the default ServerArgs are
    // used.
    // A copy of an entry from this map will be copied to each individual server
    // and potentially adjusted according to ReplicationMode.
    ServerArgsPerNode map[int]TestServerArgs

TestClusterArgs contains the parameters one can set when creating a test cluster. It contains a TestServerArgs instance which will be copied over to every server.

The zero value means "ReplicationAuto".

type TestClusterReplicationMode Uses

type TestClusterReplicationMode int

TestClusterReplicationMode represents the replication settings for a TestCluster.

const (
    // ReplicationAuto means that ranges are replicated according to the
    // production default zone config. Replication is performed as in
    // production, by the replication queue.
    // If ReplicationAuto is used, StartTestCluster() blocks until the initial
    // ranges are fully replicated.
    ReplicationAuto TestClusterReplicationMode = iota
    // ReplicationManual means that the split and replication queues of all
    // servers are stopped, and the test must manually control splitting and
    // replication through the TestServer.
    // Note that the server starts with a number of system ranges,
    // all with a single replica on node 1.

func (TestClusterReplicationMode) String Uses

func (i TestClusterReplicationMode) String() string

type TestServerArgs Uses

type TestServerArgs struct {
    // Knobs for the test server.
    Knobs TestingKnobs


    // LeaseManagerConfig holds configuration values specific to the LeaseManager.
    LeaseManagerConfig *LeaseManagerConfig

    // PartOfCluster must be set if the TestServer is joining others in a cluster.
    // If not set (and hence the server is the only one in the cluster), the
    // default zone config will be overridden to disable all replication - so that
    // tests don't get log spam about ranges not being replicated enough. This
    // is always set to true when the server is started via a TestCluster.
    PartOfCluster bool

    // Listener (if nonempty) is the listener to use for all incoming RPCs.
    // If a listener is installed, it informs the RPC `Addr` used below. The
    // Server itself knows to close it out. This is useful for when a test wants
    // manual control over how the join flags (`JoinAddr`) are populated, and
    // installs listeners manually to know which addresses to point to.
    Listener net.Listener

    // Addr (if nonempty) is the RPC address to use for the test server.
    Addr string
    // SQLAddr (if nonempty) is the SQL address to use for the test server.
    SQLAddr string
    // TenantAddr is the tenant KV address to use for the test server. If this
    // is nil, the tenant server will be set up using a random port. If this
    // is the empty string, no tenant server will be set up.
    TenantAddr *string
    // HTTPAddr (if nonempty) is the HTTP address to use for the test server.
    HTTPAddr string
    // DisableTLSForHTTP if set, disables TLS for the HTTP interface.
    DisableTLSForHTTP bool

    // JoinAddr is the address of a node we are joining.
    // If left empty and the TestServer is being added to a nonempty cluster, this
    // will be set to the the address of the cluster's first node.
    JoinAddr string

    // StoreSpecs define the stores for this server. If you want more than
    // one store per node, populate this array with StoreSpecs each
    // representing a store. If no StoreSpecs are provided then a single
    // DefaultTestStoreSpec will be used.
    StoreSpecs []StoreSpec

    // Locality is optional and will set the server's locality.
    Locality roachpb.Locality

    // TempStorageConfig defines parameters for the temp storage used as
    // working memory for distributed operations and CSV importing.
    // If not initialized, will default to DefaultTestTempStorageConfig.
    TempStorageConfig TempStorageConfig

    // ExternalIODir is used to initialize field in cluster.Settings.
    ExternalIODir string

    // Fields copied to the server.Config.
    Insecure                    bool
    RetryOptions                retry.Options // TODO(tbg): make testing knob.
    SocketFile                  string
    ScanInterval                time.Duration
    ScanMinIdleTime             time.Duration
    ScanMaxIdleTime             time.Duration
    SSLCertsDir                 string
    TimeSeriesQueryWorkerMax    int
    TimeSeriesQueryMemoryBudget int64
    SQLMemoryPoolSize           int64
    CacheSize                   int64

    // By default, test servers have AutoInitializeCluster=true set in
    // their config. If NoAutoInitializeCluster is set, that behavior is disabled
    // and the test becomes responsible for initializing the cluster.
    NoAutoInitializeCluster bool

    // If set, this will be appended to the Postgres URL by functions that
    // automatically open a connection to the server. That's equivalent to running
    // SET DATABASE=foo, which works even if the database doesn't (yet) exist.
    UseDatabase string

    // If set, this will be configured in the test server to check connections
    // from other test servers and to report in the SQL introspection.
    ClusterName string

    // Stopper can be used to stop the server. If not set, a stopper will be
    // constructed and it can be gotten through TestServerInterface.Stopper().
    Stopper *stop.Stopper

    // If set, the recording of events to the event log tables is disabled.
    DisableEventLog bool

    // If set, web session authentication will be disabled, even if the server
    // is running in secure mode.
    DisableWebSessionAuthentication bool

    // If set, testing specific descriptor validation will be disabled. even if the server
    DisableTestingDescriptorValidation bool

TestServerArgs contains the parameters one can set when creating a test server. Notably, TestServerArgs are passed to serverutils.StartServer(). They're defined in base because they need to be shared between testutils/serverutils (test code) and server.TestServer (non-test code).

The zero value is suitable for most tests.

type TestTenantArgs Uses

type TestTenantArgs struct {
    TenantID roachpb.TenantID

    // TenantInfo is the metadata used if creating a tenant.
    TenantInfo []byte

    // Existing, if true, indicates an existing tenant, rather than a new tenant
    // to be created by StartTenant.
    Existing bool

    // AllowSettingClusterSettings, if true, allows the tenant to set in-memory
    // cluster settings.
    AllowSettingClusterSettings bool

    // TenantIDCodecOverride overrides the tenant ID used to construct the SQL
    // server's codec, but nothing else (e.g. its certs). Used for testing.
    TenantIDCodecOverride roachpb.TenantID

TestTenantArgs are the arguments used when creating a tenant from a TestServer.

type TestingKnobs Uses

type TestingKnobs struct {
    Store                ModuleTestingKnobs
    KVClient             ModuleTestingKnobs
    SQLExecutor          ModuleTestingKnobs
    SQLLeaseManager      ModuleTestingKnobs
    SQLSchemaChanger     ModuleTestingKnobs
    SQLTypeSchemaChanger ModuleTestingKnobs
    GCJob                ModuleTestingKnobs
    PGWireTestingKnobs   ModuleTestingKnobs
    SQLMigrationManager  ModuleTestingKnobs
    DistSQL              ModuleTestingKnobs
    SQLEvalContext       ModuleTestingKnobs
    RegistryLiveness     ModuleTestingKnobs
    Server               ModuleTestingKnobs
    TenantTestingKnobs   ModuleTestingKnobs
    JobsTestingKnobs     ModuleTestingKnobs
    BackupRestore        ModuleTestingKnobs

TestingKnobs contains facilities for controlling various parts of the system for testing.

Package base imports 36 packages (graph) and is imported by 978 packages. Updated 2020-09-26. Refresh now. Tools for package owners.