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 drain.go grpc_server.go init.go loopback.go node.go node_engine_health.go problem_ranges.go rlimit_unix.go server.go server_sql.go server_systemlog_gc.go server_update.go settingsworker.go statement_diagnostics_requests.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

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

    // SessionCookieName is the name of the cookie used for HTTP auth.
    SessionCookieName = "session"
)
const (
    // TestUser is a fixed user used in unittests.
    // It has valid embedded client certs.
    TestUser = "testuser"
)

Variables

var (
    // DeprecatedDrainParameter the special value that must be
    // passed in DrainRequest.DeprecatedProbeIndicator to signal the
    // drain request is not a probe.
    // This variable is also used in the v20.1 "quit" client
    // to provide a valid input to the request sent to
    // v19.1 nodes.
    //
    // TODO(knz): Remove this in v20.2 and whenever the "quit" command
    // is not meant to work with 19.x servers any more, whichever comes
    // later.
    DeprecatedDrainParameter = []int32{0, 1}
)
var ErrClusterInitialized = fmt.Errorf("cluster has already been initialized")

ErrClusterInitialized is reported when the Bootstrap RPC is run on a node that is already part of an initialized cluster.

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

func CreateAuthSecret() (secret, hashedSecret []byte, err error)

CreateAuthSecret creates a secret, hash pair to populate a session auth token.

func EncodeSessionCookie Uses

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

EncodeSessionCookie encodes a SessionCookie proto into an http.Cookie. The flag forHTTPSOnly, if set, produces the "Secure" flag on the resulting HTTP cookie, which means the cookie should only be transmitted over HTTPS channels. Note that a cookie without the "Secure" flag can be transmitted over either HTTP or HTTPS channels.

func ExpectedInitialRangeCount Uses

func ExpectedInitialRangeCount(
    db *kv.DB, defaultZoneConfig *zonepb.ZoneConfig, defaultSystemZoneConfig *zonepb.ZoneConfig,
) (int, error)

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

func GetBootstrapSchema Uses

func GetBootstrapSchema(
    defaultZoneConfig *zonepb.ZoneConfig, defaultSystemZoneConfig *zonepb.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.

func StartTenant Uses

func StartTenant(
    ctx context.Context,
    stopper *stop.Stopper,
    kvClusterName string,
    baseCfg BaseConfig,
    sqlCfg SQLConfig,
) (pgAddr string, _ error)

StartTenant starts a stand-alone SQL server against a KV backend.

type BaseConfig Uses

type BaseConfig struct {
    Settings *cluster.Settings
    *base.Config

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

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

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

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

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

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

BaseConfig holds parameters that are needed to setup either a KV or a SQL server.

func MakeBaseConfig Uses

func MakeBaseConfig(st *cluster.Settings) BaseConfig

MakeBaseConfig returns a BaseConfig with default values.

type Config Uses

type Config struct {
    BaseConfig
    KVConfig
    SQLConfig
}

Config holds the parameters needed to set up a combined KV and SQL server.

func MakeConfig Uses

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

MakeConfig returns a Config for the system tenant 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) InitNode Uses

func (cfg *Config) InitNode(ctx context.Context) 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 []storage.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 KVConfig Uses

type KVConfig struct {
    base.RaftConfig

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

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

    // JoinPreferSRVRecords, if set, causes the lookup logic for the
    // names in JoinList to prefer SRV records from DNS, if available,
    // to A/AAAA records.
    JoinPreferSRVRecords bool

    // RetryOptions controls the retry behavior of the server.
    //
    // TODO(tbg): this is only ever used in one test. Make it a testing knob.
    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

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

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

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

    // 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 bool parameter is true if 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.
    //
    // This method is invoked from the main start goroutine, so it should not
    // do nontrivial work.
    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
}

KVConfig holds the parameters that (together with a BaseConfig) allow setting up a KV server.

func MakeKVConfig Uses

func MakeKVConfig(storeSpec base.StoreSpec) KVConfig

MakeKVConfig returns a KVConfig with default values.

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.

func (*ListenError) Error Uses

func (l *ListenError) Error() string

Error implements error.

func (*ListenError) Unwrap Uses

func (l *ListenError) Unwrap() error

Unwrap is because ListenError is a wrapper.

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 kvserver.StoreConfig,
    recorder *status.MetricsRecorder,
    reg *metric.Registry,
    stopper *stop.Stopper,
    txnMetrics kvcoord.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) GossipSubscription Uses

func (n *Node) GossipSubscription(
    args *roachpb.GossipSubscriptionRequest, stream roachpb.Internal_GossipSubscriptionServer,
) error

GossipSubscription 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) RangeLookup Uses

func (n *Node) RangeLookup(
    ctx context.Context, req *roachpb.RangeLookupRequest,
) (*roachpb.RangeLookupResponse, error)

RangeLookup implements the roachpb.InternalServer interface.

func (*Node) SetDraining Uses

