cockroach: github.com/cockroachdb/cockroach/pkg/server Index | Files | Directories

package server

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

Package server implements the Cockroach storage node. A node corresponds to a single instance of the cockroach binary, running on a single physical machine, which exports the "Node" Go RPC service. Each node multiplexes RPC requests to one or more stores, associated with physical storage devices.

Package server also provides access to administrative tools via the command line and also through a REST API.

Index

Package Files

admin.go api_error.go authentication.go config.go config_unix.go doc.go grpc_server.go init.go node.go node_engine_health.go problem_ranges.go rlimit_unix.go server.go server_systemlog_gc.go server_update.go settingsworker.go statements.go status.go sticky_engine.go testing_knobs.go testserver.go updates.go

Constants

const (
    // DefaultCacheSize is the default size of the RocksDB and Pebble caches. We
    // default the cache size and SQL memory pool size to 128 MiB. Larger values
    // might provide significantly better performance, but we're not sure what
    // type of system we're running on (development or production or some shared
    // environment). Production users should almost certainly override these
    // settings and we'll warn in the logs about doing so.
    DefaultCacheSize = 128 << 20 // 128 MB

    // NB: this can't easily become a variable as the UI hard-codes it to 10s.
    // See https://github.com/cockroachdb/cockroach/issues/20310.
    DefaultMetricsSampleInterval   = 10 * time.Second
    DefaultHistogramWindowInterval = 6 * DefaultMetricsSampleInterval

    // TempDirPrefix is the filename prefix of any temporary subdirectory
    // created.
    TempDirPrefix = "cockroach-temp"
    // TempDirsRecordFilename is the filename for the record file
    // that keeps track of the paths of the temporary directories created.
    TempDirsRecordFilename = "temp-dirs-record.txt"
)

Context defaults.

const (

    // FirstNodeID is the node ID of the first node in a new cluster.
    FirstNodeID = 1
)
const (
    // TestUser is a fixed user used in unittests.
    // It has valid embedded client certs.
    TestUser = "testuser"
)

Variables

var ErrClusterInitialized = fmt.Errorf("cluster has already been initialized")

ErrClusterInitialized is reported when the Boostrap RPC is ran on a node already part of an initialized cluster.

var (

    // GracefulDrainModes is the standard succession of drain modes entered
    // for a graceful shutdown.
    GracefulDrainModes = []serverpb.DrainMode{serverpb.DrainMode_CLIENT, serverpb.DrainMode_LEASES}
)
var TestServerFactory = testServerFactoryImpl{}

TestServerFactory can be passed to serverutils.InitTestServerFactory

func CloseAllStickyInMemEngines Uses

func CloseAllStickyInMemEngines()

CloseAllStickyInMemEngines closes and removes all sticky in memory engines.

func CloseStickyInMemEngine Uses

func CloseStickyInMemEngine(id string) error

CloseStickyInMemEngine closes the underlying engine and removes the sticky engine keyed by the given id. It will error if it does not exist.

func EncodeSessionCookie Uses

func EncodeSessionCookie(sessionCookie *serverpb.SessionCookie) (*http.Cookie, error)

EncodeSessionCookie encodes a SessionCookie proto into an http.Cookie.

func ExpectedInitialRangeCount Uses

func ExpectedInitialRangeCount(
    db *client.DB, defaultZoneConfig *config.ZoneConfig, defaultSystemZoneConfig *config.ZoneConfig,
) (int, error)

ExpectedInitialRangeCount returns the expected number of ranges that should be on the server after bootstrap.

func GetBootstrapSchema Uses

func GetBootstrapSchema(
    defaultZoneConfig *config.ZoneConfig, defaultSystemZoneConfig *config.ZoneConfig,
) sqlbase.MetadataSchema

GetBootstrapSchema returns the schema which will be used to bootstrap a new server.

func IsWaitingForInit Uses

func IsWaitingForInit(err error) bool

IsWaitingForInit checks whether the provided error is because the node is still waiting for initialization.

