cockroach: github.com/cockroachdb/cockroach/pkg/base Index | Files

package base

import "github.com/cockroachdb/cockroach/pkg/base"

Index

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

Constants

const (

    // From IANA Service Name and Transport Protocol Port Number Registry. See
    // https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=cockroachdb
    //
    // 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"

    // DefaultTableDescriptorLeaseDuration 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.
    DefaultTableDescriptorLeaseDuration = 5 * time.Minute

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

    // DefaultTableDescriptorLeaseRenewalTimeout is the default time
    // before a lease expires when acquisition to renew the lease begins.
    DefaultTableDescriptorLeaseRenewalTimeout = 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"

    // 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.

Variables

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 = "https://www.cockroachlabs.com/docs/" + 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.

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 {
    syncutil.Mutex
    // 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 use SSL or not.
    // This is really not recommended.
    Insecure 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

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

    // 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.
    // See the comment in server.Config for more details.
    HistogramWindowInterval time.Duration

    // 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
    // contains filtered or unexported fields
}

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) CheckCertificateAddrs Uses

func (cfg *Config) CheckCertificateAddrs(ctx context.Context)

CheckCertificateAddrs validates the addresses inside the configured certificates to be compatible with the configured listen and advertise addresses. This is an advisory function (to inform/educate the user) and not a requirement for security. This must also be called after ValidateAddrs() and after the certificate manager was initialized.

func (*Config) GetCACertPath Uses

func (cfg *Config) GetCACertPath() (string, error)

GetCACertPath returns the path to the CA certificate.

func (*Config) GetCertificateManager Uses

func (cfg *Config) GetCertificateManager() (*security.CertificateManager, error)

GetCertificateManager returns the certificate manager, initializing it on the first call.

func (*Config) GetClientCertPaths Uses

func (cfg *Config) GetClientCertPaths(user string) (string, string, error)

GetClientCertPaths returns the paths to the client cert and key.

func (*Config) GetClientTLSConfig Uses

func (cfg *Config) GetClientTLSConfig() (*tls.Config, error)

GetClientTLSConfig returns the client TLS config, initializing it if needed. If Insecure is true, return a nil config, otherwise ask the certificate manager for a TLS config using certs for the config.User. This TLSConfig might **NOT** be suitable to talk to the Admin UI, use GetUIClientTLSConfig instead.

func (*Config) GetHTTPClient Uses

func (cfg *Config) GetHTTPClient() (http.Client, error)

GetHTTPClient returns the http client, initializing it if needed. It uses the client TLS config.

func (*Config) GetServerTLSConfig Uses

func (cfg *Config) GetServerTLSConfig() (*tls.Config, error)

GetServerTLSConfig returns the server TLS config, initializing it if needed. If Insecure is true, return a nil config, otherwise ask the certificate manager for a server TLS config.

func (*Config) GetUIClientTLSConfig Uses

func (cfg *Config) GetUIClientTLSConfig() (*tls.Config, error)

GetUIClientTLSConfig returns the client TLS config for Admin UI clients, initializing it if needed. If Insecure is true, return a nil config, otherwise ask the certificate manager for a TLS config configured to talk to the Admin UI. This TLSConfig is **NOT** suitable to talk to the GRPC or SQL servers, use GetClientTLSConfig instead.

func (*Config) GetUIServerTLSConfig Uses

func (cfg *Config) GetUIServerTLSConfig() (*tls.Config, error)

GetUIServerTLSConfig returns the server TLS config for the Admin UI, initializing it if needed. If Insecure is true, return a nil config, otherwise ask the certificate manager for a server UI TLS config.

func (*Config) HTTPRequestScheme Uses

func (cfg *Config) HTTPRequestScheme() string

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

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) InitializeNodeTLSConfigs Uses

func (cfg *Config) InitializeNodeTLSConfigs(
    stopper *stop.Stopper,
) (*security.CertificateManager, error)

InitializeNodeTLSConfigs tries to load client and server-side TLS configs. It also enables the reload-on-SIGHUP functionality on the certificate manager. This should be called early in the life of the server to make sure there are no issues with TLS configs. Returns the certificate manager if successfully created and in secure mode.

func (*Config) LoadSecurityOptions Uses

func (cfg *Config) LoadSecurityOptions(options url.Values, username string) error

LoadSecurityOptions extends a url.Values with SSL settings suitable for the given server config. It returns true if and only if the URL already contained SSL config options.

func (*Config) PGURL Uses

func (cfg *Config) PGURL(user *url.Userinfo) (*url.URL, error)

PGURL constructs a URL for the postgres endpoint, given a server config. There is no default database set.

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 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 {
    // TableDescriptorLeaseDuration is the mean duration a lease will be
    // acquired for.
    TableDescriptorLeaseDuration time.Duration

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

    // DefaultTableDescriptorLeaseRenewalTimeout is the default time
    // before a lease expires when acquisition to renew the lease begins.
    TableDescriptorLeaseRenewalTimeout time.Duration
}

LeaseManagerConfig holds table 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()
}

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

    // 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.
    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" messages 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 1 MB of raft log to be sent
    // without acknowledgement. With an average entry size of 1 KB that
    // translates to ~1024 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 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
    // 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) GetPreventedStartupMessage Uses

func (ssl StoreSpecList) GetPreventedStartupMessage() (string, error)

GetPreventedStartupMessage attempts to read the PreventedStartupFile for each store directory and returns their concatenated contents. 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
    // StoreIdx stores the index of the StoreSpec this TempStorageConfig will use.
    SpecIdx int
}

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 TempStorageConfigFromEnv Uses

func TempStorageConfigFromEnv(
    ctx context.Context,
    st *cluster.Settings,
    firstStore StoreSpec,
    parentDir string,
    maxSizeBytes int64,
    specIdx int,
) 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.
    ReplicationManual
)

func (TestClusterReplicationMode) String Uses

func (i TestClusterReplicationMode) String() string

type TestServerArgs Uses

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

    *cluster.Settings
    RaftConfig

    // 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

    // 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
    // HTTPAddr (if nonempty) is the HTTP address to use for the test server.
    HTTPAddr string

    // 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
    SocketFile                  string
    ScanInterval                time.Duration
    ScanMinIdleTime             time.Duration
    ScanMaxIdleTime             time.Duration
    SSLCertsDir                 string
    TimeSeriesQueryWorkerMax    int
    TimeSeriesQueryMemoryBudget int64
    SQLMemoryPoolSize           int64

    // 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
}

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 TestingKnobs Uses

type TestingKnobs struct {
    Store               ModuleTestingKnobs
    KVClient            ModuleTestingKnobs
    SQLExecutor         ModuleTestingKnobs
    SQLLeaseManager     ModuleTestingKnobs
    SQLSchemaChanger    ModuleTestingKnobs
    PGWireTestingKnobs  ModuleTestingKnobs
    SQLMigrationManager ModuleTestingKnobs
    DistSQL             ModuleTestingKnobs
    SQLEvalContext      ModuleTestingKnobs
    RegistryLiveness    ModuleTestingKnobs
    Server              ModuleTestingKnobs
}

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

Package base imports 37 packages (graph) and is imported by 359 packages. Updated 2019-11-20. Refresh now. Tools for package owners.