func (n *Node) SetDraining(drain bool, reporter func(int, string)) error

SetDraining sets the draining mode on all of the node's underlying stores. The reporter callback, if non-nil, is called on a best effort basis to report work that needed to be done and which may or may not have been done by the time this call returns. See the explanation in pkg/server/drain.go for details.

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

type SQLConfig struct {
    // The tenant that the SQL server runs on the behalf of.
    TenantID roachpb.TenantID

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

    // SocketFile, if non-empty, sets up a TLS-free local listener using
    // a unix datagram socket at the specified path.
    SocketFile string

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

    // ExternalIODirConfig is used to configure external storage
    // access (http://, nodelocal://, etc)
    ExternalIODirConfig base.ExternalIODirConfig

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

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

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

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

    // TenantKVAddrs are the entry points to the KV layer.
    //
    // Only applies when the SQL server is deployed individually.
    TenantKVAddrs []string
}

SQLConfig holds the parameters that (together with a BaseConfig) allow setting up a SQL server.

func MakeSQLConfig Uses

func MakeSQLConfig(tenID roachpb.TenantID, tempStorageCfg base.TempStorageConfig) SQLConfig

MakeSQLConfig returns a SQLConfig with default values.

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

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

CheckForUpdates is part of the TestServerInterface.

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, targetStatus kvserverpb.MembershipStatus, nodeIDs []roachpb.NodeID,
) error

Decommission idempotently sets the decommissioning flag for specified nodes.

func (*Server) Drain Uses

func (s *Server) Drain(ctx context.Context) (remaining uint64, info string, err error)

Drain idempotently activates the draining mode. Note: new code should not be taught to use this method directly. Use the Drain() RPC instead with a suitably crafted DrainRequest.

On failure, the system may be in a partially drained state; the client should either continue calling Drain() or shut down the server.

The reporter function, if non-nil, is called for each packet of load shed away from the server during the drain.

TODO(knz): This method is currently exported for use by the shutdown code in cli/start.go; however, this is a mis-design. The start code should use the Drain() RPC like quit does.

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

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

ReportDiagnostics is part of the TestServerInterface.

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 (s *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.

type StmtDiagnosticsRequester Uses

type StmtDiagnosticsRequester interface {

    // InsertRequest adds an entry to system.statement_diagnostics_requests for
    // tracing a query with the given fingerprint. Once this returns, calling
    // shouldCollectDiagnostics() on the current node will return true for the given
    // fingerprint.
    InsertRequest(ctx context.Context, fprint string) error
}

StmtDiagnosticsRequester is the interface into *stmtdiagnostics.Registry used by AdminUI endpoints.

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() *kv.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() *kvcoord.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) DrainClients Uses

func (ts *TestServer) DrainClients(ctx context.Context) error

DrainClients exports the drainClients() method for use by tests.

func (*TestServer) Engines Uses

func (ts *TestServer) Engines() []storage.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) ForceTableGC Uses

func (ts *TestServer) ForceTableGC(
    ctx context.Context, database, table string, timestamp hlc.Timestamp,
) error

ForceTableGC is part of TestServerInterface.

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

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

GetAdminAuthenticatedHTTPClient implements the TestServerInterface.

func (*TestServer) GetAuthenticatedHTTPClient Uses

func (ts *TestServer) GetAuthenticatedHTTPClient(isAdmin bool) (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) 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) MigrationManager Uses

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

MigrationManager returns the *sqlmigrations.Manager as an interface{}.

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

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

Node returns the Node as an interface{}.

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() *kvserver.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) SQLServer Uses

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

SQLServer is part of TestServerInterface.

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

func (ts *TestServer) ServingTenantAddr() string

ServingTenantAddr returns the server's Tenant address. Should be used by tenant SQL processes.

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

func (ts *TestServer) StartTenant(params base.TestTenantArgs) (pgAddr string, _ error)

StartTenant starts a SQL tenant communicating with this TestServer.

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() *kvserver.Stores

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

func (*TestServer) TenantAddr Uses

func (ts *TestServer) TenantAddr() string

TenantAddr returns the server's listening Tenant address. Note: use ServingTenantAddr() instead unless there is a specific reason not to.

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 *zonepb.ZoneConfig
    // DefaultSystemZoneConfigOverride, if set, overrides the default system zone config defined in `pkg/config/zone.go`
    DefaultSystemZoneConfigOverride *zonepb.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
    // DiagnosticsTestingKnobs allows customization of diagnostics testing knobs.
    DiagnosticsTestingKnobs diagnosticspb.TestingKnobs

    // 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 clusterversion.BinaryVersion (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.
    //
    // NB: When setting this, you probably also want to set
    // DisableAutomaticVersionUpgrade.
    //
    // TODO(irfansharif): Update users of this testing knob to use the
    // appropriate clusterversion.Handle instead.
    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 148 packages (graph) and is imported by 103 packages. Updated 2020-08-05. Refresh now. Tools for package owners.