func SetOpenFileLimitForOneStore Uses

func SetOpenFileLimitForOneStore() (uint64, error)

SetOpenFileLimitForOneStore sets the soft limit for open file descriptors when there is only one store.

type Config Uses

type Config struct {
    // Embed the base context.
    *base.Config

    Settings *cluster.Settings

    base.RaftConfig

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

    // Unix socket: for postgres only.
    SocketFile string

    // Stores is specified to enable durable key-value storage.
    Stores base.StoreSpecList

    // StorageEngine specifies the engine type (eg. rocksdb, pebble) to use to
    // instantiate stores.
    StorageEngine enginepb.EngineType

    // TempStorageConfig is used to configure temp storage, which stores
    // ephemeral data when processing large queries.
    TempStorageConfig base.TempStorageConfig

    // Attrs specifies a colon-separated list of node topography or machine
    // capabilities, used to match capabilities or location preferences specified
    // in zone configs.
    Attrs string

    // JoinList is a list of node addresses that act as bootstrap hosts for
    // connecting to the gossip network.
    JoinList base.JoinListType

    // RetryOptions controls the retry behavior of the server.
    RetryOptions retry.Options

    // CacheSize is the amount of memory in bytes to use for caching data.
    // The value is split evenly between the stores if there are more than one.
    CacheSize int64

    // TimeSeriesServerConfig contains configuration specific to the time series
    // server.
    TimeSeriesServerConfig ts.ServerConfig

    // SQLMemoryPoolSize is the amount of memory in bytes that can be
    // used by SQL clients to store row data in server RAM.
    SQLMemoryPoolSize int64

    // SQLAuditLogDirName is the target directory name for SQL audit logs.
    SQLAuditLogDirName *log.DirName

    // SQLTableStatCacheSize is the size (number of tables) of the table
    // statistics cache.
    SQLTableStatCacheSize int

    // SQLQueryCacheSize is the memory size (in bytes) of the query plan cache.
    SQLQueryCacheSize int64

    // GoroutineDumpDirName is the directory name for goroutine dumps using
    // goroutinedumper.
    GoroutineDumpDirName string

    // HeapProfileDirName is the directory name for heap profiles using
    // heapprofiler. If empty, no heap profiles will be collected.
    HeapProfileDirName string

    // NodeAttributes is the parsed representation of Attrs.
    NodeAttributes roachpb.Attributes

    // GossipBootstrapResolvers is a list of gossip resolvers used
    // to find bootstrap nodes for connecting to the gossip network.
    GossipBootstrapResolvers []resolver.Resolver

    // Enables linearizable behavior of operations on this node by making sure
    // that no commit timestamp is reported back to the client until all other
    // node clocks have necessarily passed it.
    // Environment Variable: COCKROACH_EXPERIMENTAL_LINEARIZABLE
    Linearizable bool

    // Maximum allowed clock offset for the cluster. If observed clock
    // offsets exceed this limit, inconsistency may result, and servers
    // will panic to minimize the likelihood of inconsistent data.
    // Increasing this value will increase time to recovery after
    // failures, and increase the frequency and impact of
    // ReadWithinUncertaintyIntervalError.
    MaxOffset MaxOffsetType

    // TimestampCachePageSize is the size in bytes of the pages in the
    // timestamp cache held by each store.
    TimestampCachePageSize uint32

    // ScanInterval determines a duration during which each range should be
    // visited approximately once by the range scanner. Set to 0 to disable.
    // Environment Variable: COCKROACH_SCAN_INTERVAL
    ScanInterval time.Duration

    // ScanMinIdleTime is the minimum time the scanner will be idle between ranges.
    // If enabled (> 0), the scanner may complete in more than ScanInterval for large
    // stores.
    // Environment Variable: COCKROACH_SCAN_MIN_IDLE_TIME
    ScanMinIdleTime time.Duration

    // ScanMaxIdleTime is the maximum time the scanner will be idle between ranges.
    // If enabled (> 0), the scanner may complete in less than ScanInterval for small
    // stores.
    // Environment Variable: COCKROACH_SCAN_MAX_IDLE_TIME
    ScanMaxIdleTime time.Duration

    // TestingKnobs is used for internal test controls only.
    TestingKnobs base.TestingKnobs

    // AmbientCtx is used to annotate contexts used inside the server.
    AmbientCtx log.AmbientContext

    // DefaultZoneConfig is used to set the default zone config inside the server.
    // It can be overridden during tests by setting the DefaultZoneConfigOverride
    // server testing knob.
    DefaultZoneConfig config.ZoneConfig
    // DefaultSystemZoneConfig is used to set the default system zone config
    // inside the server. It can be overridden during tests by setting the
    // DefaultSystemZoneConfigOverride server testing knob.
    DefaultSystemZoneConfig config.ZoneConfig

    // Locality is a description of the topography of the server.
    Locality roachpb.Locality

    // LocalityAddresses contains private IP addresses the can only be accessed
    // in the corresponding locality.
    LocalityAddresses []roachpb.LocalityAddress

    // EventLogEnabled is a switch which enables recording into cockroach's SQL
    // event log tables. These tables record transactional events about changes
    // to cluster metadata, such as DDL statements and range rebalancing
    // actions.
    EventLogEnabled bool

    // ReadyFn is called when the server has started listening on its
    // sockets.
    // The argument waitForInit indicates (iff true) that the
    // server is not bootstrapped yet, will not bootstrap itself and
    // will be waiting for an `init` command or accept bootstrapping
    // from a joined node.
    ReadyFn func(waitForInit bool)

    // DelayedBootstrapFn is called if the boostrap process does not complete
    // in a timely fashion, typically 30s after the server starts listening.
    DelayedBootstrapFn func()

    // EnableWebSessionAuthentication enables session-based authentication for
    // the Admin API's HTTP endpoints.
    EnableWebSessionAuthentication bool
    // contains filtered or unexported fields
}

Config holds parameters needed to setup a server.

func MakeConfig Uses

func MakeConfig(ctx context.Context, st *cluster.Settings) Config

MakeConfig returns a Context with default values.

func (*Config) CreateEngines Uses

func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error)

CreateEngines creates Engines based on the specs in cfg.Stores.

func (*Config) FilterGossipBootstrapResolvers Uses

func (cfg *Config) FilterGossipBootstrapResolvers(
    ctx context.Context, listen, advert net.Addr,
) []resolver.Resolver

FilterGossipBootstrapResolvers removes any gossip bootstrap resolvers which match either this node's listen address or its advertised host address.

func (Config) HistogramWindowInterval Uses

func (cfg 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) InitNode Uses

func (cfg *Config) InitNode() error

InitNode parses node attributes and initializes the gossip bootstrap resolvers.

func (*Config) Report Uses

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

Report logs an overview of the server configuration parameters via the given context.

func (*Config) RequireWebSession Uses

func (cfg *Config) RequireWebSession() bool

RequireWebSession indicates whether the server should require authentication sessions when serving admin API requests.

func (*Config) String Uses

func (cfg *Config) String() string

String implements the fmt.Stringer interface.

type Engines Uses

type Engines []engine.Engine

Engines is a container of engines, allowing convenient closing.

func (*Engines) Close Uses

func (e *Engines) Close()

Close closes all the Engines. This method has a pointer receiver so that the following pattern works:

func f() {
	engines := Engines(engineSlice)
	defer engines.Close()  // make sure the engines are Closed if this
	                       // function returns early.
	... do something with engines, pass ownership away...
	engines = nil  // neutralize the preceding defer
}

type ListenError Uses

type ListenError struct {
    Addr string
    // contains filtered or unexported fields
}

ListenError is returned from Start when we fail to start listening on either the main Cockroach port or the HTTP port, so that the CLI can instruct the user on what might have gone wrong.

type MaxOffsetType Uses

type MaxOffsetType time.Duration

MaxOffsetType stores the configured MaxOffset.

func (*MaxOffsetType) Set Uses

func (mo *MaxOffsetType) Set(v string) error

Set implements the pflag.Value interface.

func (*MaxOffsetType) String Uses

func (mo *MaxOffsetType) String() string

String implements the pflag.Value interface.

func (*MaxOffsetType) Type Uses

func (mo *MaxOffsetType) Type() string

Type implements the pflag.Value interface.

type Node Uses

type Node struct {
    Descriptor roachpb.NodeDescriptor // Node ID, network/physical topology
    // contains filtered or unexported fields
}

A Node manages a map of stores (by store ID) for which it serves traffic. A node is the top-level data structure. There is one node instance per process. A node accepts incoming RPCs and services them by directing the commands contained within RPCs to local stores, which in turn direct the commands to specific ranges. Each node has access to the global, monolithic Key-Value abstraction via its client.DB reference. Nodes use this to allocate node and store IDs for bootstrapping the node itself or new stores as they're added on subsequent instantiations.

func NewNode Uses

func NewNode(
    cfg storage.StoreConfig,
    recorder *status.MetricsRecorder,
    reg *metric.Registry,
    stopper *stop.Stopper,
    txnMetrics kv.TxnMetrics,
    execCfg *sql.ExecutorConfig,
    clusterID *base.ClusterIDContainer,
) *Node

NewNode returns a new instance of Node.

execCfg can be nil to help bootstrapping of a Server (the Node is created before the ExecutorConfig is initialized). In that case, InitLogger() needs to be called before the Node is used.

func (*Node) AnnotateCtx Uses

func (n *Node) AnnotateCtx(ctx context.Context) context.Context

AnnotateCtx is a convenience wrapper; see AmbientContext.

func (*Node) AnnotateCtxWithSpan Uses

func (n *Node) AnnotateCtxWithSpan(
    ctx context.Context, opName string,
) (context.Context, opentracing.Span)

AnnotateCtxWithSpan is a convenience wrapper; see AmbientContext.

func (*Node) Batch Uses

func (n *Node) Batch(
    ctx context.Context, args *roachpb.BatchRequest,
) (*roachpb.BatchResponse, error)

Batch implements the roachpb.InternalServer interface.

func (*Node) InitLogger Uses

func (n *Node) InitLogger(execCfg *sql.ExecutorConfig)

InitLogger needs to be called if a nil execCfg was passed to NewNode().

func (*Node) IsDraining Uses

func (n *Node) IsDraining() bool

IsDraining returns true if at least one Store housed on this Node is not currently allowing range leases to be procured or extended.

func (*Node) RangeFeed Uses

func (n *Node) RangeFeed(
    args *roachpb.RangeFeedRequest, stream roachpb.Internal_RangeFeedServer,
) error

RangeFeed implements the roachpb.InternalServer interface.

func (*Node) SetDraining Uses

func (n *Node) SetDraining(drain bool) error

SetDraining sets the draining mode on all of the node's underlying stores.

func (*Node) SetHLCUpperBound Uses

func (n *Node) SetHLCUpperBound(ctx context.Context, hlcUpperBound int64) error

SetHLCUpperBound sets the upper bound of the HLC wall time on all of the node's underlying stores.

func (*Node) String Uses

func (n *Node) String() string

String implements fmt.Stringer.

type NodeStatusWithLiveness Uses

type NodeStatusWithLiveness struct {
    statuspb.NodeStatus
    LivenessStatus storagepb.NodeLivenessStatus
}

NodeStatusWithLiveness combines a NodeStatus with a NodeLivenessStatus.

type Server Uses

type Server struct {
    // contains filtered or unexported fields
}

Server is the cockroach server node.

func NewServer Uses

func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error)

NewServer creates a Server from a server.Config.

func (*Server) AnnotateCtx Uses

func (s *Server) AnnotateCtx(ctx context.Context) context.Context

AnnotateCtx is a convenience wrapper; see AmbientContext.

func (*Server) AnnotateCtxWithSpan Uses

func (s *Server) AnnotateCtxWithSpan(
    ctx context.Context, opName string,
) (context.Context, opentracing.Span)

AnnotateCtxWithSpan is a convenience wrapper; see AmbientContext.

func (*Server) ClusterID Uses

func (s *Server) ClusterID() uuid.UUID

ClusterID returns the ID of the cluster this server is a part of.

func (*Server) ClusterSettings Uses

func (s *Server) ClusterSettings() *cluster.Settings

ClusterSettings returns the cluster settings.

func (*Server) Decommission Uses

func (s *Server) Decommission(ctx context.Context, setTo bool, nodeIDs []roachpb.NodeID) error

Decommission idempotently sets the decommissioning flag for specified nodes.

func (*Server) Drain Uses

func (s *Server) Drain(ctx context.Context, on []serverpb.DrainMode) ([]serverpb.DrainMode, error)

Drain idempotently activates the given DrainModes on the Server in the order in which they are supplied. For example, Drain is typically called with [CLIENT,LEADERSHIP] before terminating the process for graceful shutdown. On success, returns all active drain modes after carrying out the request. On failure, the system may be in a partially drained state and should be recovered by calling Undrain() with the same (or a larger) slice of modes.

func (*Server) InitialBoot Uses

func (s *Server) InitialBoot() bool

InitialBoot returns whether this is the first time the node has booted. Only intended to help print debugging info during server startup.

func (*Server) NodeID Uses

func (s *Server) NodeID() roachpb.NodeID

NodeID returns the ID of this node within its cluster.

func (*Server) PGServer Uses

func (s *Server) PGServer() *pgwire.Server

PGServer exports the pgwire server. Used by tests.

func (*Server) PeriodicallyCheckForUpdates Uses

func (s *Server) PeriodicallyCheckForUpdates(ctx context.Context)

PeriodicallyCheckForUpdates starts a background worker that periodically phones home to check for updates and report usage.

func (*Server) RunLocalSQL Uses

func (s *Server) RunLocalSQL(
    ctx context.Context, fn func(ctx context.Context, sqlExec *sql.InternalExecutor) error,
) error

RunLocalSQL calls fn on a SQL internal executor on this server. This is meant for use for SQL initialization during bootstrapping.

The internal SQL interface should be used instead of a regular SQL network connection for SQL initializations when setting up a new server, because it is possible for the server to listen on a network interface that is not reachable from loopback. It is also possible for the TLS certificates to be invalid when used locally (e.g. if the hostname in the cert is an advertised address that's only reachable externally).

func (*Server) ServeHTTP Uses

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is necessary to implement the http.Handler interface.

func (*Server) SetDistSQLSpanResolver Uses

func (ts *Server) SetDistSQLSpanResolver(spanResolver interface{})

SetDistSQLSpanResolver is part of TestServerInterface.

func (*Server) Start Uses

func (s *Server) Start(ctx context.Context) error

Start starts the server on the specified port, starts gossip and initializes the node using the engines from the server's context. This is complex since it sets up the listeners and the associated port muxing, but especially since it has to solve the "bootstrapping problem": nodes need to connect to Gossip fairly early, but what drives Gossip connectivity are the first range replicas in the kv store. This in turn suggests opening the Gossip server early. However, naively doing so also serves most other services prematurely, which exposes a large surface of potentially underinitialized services. This is avoided with some additional complexity that can be summarized as follows:

- before blocking trying to connect to the Gossip network, we already open

the admin UI (so that its diagnostics are available)

- we also allow our Gossip and our connection health Ping service - everything else returns Unavailable errors (which are retryable) - once the node has started, unlock all RPCs.

The passed context can be used to trace the server startup. The context should represent the general startup operation.

func (*Server) Stop Uses

func (s *Server) Stop()

Stop stops the server.

func (*Server) TempDir Uses

func (s *Server) TempDir() string

TempDir returns the filepath of the temporary directory used for temp storage. It is empty for an in-memory temp storage.

func (*Server) Undrain Uses

func (s *Server) Undrain(ctx context.Context, off []serverpb.DrainMode) []serverpb.DrainMode

Undrain idempotently deactivates the given DrainModes on the Server in the order in which they are supplied. On success, returns any remaining active drain modes.

type TestServer Uses

type TestServer struct {
    Cfg *Config
    // server is the embedded Cockroach server struct.
    *Server
    // contains filtered or unexported fields
}

A TestServer encapsulates an in-memory instantiation of a cockroach node with a single store. It provides tests with access to Server internals. Where possible, it should be used through the testingshim.TestServerInterface.

Example usage of a TestServer:

s, db, kvDB := serverutils.StartServer(t, base.TestServerArgs{})
defer s.Stopper().Stop()
// If really needed, in tests that can depend on server, downcast to
// server.TestServer:
ts := s.(*server.TestServer)

func (*TestServer) AdminURL Uses

func (ts *TestServer) AdminURL() string

AdminURL implements TestServerInterface.

func (*TestServer) Clock Uses

func (ts *TestServer) Clock() *hlc.Clock

Clock returns the clock used by the TestServer.

func (*TestServer) ClusterSettings Uses

func (ts *TestServer) ClusterSettings() *cluster.Settings

ClusterSettings returns the ClusterSettings.

func (*TestServer) DB Uses

func (ts *TestServer) DB() *client.DB

DB returns the client.DB instance used by the TestServer.

func (*TestServer) DistSQLServer Uses

func (ts *TestServer) DistSQLServer() interface{}

DistSQLServer is part of TestServerInterface.

func (*TestServer) DistSender Uses

func (ts *TestServer) DistSender() *kv.DistSender

DistSender is like DistSenderI(), but returns the real type instead of interface{}.

func (*TestServer) DistSenderI Uses

func (ts *TestServer) DistSenderI() interface{}

DistSenderI is part of DistSendeInterface.

func (*TestServer) Engines Uses

func (ts *TestServer) Engines() []engine.Engine

Engines returns the TestServer's engines.

func (*TestServer) ExecutorConfig Uses

func (ts *TestServer) ExecutorConfig() interface{}

ExecutorConfig is part of the TestServerInterface.

func (*TestServer) ExpectedInitialRangeCount Uses

func (ts *TestServer) ExpectedInitialRangeCount() (int, error)

ExpectedInitialRangeCount returns the expected number of ranges that should be on the server after initial (asynchronous) splits have been completed, assuming no additional information is added outside of the normal bootstrap process.

func (*TestServer) GCSystemLog Uses

func (ts *TestServer) GCSystemLog(
    ctx context.Context, table string, timestampLowerBound, timestampUpperBound time.Time,
) (time.Time, int64, error)

GCSystemLog deletes entries in the given system log table between timestamp and timestampUpperBound if the server is the lease holder for range 1. Leaseholder constraint is present so that only one node in the cluster performs gc. The system log table is expected to have a "timestamp" column. It returns the timestampLowerBound to be used in the next iteration, number of rows affected and error (if any).

func (*TestServer) GetAuthenticatedHTTPClient Uses

func (ts *TestServer) GetAuthenticatedHTTPClient() (http.Client, error)

GetAuthenticatedHTTPClient implements the TestServerInterface.

func (*TestServer) GetFirstStoreID Uses

func (ts *TestServer) GetFirstStoreID() roachpb.StoreID

GetFirstStoreID is part of TestServerInterface.

func (*TestServer) GetHTTPClient Uses

func (ts *TestServer) GetHTTPClient() (http.Client, error)

GetHTTPClient implements TestServerInterface.

func (*TestServer) GetNode Uses

func (ts *TestServer) GetNode() *Node

GetNode exposes the Server's Node.

func (*TestServer) GetNodeLiveness Uses

func (ts *TestServer) GetNodeLiveness() *storage.NodeLiveness

GetNodeLiveness exposes the Server's nodeLiveness.

func (*TestServer) GetRangeLease Uses

func (ts *TestServer) GetRangeLease(
    ctx context.Context, key roachpb.Key,
) (_ roachpb.Lease, now hlc.Timestamp, _ error)

GetRangeLease returns the current lease for the range containing key, and a timestamp taken from the node.

The lease is returned regardless of its status.

func (*TestServer) GetStores Uses

func (ts *TestServer) GetStores() interface{}

GetStores is part of TestServerInterface.

func (*TestServer) Gossip Uses

func (ts *TestServer) Gossip() *gossip.Gossip

Gossip is like GossipI but returns the real type instead of interface{}.

func (*TestServer) GossipI Uses

func (ts *TestServer) GossipI() interface{}

GossipI is part of TestServerInterface.

func (*TestServer) HTTPAddr Uses

func (ts *TestServer) HTTPAddr() string

HTTPAddr returns the server's HTTP address. Should be used by clients.

func (*TestServer) InternalExecutor Uses

func (ts *TestServer) InternalExecutor() interface{}

InternalExecutor is part of TestServerInterface.

func (*TestServer) JobRegistry Uses

func (ts *TestServer) JobRegistry() interface{}

JobRegistry returns the *jobs.Registry as an interface{}.

func (*TestServer) LeaseManager Uses

func (ts *TestServer) LeaseManager() interface{}

LeaseManager is part of TestServerInterface.

func (*TestServer) LookupRange Uses

func (ts *TestServer) LookupRange(key roachpb.Key) (roachpb.RangeDescriptor, error)

LookupRange returns the descriptor of the range containing key.

func (*TestServer) MergeRanges Uses

func (ts *TestServer) MergeRanges(leftKey roachpb.Key) (roachpb.RangeDescriptor, error)

MergeRanges merges the range containing leftKey with the range to its right.

func (*TestServer) MustGetSQLCounter Uses

func (ts *TestServer) MustGetSQLCounter(name string) int64

MustGetSQLCounter implements TestServerInterface.

func (*TestServer) MustGetSQLNetworkCounter Uses

func (ts *TestServer) MustGetSQLNetworkCounter(name string) int64

MustGetSQLNetworkCounter implements TestServerInterface.

func (*TestServer) PGServer Uses

func (ts *TestServer) PGServer() *pgwire.Server

PGServer returns the pgwire.Server used by the TestServer.

func (*TestServer) RPCAddr Uses

func (ts *TestServer) RPCAddr() string

RPCAddr returns the server's listening RPC address. Note: use ServingRPCAddr() instead unless there is a specific reason not to.

func (*TestServer) RPCContext Uses

func (ts *TestServer) RPCContext() *rpc.Context

RPCContext returns the rpc context used by the TestServer.

func (*TestServer) RaftTransport Uses

func (ts *TestServer) RaftTransport() *storage.RaftTransport

RaftTransport returns the RaftTransport used by the TestServer.

func (*TestServer) SQLAddr Uses

func (ts *TestServer) SQLAddr() string

SQLAddr returns the server's listening SQL address. Note: use ServingSQLAddr() instead unless there is a specific reason not to.

func (*TestServer) ServingRPCAddr Uses

func (ts *TestServer) ServingRPCAddr() string

ServingRPCAddr returns the server's RPC address. Should be used by clients.

func (*TestServer) ServingSQLAddr Uses

func (ts *TestServer) ServingSQLAddr() string

ServingSQLAddr returns the server's SQL address. Should be used by clients.

func (*TestServer) SplitRange Uses

func (ts *TestServer) SplitRange(
    splitKey roachpb.Key,
) (roachpb.RangeDescriptor, roachpb.RangeDescriptor, error)

SplitRange splits the range containing splitKey. The right range created by the split starts at the split key and extends to the original range's end key. Returns the new descriptors of the left and right ranges.

splitKey must correspond to a SQL table key (it must end with a family ID / col ID).

func (*TestServer) Start Uses

func (ts *TestServer) Start(params base.TestServerArgs) error

Start starts the TestServer by bootstrapping an in-memory store (defaults to maximum of 100M). The server is started, launching the node RPC server and all HTTP endpoints. Use the value of TestServer.ServingRPCAddr() after Start() for client connections. Use TestServer.Stopper().Stop() to shutdown the server after the test completes.

func (*TestServer) Stopper Uses

func (ts *TestServer) Stopper() *stop.Stopper

Stopper returns the embedded server's Stopper.

func (*TestServer) Stores Uses

func (ts *TestServer) Stores() *storage.Stores

Stores returns the collection of stores from this TestServer's node.

func (*TestServer) TsDB Uses

func (ts *TestServer) TsDB() *ts.DB

TsDB returns the ts.DB instance used by the TestServer.

func (*TestServer) WriteSummaries Uses

func (ts *TestServer) WriteSummaries() error

WriteSummaries implements TestServerInterface.

type TestingKnobs Uses

type TestingKnobs struct {
    // DisableAutomaticVersionUpgrade, if set, temporarily disables the server's
    // automatic version upgrade mechanism.
    DisableAutomaticVersionUpgrade int32 // accessed atomically
    // DefaultZoneConfigOverride, if set, overrides the default zone config defined in `pkg/config/zone.go`
    DefaultZoneConfigOverride *config.ZoneConfig
    // DefaultSystemZoneConfigOverride, if set, overrides the default system zone config defined in `pkg/config/zone.go`
    DefaultSystemZoneConfigOverride *config.ZoneConfig
    // PauseAfterGettingRPCAddress, if non-nil, instructs the server to wait until
    // the channel is closed after getting an RPC serving address.
    PauseAfterGettingRPCAddress chan struct{}
    // SignalAfterGettingRPCAddress, if non-nil, is closed after the server gets
    // an RPC server address.
    SignalAfterGettingRPCAddress chan struct{}
    // ContextTestingKnobs allows customization of the RPC context testing knobs.
    ContextTestingKnobs rpc.ContextTestingKnobs

    // If set, use this listener for RPC (and possibly SQL, depending on
    // the SplitListenSQL setting), instead of binding a new listener.
    // This is useful in tests that need an ephemeral listening port but
    // must know it before the server starts.
    //
    // When this is used, the advertise address should also be set to
    // match.
    //
    // The Server takes responsibility for closing this listener.
    // TODO(bdarnell): That doesn't give us a good way to clean up if the
    // server fails to start.
    RPCListener net.Listener

    // BootstrapVersionOverride, if not empty, will be used for bootstrapping
    // clusters instead of cluster.BinaryServerVersion (if this server
    // is the one bootstrapping the cluster).
    //
    // This can be used by tests to essentially pretend that a new cluster is not
    // starting from scratch, but instead is "created" by a node starting up with
    // engines that had already been bootstrapped, at this
    // BootstrapVersionOverride. For example, it allows convenient creation of a
    // cluster from a 2.1 binary, but that's running at version 2.0.
    //
    // NOTE: When setting this, you probably also want to set
    // DisableAutomaticVersionUpgrade.
    BootstrapVersionOverride roachpb.Version
}

TestingKnobs groups testing knobs for the Server.

func (*TestingKnobs) ModuleTestingKnobs Uses

func (*TestingKnobs) ModuleTestingKnobs()

ModuleTestingKnobs is part of the base.ModuleTestingKnobs interface.

Directories

PathSynopsis
debug
debug/goroutineui
debug/pprofui
diagnosticspb
goroutinedumper
heapprofiler
serverpbPackage serverpb is a reverse proxy.
status
status/statuspb
telemetryPackage telemetry contains helpers for capturing diagnostics information.

Package server imports 133 packages (graph) and is imported by 37 packages. Updated 2019-11-12. Refresh now. Tools for package owners.