execinfra

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 58 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StateRunning is the common state of a processor: it's producing rows for
	// its consumer and forwarding metadata from its input. Different processors
	// might have sub-states internally.
	//
	// If the consumer calls ConsumerDone or if the ProcOutputHelper.maxRowIdx is
	// reached, then the processor will transition to StateDraining. If the input
	// is exhausted, then the processor can transition to StateTrailingMeta
	// directly, although most always go through StateDraining.
	StateRunning procState = iota

	// StateDraining is the state in which the processor is forwarding metadata
	// from its input and otherwise ignoring all rows. Once the input is
	// exhausted, the processor will transition to StateTrailingMeta.
	//
	// In StateDraining, processors are required to swallow
	// ReadWithinUncertaintyIntervalErrors received from its sources. We're
	// already draining, so we don't care about whatever data generated this
	// uncertainty error. Besides generally seeming like a good idea, doing this
	// allows us to offer a nice guarantee to SQL clients: a read-only query that
	// produces at most one row, run as an implicit txn, never produces retriable
	// errors, regardless of the size of the row being returned (in relation to
	// the size of the result buffer on the connection). One would naively expect
	// that to be true: either the error happens before any rows have been
	// delivered to the client, in which case the auto-retries kick in, or, if a
	// row has been delivered, then the query is done and so how can there be an
	// error? What our naive friend is ignoring is that, if it weren't for this
	// code, it'd be possible for a retriable error to sneak in after the query's
	// limit has been satisfied but while processors are still draining. Note
	// that uncertainty errors are not retried automatically by the leaf
	// TxnCoordSenders (i.e. by refresh txn interceptor).
	//
	// Other categories of errors might be safe to ignore too; however we
	// can't ignore all of them. Generally, we need to ensure that all the
	// trailing metadata (e.g. LeafTxnFinalState's) make it to the gateway for
	// successful flows. If an error is telling us that some metadata might
	// have been dropped, we can't ignore that.
	StateDraining

	// StateTrailingMeta is the state in which the processor is outputting final
	// metadata such as the tracing information or the LeafTxnFinalState. Once all the
	// trailing metadata has been produced, the processor transitions to
	// StateExhausted.
	StateTrailingMeta

	// StateExhausted is the state of a processor that has no more rows or
	// metadata to produce.
	StateExhausted
)
View Source
const DefaultMemoryLimit = 64 << 20 /* 64 MiB */

DefaultMemoryLimit is the default value of sql.distsql.temp_storage.workmem cluster setting.

View Source
const MinAcceptedVersion execinfrapb.DistSQLVersion = 66

MinAcceptedVersion is the oldest version that the server is compatible with. A server will not accept flows with older versions.

View Source
const RowChannelBufSize = 16

RowChannelBufSize is the default buffer size of a RowChannel.

View Source
const StaticSQLInstanceID = base.SQLInstanceID(3)

StaticSQLInstanceID is the default Node ID to be used in tests.

Version identifies the distsql protocol version.

This version is separate from the main CockroachDB version numbering; it is only changed when the distsql API changes.

The planner populates the version in SetupFlowRequest. A server only accepts requests with versions in the range [MinAcceptedVersion, Version].

This mechanism can be used to provide a "window" of compatibility when new features are added. Example:

  • we start with Version=1; distsql servers with version 1 only accept requests with version 1.
  • a new distsql feature is added; Version is bumped to 2. The planner does not yet use this feature by default; it still issues requests with version 1.
  • MinAcceptedVersion is still 1, i.e. servers with version 2 accept both versions 1 and 2.
  • after an upgrade cycle, we can enable the feature in the planner, requiring version 2.
  • at some later point, we can choose to deprecate version 1 and have servers only accept versions >= 2 (by setting MinAcceptedVersion to 2).

Why does this all matter? Because of rolling upgrades, distsql servers across nodes may not have an overlapping window of compatibility, so only a subset of nodes can participate in a distsql flow on a given version -- hurting performance. However, we'll take the performance hit to prevent a distsql flow from blowing up. Here's an example:

Suppose that nodes running 21.2 can handle flows with distsql version 59. Say we introduced a new distsql processor spec, ExportSpec, in 22.1 but didn't bump the distsql version from 59 to 60.

During a rolling upgrade, suppose Node A has upgraded to 22.1 and plans a distSQL flow that uses the new ExportSpec. Node A thinks any node with distsql version 59 can handle this flow, which includes nodes still running a 21.2 binary! As soon as a node running a 21.2 binary receives a ExportSpec proto, it will not recognize it, causing the distsql flow to error out.

To avoid this sad tale, consider bumping the distsql version if you: - Modify a distsql processor spec in a released binary - Create a new distql processor spec - More examples below

A few changes don't need to bump the distsql version: - Modifying a distsql processor spec that isn't on a released binary yet - Renaming any field or the processor spec itself. Nodes are naive to proto field names.

ATTENTION: When updating these fields, add a brief description of what changed to the version history below.

Variables

This section is empty.

Functions

func DecodeDatum

func DecodeDatum(datumAlloc *tree.DatumAlloc, typ *types.T, data []byte) (tree.Datum, error)

DecodeDatum decodes the given bytes slice into a datum of the given type. It returns an error if the decoding is not valid, or if there are any remaining bytes.

func DrainAndClose

func DrainAndClose(
	ctx context.Context,
	dst RowReceiver,
	cause error,
	pushTrailingMeta func(context.Context),
	srcs ...RowSource,
)

DrainAndClose is a version of DrainAndForwardMetadata that drains multiple sources. These sources are assumed to be the only producers left for dst, so dst is closed once they're all exhausted (this is different from DrainAndForwardMetadata).

If cause is specified, it is forwarded to the consumer before all the drain metadata. This is intended to have been the error, if any, that caused the draining.

pushTrailingMeta is called after draining the sources and before calling dst.ProducerDone(). It gives the caller the opportunity to push some trailing metadata (e.g. tracing information and txn updates, if applicable).

srcs can be nil.

All errors are forwarded to the producer.

func DrainAndForwardMetadata

func DrainAndForwardMetadata(ctx context.Context, src RowSource, dst RowReceiver)

DrainAndForwardMetadata calls src.ConsumerDone() (thus asking src for draining metadata) and then forwards all the metadata to dst.

When this returns, src has been properly closed (regardless of the presence or absence of an error). dst, however, has not been closed; someone else must call dst.ProducerDone() when all producers have finished draining.

It is OK to call DrainAndForwardMetadata() multiple times concurrently on the same dst (as RowReceiver.Push() is guaranteed to be thread safe).

func GenerateValuesSpec

func GenerateValuesSpec(
	colTypes []*types.T, rows rowenc.EncDatumRows,
) (execinfrapb.ValuesCoreSpec, error)

GenerateValuesSpec generates a ValuesCoreSpec that encodes the given rows. We pass the types as well because zero rows are allowed.

func GetConnForOutbox

func GetConnForOutbox(
	ctx context.Context, dialer Dialer, sqlInstanceID base.SQLInstanceID, timeout time.Duration,
) (conn *grpc.ClientConn, err error)

GetConnForOutbox is a shared function between the rowexec and colexec outboxes. It attempts to dial the destination ignoring the breaker, up to the given timeout and returns the connection or an error. This connection attempt is retried since failure results in a query error. In the past, we have seen cases where a gateway node, n1, would send a flow request to n2, but n2 would be unable to connect back to n1 due to this connection attempt failing. Retrying here alleviates these flakes and causes no impact to the end user, since the receiver at the other end will hang for SettingFlowStreamTimeout waiting for a successful connection attempt.

func GetCumulativeContentionTime

func GetCumulativeContentionTime(ctx context.Context) time.Duration

GetCumulativeContentionTime is a helper function to calculate the cumulative contention time from the tracing span from the context. All contention events found in the trace are included.

func GetLeafTxnFinalState

func GetLeafTxnFinalState(ctx context.Context, txn *kv.Txn) *roachpb.LeafTxnFinalState

GetLeafTxnFinalState returns the txn metadata from a transaction if it is present and the transaction is a leaf transaction. It returns nil when called on a Root. This is done as a convenience allowing DistSQL processors to be oblivious about whether they're running in a Leaf or a Root.

NOTE(andrei): As of 04/2018, the txn is shared by all processors scheduled on a node, and so it's possible for multiple processors to send the same LeafTxnFinalState. The root TxnCoordSender doesn't care if it receives the same thing multiple times.

func GetTraceData

func GetTraceData(ctx context.Context) []tracingpb.RecordedSpan

GetTraceData returns the trace data.

func GetTraceDataAsMetadata

func GetTraceDataAsMetadata(span *tracing.Span) *execinfrapb.ProducerMetadata

GetTraceDataAsMetadata returns the trace data as execinfrapb.ProducerMetadata object.

func GetWorkMemLimit

func GetWorkMemLimit(flowCtx *FlowCtx) int64

GetWorkMemLimit returns the number of bytes determining the amount of RAM available to a single processor or operator.

func HasParallelProcessors

func HasParallelProcessors(flow *execinfrapb.FlowSpec) bool

HasParallelProcessors returns whether flow contains multiple processors in the same stage.

func LimitHint

func LimitHint(specLimitHint int64, post *execinfrapb.PostProcessSpec) (limitHint int64)

LimitHint returns the limit hint to set for a KVFetcher based on the spec's limit hint and the PostProcessSpec.

func MisplannedRanges

func MisplannedRanges(
	ctx context.Context, spans []roachpb.Span, nodeID roachpb.NodeID, rdc *rangecache.RangeCache,
) (misplannedRanges []roachpb.RangeInfo)

MisplannedRanges queries the range cache for all the passed-in spans and returns the list of ranges whose leaseholder is not on the indicated node. Ranges with unknown leases are not included in the result.

func NewLimitedMonitor

func NewLimitedMonitor(
	ctx context.Context, parent *mon.BytesMonitor, flowCtx *FlowCtx, name string,
) *mon.BytesMonitor

NewLimitedMonitor is a utility function used by processors to create a new limited memory monitor with the given name and start it. The returned monitor must be closed. The limit is determined by SessionData.WorkMemLimit (stored inside of the flowCtx) but overridden to 1 if ServerConfig.TestingKnobs.ForceDiskSpill is set or ServerConfig.TestingKnobs.MemoryLimitBytes if not.

func NewLimitedMonitorNoFlowCtx

func NewLimitedMonitorNoFlowCtx(
	ctx context.Context,
	parent *mon.BytesMonitor,
	config *ServerConfig,
	sd *sessiondata.SessionData,
	name string,
) *mon.BytesMonitor

NewLimitedMonitorNoFlowCtx is the same as NewLimitedMonitor and should be used when the caller doesn't have an access to *FlowCtx.

func NewMonitor

func NewMonitor(ctx context.Context, parent *mon.BytesMonitor, name string) *mon.BytesMonitor

NewMonitor is a utility function used by processors to create a new memory monitor with the given name and start it. The returned monitor must be closed.

func NewTestDiskMonitor

func NewTestDiskMonitor(ctx context.Context, st *cluster.Settings) *mon.BytesMonitor

NewTestDiskMonitor creates and starts a new disk monitor to be used in tests.

func NewTestMemMonitor

func NewTestMemMonitor(ctx context.Context, st *cluster.Settings) *mon.BytesMonitor

NewTestMemMonitor creates and starts a new memory monitor to be used in tests. TODO(yuzefovich): consider reusing this in tree.MakeTestingEvalContext (currently it would create an import cycle, so this code will need to be moved).

func PopulateKVMVCCStats

func PopulateKVMVCCStats(kvStats *execinfrapb.KVStats, ss *ScanStats)

PopulateKVMVCCStats adds data from the input ScanStats to the input KVStats.

func ProcessorSpan

func ProcessorSpan(ctx context.Context, name string) (context.Context, *tracing.Span)

ProcessorSpan creates a child span for a processor (if we are doing any tracing). The returned span needs to be finished using tracing.FinishSpan.

func Run

func Run(ctx context.Context, src RowSource, dst RowReceiver)

Run reads records from the source and outputs them to the receiver, properly draining the source of metadata and closing both the source and receiver.

src needs to have been Start()ed before calling this.

func SendTraceData

func SendTraceData(ctx context.Context, dst RowReceiver)

SendTraceData collects the tracing information from the ctx and pushes it to dst. The ConsumerStatus returned by dst is ignored.

Note that the tracing data is distinct between different processors, since each one gets its own trace "recording group".

func ShouldCollectStats

func ShouldCollectStats(ctx context.Context, flowCtx *FlowCtx) bool

ShouldCollectStats is a helper function used to determine if a processor should collect stats. The two requirements are that tracing must be enabled (to be able to output the stats somewhere), and that the flowCtx.CollectStats flag was set by the gateway node.

func ShouldSwallowReadWithinUncertaintyIntervalError

func ShouldSwallowReadWithinUncertaintyIntervalError(meta *execinfrapb.ProducerMetadata) bool

ShouldSwallowReadWithinUncertaintyIntervalError examines meta and returns true if it should be swallowed and not propagated further. It is the case if meta contains roachpb.ReadWithinUncertaintyIntervalError.

Types

type BatchReceiver

type BatchReceiver interface {

	// PushBatch sends a batch to the consumer of this BatchReceiver. The
	// semantics of the method are exactly the same as of RowReceiver.Push.
	PushBatch(batch coldata.Batch, meta *execinfrapb.ProducerMetadata) ConsumerStatus
	// contains filtered or unexported methods
}

BatchReceiver is any component of a flow that receives batches from another component.

type ConsumerStatus

type ConsumerStatus uint32

ConsumerStatus is the type returned by RowReceiver.Push(), informing a producer of a consumer's state.

const (
	// NeedMoreRows indicates that the consumer is still expecting more rows.
	NeedMoreRows ConsumerStatus = iota
	// DrainRequested indicates that the consumer will not process any more data
	// rows, but will accept trailing metadata from the producer.
	DrainRequested
	// ConsumerClosed indicates that the consumer will not process any more data
	// rows or metadata. This is also commonly returned in case the consumer has
	// encountered an error.
	ConsumerClosed
)

func (ConsumerStatus) String

func (i ConsumerStatus) String() string

type Dialer

type Dialer interface {
	DialNoBreaker(context.Context, roachpb.NodeID, rpc.ConnectionClass) (*grpc.ClientConn, error)
}

Dialer is used for dialing based on node IDs. It extracts out the single method that outboxes need from nodedialer.Dialer so that we can mock it in tests outside of this package.

type DistSQLMetrics

type DistSQLMetrics struct {
	QueriesActive         *metric.Gauge
	QueriesTotal          *metric.Counter
	ContendedQueriesCount *metric.Counter
	FlowsActive           *metric.Gauge
	FlowsTotal            *metric.Counter
	FlowsQueued           *metric.Gauge
	FlowsScheduled        *metric.Counter
	QueueWaitHist         *metric.Histogram
	MaxBytesHist          *metric.Histogram
	CurBytesCount         *metric.Gauge
	VecOpenFDs            *metric.Gauge
	CurDiskBytesCount     *metric.Gauge
	MaxDiskBytesHist      *metric.Histogram
	QueriesSpilled        *metric.Counter
	SpilledBytesWritten   *metric.Counter
	SpilledBytesRead      *metric.Counter
}

DistSQLMetrics contains pointers to the metrics for monitoring DistSQL processing.

func MakeDistSQLMetrics

func MakeDistSQLMetrics(histogramWindow time.Duration) DistSQLMetrics

MakeDistSQLMetrics instantiates the metrics holder for DistSQL monitoring.

func (*DistSQLMetrics) FlowStart

func (m *DistSQLMetrics) FlowStart()

FlowStart registers the start of a new DistSQL flow.

func (*DistSQLMetrics) FlowStop

func (m *DistSQLMetrics) FlowStop()

FlowStop registers the end of a DistSQL flow.

func (DistSQLMetrics) MetricStruct

func (DistSQLMetrics) MetricStruct()

MetricStruct implements the metrics.Struct interface.

func (*DistSQLMetrics) QueryStart

func (m *DistSQLMetrics) QueryStart()

QueryStart registers the start of a new DistSQL query.

func (*DistSQLMetrics) QueryStop

func (m *DistSQLMetrics) QueryStop()

QueryStop registers the end of a DistSQL query.

type DoesNotUseTxn

type DoesNotUseTxn interface {
	DoesNotUseTxn() bool
}

DoesNotUseTxn is an interface implemented by some processors to mark that they do not use a txn. The DistSQLPlanner forbids multiple processors in a local flow from running in parallel if this is unknown since concurrent use of the RootTxn is forbidden (in a distributed flow these are leaf txns, so it doesn't matter). Implementing this interface lets the DistSQLPlanner know that it is ok to run this processor in an additional goroutine.

type ExecStatsForTraceHijacker

type ExecStatsForTraceHijacker interface {
	// HijackExecStatsForTrace returns ExecStatsForTrace function, if set, and
	// sets it to nil. The caller becomes responsible for collecting and
	// propagating the execution statistics.
	HijackExecStatsForTrace() func() *execinfrapb.ComponentStats
}

ExecStatsForTraceHijacker is an interface that allows us to hijack ExecStatsForTrace function from the ProcessorBase.

type FlowCtx

type FlowCtx struct {
	AmbientContext log.AmbientContext

	Cfg *ServerConfig

	// ID is a unique identifier for a flow.
	ID execinfrapb.FlowID

	// EvalCtx is used by all the processors in the flow to evaluate expressions.
	// Processors that intend to evaluate expressions with this EvalCtx should
	// get a copy with NewEvalCtx instead of storing a pointer to this one
	// directly (since some processor mutate the EvalContext they use).
	//
	// TODO(andrei): Get rid of this field and pass a non-shared EvalContext to
	// cores of the processors that need it.
	EvalCtx *tree.EvalContext

	// The transaction in which kv operations performed by processors in the flow
	// must be performed. Processors in the Flow will use this txn concurrently.
	// This field is generally not nil, except for flows that don't run in a
	// higher-level txn (like backfills).
	Txn *kv.Txn

	// Descriptors is used to look up leased table descriptors and to construct
	// transaction bound TypeResolvers to resolve type references during flow
	// setup. It is not safe for concurrent use and is intended to be used only
	// during flow setup and initialization. The Descriptors object is initialized
	// when the FlowContext is created on the gateway node using the planner's
	// descs.Collection and is created on remote nodes with a new descs.Collection
	// In the latter case, after the flow is complete, all descriptors leased from
	// this object must be released.
	Descriptors *descs.Collection

	// IsDescriptorsCleanupRequired is set if Descriptors needs to release the
	// leases it acquired after the flow is complete.
	IsDescriptorsCleanupRequired bool

	// nodeID is the ID of the node on which the processors using this FlowCtx
	// run.
	NodeID *base.SQLIDContainer

	// TraceKV is true if KV tracing was requested by the session.
	TraceKV bool

	// CollectStats is true if execution stats collection was requested.
	CollectStats bool

	// Local is true if this flow is being run as part of a local-only query.
	Local bool

	// Gateway is true if this flow is being run on the gateway node.
	Gateway bool

	// DiskMonitor is this flow's disk monitor. All disk usage for this flow must
	// be registered through this monitor.
	DiskMonitor *mon.BytesMonitor

	// PreserveFlowSpecs is true when the flow setup code needs to be careful
	// when modifying the specifications of processors.
	PreserveFlowSpecs bool
}

FlowCtx encompasses the configuration parameters needed for various flow components.

func (*FlowCtx) Codec

func (ctx *FlowCtx) Codec() keys.SQLCodec

Codec returns the SQL codec for this flowCtx.

func (*FlowCtx) GetRowMetrics

func (flowCtx *FlowCtx) GetRowMetrics() *row.Metrics

GetRowMetrics returns the proper RowMetrics for either internal or user queries.

func (*FlowCtx) NewEvalCtx

func (ctx *FlowCtx) NewEvalCtx() *tree.EvalContext

NewEvalCtx returns a modifiable copy of the FlowCtx's EvalContext. Processors should use this method any time they need to store a pointer to the EvalContext, since processors may mutate the EvalContext. Specifically, every processor that runs ProcOutputHelper.Init must pass in a modifiable EvalContext, since it stores that EvalContext in its exprHelpers and mutates them at runtime to ensure expressions are evaluated with the correct indexed var context.

func (*FlowCtx) NewSemaContext

func (ctx *FlowCtx) NewSemaContext(txn *kv.Txn) *tree.SemaContext

NewSemaContext creates a new SemaContext with a TypeResolver bound to the input transaction.

func (*FlowCtx) NewTypeResolver

func (ctx *FlowCtx) NewTypeResolver(txn *kv.Txn) descs.DistSQLTypeResolver

NewTypeResolver creates a new TypeResolver that is bound under the input transaction. It returns a nil resolver if the FlowCtx doesn't hold a descs.Collection object.

func (*FlowCtx) ProcessorComponentID

func (ctx *FlowCtx) ProcessorComponentID(procID int32) execinfrapb.ComponentID

ProcessorComponentID returns a ComponentID for the given processor in this flow.

func (*FlowCtx) Stopper

func (ctx *FlowCtx) Stopper() *stop.Stopper

Stopper returns the stopper for this flowCtx.

func (*FlowCtx) StreamComponentID

func (ctx *FlowCtx) StreamComponentID(streamID execinfrapb.StreamID) execinfrapb.ComponentID

StreamComponentID returns a ComponentID for the given stream in this flow. The stream must originate from the node associated with this FlowCtx.

func (*FlowCtx) TableDescriptor

func (ctx *FlowCtx) TableDescriptor(desc *descpb.TableDescriptor) catalog.TableDescriptor

TableDescriptor returns a catalog.TableDescriptor object for the given descriptor proto, using the descriptors collection if it is available.

func (*FlowCtx) TestingKnobs

func (ctx *FlowCtx) TestingKnobs() TestingKnobs

TestingKnobs returns the distsql testing knobs for this flow context.

type LocalProcessor

type LocalProcessor interface {
	RowSourcedProcessor
	// InitWithOutput initializes this processor.
	InitWithOutput(flowCtx *FlowCtx, post *execinfrapb.PostProcessSpec, output RowReceiver) error
	// SetInput initializes this LocalProcessor with an input RowSource. Not all
	// LocalProcessors need inputs, but this needs to be called if a
	// LocalProcessor expects to get its data from another RowSource.
	SetInput(ctx context.Context, input RowSource) error
}

LocalProcessor is a RowSourcedProcessor that needs to be initialized with its post processing spec and output row receiver. Most processors can accept these objects at creation time.

type MetadataTestLevel

type MetadataTestLevel int

MetadataTestLevel represents the types of queries where metadata test processors are planned.

const (
	// Off represents that no metadata test processors are planned.
	Off MetadataTestLevel = iota
	// NoExplain represents that metadata test processors are planned for all
	// queries except EXPLAIN (DISTSQL) statements.
	NoExplain
	// On represents that metadata test processors are planned for all queries.
	On
)

type MetadataTestReceiver

type MetadataTestReceiver struct {
	ProcessorBase
	// contains filtered or unexported fields
}

MetadataTestReceiver is a Processors that is complimentary to MetadataTestSender which checks that all metadata emitted by latter is received.

func NewMetadataTestReceiver

func NewMetadataTestReceiver(
	flowCtx *FlowCtx,
	processorID int32,
	input RowSource,
	post *execinfrapb.PostProcessSpec,
	output RowReceiver,
	senders []string,
) (*MetadataTestReceiver, error)

NewMetadataTestReceiver creates a new MetadataTestReceiver.

func (*MetadataTestReceiver) Next

Next is part of the RowSource interface.

This implementation doesn't follow the usual patterns of other processors; it makes more limited use of the ProcessorBase's facilities because it needs to inspect metadata while draining.

func (*MetadataTestReceiver) Start

func (mtr *MetadataTestReceiver) Start(ctx context.Context)

Start is part of the RowSource interface.

type MetadataTestSender

type MetadataTestSender struct {
	ProcessorBase
	// contains filtered or unexported fields
}

MetadataTestSender intersperses a metadata record after every row.

func NewMetadataTestSender

func NewMetadataTestSender(
	flowCtx *FlowCtx,
	processorID int32,
	input RowSource,
	post *execinfrapb.PostProcessSpec,
	output RowReceiver,
	id string,
) (*MetadataTestSender, error)

NewMetadataTestSender creates a new MetadataTestSender.

func (*MetadataTestSender) Next

Next is part of the RowSource interface.

func (*MetadataTestSender) Start

func (mts *MetadataTestSender) Start(ctx context.Context)

Start is part of the RowSource interface.

type NoMetadataRowSource

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

NoMetadataRowSource is a wrapper on top of a RowSource that automatically forwards metadata to a RowReceiver. Data rows are returned through an interface similar to RowSource, except that, since metadata is taken care of, only the data rows are returned.

The point of this struct is that it'd be burdensome for some row consumers to have to deal with metadata.

func MakeNoMetadataRowSource

func MakeNoMetadataRowSource(src RowSource, sink RowReceiver) NoMetadataRowSource

MakeNoMetadataRowSource builds a NoMetadataRowSource.

func (*NoMetadataRowSource) NextRow

func (rs *NoMetadataRowSource) NextRow() (rowenc.EncDatumRow, error)

NextRow is analogous to RowSource.Next. If the producer sends an error, we can't just forward it to metadataSink. We need to let the consumer know so that it's not under the impression that everything is hunky-dory and it can continue consuming rows. So, this interface returns the error. Just like with a raw RowSource, the consumer should generally call ConsumerDone() and drain.

type OpChains

type OpChains []OpNode

OpChains describes a forest of OpNodes that represent a single physical plan. Each entry in the slice is a root of a separate OpNode tree.

type OpNode

type OpNode interface {
	// ChildCount returns the number of children (inputs) of the operator.
	ChildCount(verbose bool) int

	// Child returns the nth child (input) of the operator.
	Child(nth int, verbose bool) OpNode
}

OpNode is an interface to operator-like structures with children.

type ProcOutputHelper

type ProcOutputHelper struct {
	RowAlloc rowenc.EncDatumRowAlloc

	// OutputTypes is the schema of the rows produced by the processor after
	// post-processing (i.e. the rows that are pushed through a router).
	//
	// If renderExprs is set, these types correspond to the types of those
	// expressions.
	// If outputCols is set, these types correspond to the types of
	// those columns.
	// If neither is set, this is the internal schema of the processor.
	OutputTypes []*types.T
	// contains filtered or unexported fields
}

ProcOutputHelper is a helper type that performs filtering and projection on the output of a processor.

func (*ProcOutputHelper) EmitRow

EmitRow sends a row through the post-processing stage. The same row can be reused.

It returns the consumer's status that was observed when pushing this row. If an error is returned, it's coming from the ProcOutputHelper's filtering or rendering processing; the output has not been closed and it's the caller's responsibility to push the error to the output.

Note: check out rowexec.emitHelper() for a useful wrapper.

func (*ProcOutputHelper) Init

func (h *ProcOutputHelper) Init(
	post *execinfrapb.PostProcessSpec,
	coreOutputTypes []*types.T,
	semaCtx *tree.SemaContext,
	evalCtx *tree.EvalContext,
) error

Init sets up a ProcOutputHelper. The types describe the internal schema of the processor (as described for each processor core spec); they can be omitted if there is no filtering expression. Note that the types slice may be stored directly; the caller should not modify it.

func (*ProcOutputHelper) NeededColumns

func (h *ProcOutputHelper) NeededColumns() (colIdxs util.FastIntSet)

NeededColumns calculates the set of internal processor columns that are actually used by the post-processing stage.

func (*ProcOutputHelper) ProcessRow

func (h *ProcOutputHelper) ProcessRow(
	ctx context.Context, row rowenc.EncDatumRow,
) (_ rowenc.EncDatumRow, moreRowsOK bool, _ error)

ProcessRow sends the invoked row through the post-processing stage and returns the post-processed row. Results from ProcessRow aren't safe past the next call to ProcessRow.

The moreRowsOK retval is true if more rows can be processed, false if the limit has been reached (if there's a limit). Upon seeing a false value, the caller is expected to start draining. Note that both a row and moreRowsOK=false can be returned at the same time: the row that satisfies the limit is returned at the same time as a DrainRequested status. In that case, the caller is supposed to both deal with the row and start draining.

func (*ProcOutputHelper) Reset

func (h *ProcOutputHelper) Reset()

Reset resets this ProcOutputHelper, retaining allocated memory in its slices.

func (*ProcOutputHelper) Stats

Stats returns output statistics.

type ProcStateOpts

type ProcStateOpts struct {
	// TrailingMetaCallback, if specified, is a callback to be called by
	// moveToTrailingMeta(). See ProcessorBase.TrailingMetaCallback.
	TrailingMetaCallback func() []execinfrapb.ProducerMetadata
	// InputsToDrain, if specified, will be drained by DrainHelper().
	// MoveToDraining() calls ConsumerDone() on them, InternalClose() calls
	// ConsumerClosed() on them.
	InputsToDrain []RowSource
}

ProcStateOpts contains fields used by the ProcessorBase's family of functions that deal with draining and trailing metadata: the ProcessorBase implements generic useful functionality that needs to call back into the Processor.

type Processor

type Processor interface {
	// OutputTypes returns the column types of the results (that are to be fed
	// through an output router).
	OutputTypes() []*types.T

	// MustBeStreaming indicates whether this processor is of "streaming" nature
	// and is expected to emit the output one row at a time (in both row-by-row
	// and the vectorized engines).
	MustBeStreaming() bool

	// Run is the main loop of the processor.
	Run(context.Context)
}

Processor is a common interface implemented by all processors, used by the higher-level flow orchestration code.

type ProcessorBase

type ProcessorBase struct {
	ProcessorBaseNoHelper

	// OutputHelper is used to handle the post-processing spec.
	OutputHelper ProcOutputHelper

	// MemMonitor is the processor's memory monitor.
	MemMonitor *mon.BytesMonitor

	// SemaCtx is used to avoid allocating a new SemaCtx during processor setup.
	SemaCtx tree.SemaContext
}

ProcessorBase is supposed to be embedded by Processors. It provides facilities for dealing with filtering and projection (through a ProcOutputHelper) and for implementing the RowSource interface (draining, trailing metadata).

func (*ProcessorBase) AppendTrailingMeta

func (pb *ProcessorBase) AppendTrailingMeta(meta execinfrapb.ProducerMetadata)

AppendTrailingMeta appends metadata to the trailing metadata without changing the state to draining (as opposed to MoveToDraining).

func (*ProcessorBase) HijackExecStatsForTrace

func (pb *ProcessorBase) HijackExecStatsForTrace() func() *execinfrapb.ComponentStats

HijackExecStatsForTrace is a part of the ExecStatsForTraceHijacker interface.

func (*ProcessorBase) Init

func (pb *ProcessorBase) Init(
	self RowSource,
	post *execinfrapb.PostProcessSpec,
	coreOutputTypes []*types.T,
	flowCtx *FlowCtx,
	processorID int32,
	output RowReceiver,
	memMonitor *mon.BytesMonitor,
	opts ProcStateOpts,
) error

Init initializes the ProcessorBase. - coreOutputTypes are the type schema of the rows output by the processor core (i.e. the "internal schema" of the processor, see execinfrapb.ProcessorSpec for more details).

func (*ProcessorBase) InitWithEvalCtx

func (pb *ProcessorBase) InitWithEvalCtx(
	self RowSource,
	post *execinfrapb.PostProcessSpec,
	coreOutputTypes []*types.T,
	flowCtx *FlowCtx,
	evalCtx *tree.EvalContext,
	processorID int32,
	output RowReceiver,
	memMonitor *mon.BytesMonitor,
	opts ProcStateOpts,
) error

InitWithEvalCtx initializes the ProcessorBase with a given EvalContext. - coreOutputTypes are the type schema of the rows output by the processor core (i.e. the "internal schema" of the processor, see execinfrapb.ProcessorSpec for more details).

func (*ProcessorBase) InternalClose

func (pb *ProcessorBase) InternalClose() bool

InternalClose helps processors implement the RowSource interface, performing common close functionality. Returns true iff the processor was not already closed.

Notably, it calls ConsumerClosed() on all the inputsToDrain and updates pb.Ctx to the context passed into StartInternal() call.

if pb.InternalClose() {
  // Perform processor specific close work.
}

func (*ProcessorBase) InternalCloseEx

func (pb *ProcessorBase) InternalCloseEx(onClose func()) bool

InternalCloseEx is like InternalClose, but also takes a closure to run in case the processor was not already closed. The closure is run before the processor's span is finished, so the closure can finalize work that relies on that span (e.g. async work previously started by the processor that has captured the processor's span).

func (*ProcessorBase) OutputTypes

func (pb *ProcessorBase) OutputTypes() []*types.T

OutputTypes is part of the Processor interface.

func (*ProcessorBase) ProcessRowHelper

func (pb *ProcessorBase) ProcessRowHelper(row rowenc.EncDatumRow) rowenc.EncDatumRow

ProcessRowHelper is a wrapper on top of ProcOutputHelper.ProcessRow(). It takes care of handling errors and drain requests by moving the processor to StateDraining.

It takes a row and returns the row after processing. The return value can be nil, in which case the caller shouldn't return anything to its consumer; it should continue processing other rows, with the awareness that the processor might have been transitioned to the draining phase.

func (*ProcessorBase) Reset

func (pb *ProcessorBase) Reset()

Reset resets this ProcessorBase, retaining allocated memory in slices.

type ProcessorBaseNoHelper

type ProcessorBaseNoHelper struct {
	ProcessorID int32

	// Output is the consumer of the rows produced by this ProcessorBase. If
	// Output is nil, one can invoke ProcessRow to obtain the post-processed row
	// directly.
	Output RowReceiver

	FlowCtx *FlowCtx

	// EvalCtx is used for expression evaluation. It overrides the one in flowCtx.
	EvalCtx *tree.EvalContext

	// Closed is set by InternalClose(). Once set, the processor's tracing span
	// has been closed.
	Closed bool

	// Ctx and span contain the tracing state while the processor is active
	// (i.e. hasn't been closed). Initialized using flowCtx.Ctx (which should not be otherwise
	// used).
	Ctx context.Context

	State procState

	// ExecStatsForTrace, if set, will be called before getting the trace data from
	// the span and adding the recording to the trailing metadata. The returned
	// ComponentStats are associated with the processor's span. The Component
	// field of the returned stats will be set by the calling code.
	//
	// Can return nil.
	ExecStatsForTrace func() *execinfrapb.ComponentStats
	// contains filtered or unexported fields
}

ProcessorBaseNoHelper is slightly reduced version of ProcessorBase that should be used by the processors that don't need to handle the post-processing spec.

func (*ProcessorBaseNoHelper) AddInputToDrain

func (pb *ProcessorBaseNoHelper) AddInputToDrain(input RowSource)

AddInputToDrain adds an input to drain when moving the processor to a draining state.

func (*ProcessorBaseNoHelper) ConsumerClosed

func (pb *ProcessorBaseNoHelper) ConsumerClosed()

ConsumerClosed is part of the RowSource interface.

func (*ProcessorBaseNoHelper) ConsumerDone

func (pb *ProcessorBaseNoHelper) ConsumerDone()

ConsumerDone is part of the RowSource interface.

func (*ProcessorBaseNoHelper) DrainHelper

DrainHelper is supposed to be used in states draining and trailingMetadata. It deals with optionally draining an input and returning trailing meta. It also moves from StateDraining to StateTrailingMeta when appropriate.

func (*ProcessorBaseNoHelper) Init

func (pb *ProcessorBaseNoHelper) Init(
	self RowSource,
	flowCtx *FlowCtx,
	evalCtx *tree.EvalContext,
	processorID int32,
	output RowReceiver,
	opts ProcStateOpts,
)

Init initializes the ProcessorBaseNoHelper.

func (*ProcessorBaseNoHelper) InternalClose

func (pb *ProcessorBaseNoHelper) InternalClose() bool

InternalClose is the meat of ProcessorBase.InternalClose.

func (*ProcessorBaseNoHelper) InternalCloseEx

func (pb *ProcessorBaseNoHelper) InternalCloseEx(onClose func()) bool

InternalCloseEx is the meat of ProcessorBase.InternalCloseEx.

func (*ProcessorBaseNoHelper) MoveToDraining

func (pb *ProcessorBaseNoHelper) MoveToDraining(err error)

MoveToDraining switches the processor to the StateDraining. Only metadata is returned from now on. In this state, the processor is expected to drain its inputs (commonly by using DrainHelper()).

If the processor has no input (ProcStateOpts.inputToDrain was not specified at init() time), then we move straight to the StateTrailingMeta.

An error can be optionally passed. It will be the first piece of metadata returned by DrainHelper().

func (*ProcessorBaseNoHelper) MustBeStreaming

func (pb *ProcessorBaseNoHelper) MustBeStreaming() bool

MustBeStreaming implements the Processor interface.

func (*ProcessorBaseNoHelper) Reset

func (pb *ProcessorBaseNoHelper) Reset()

Reset resets this ProcessorBaseNoHelper, retaining allocated memory in slices.

func (*ProcessorBaseNoHelper) Run

func (pb *ProcessorBaseNoHelper) Run(ctx context.Context)

Run is part of the Processor interface.

func (*ProcessorBaseNoHelper) StartInternal

func (pb *ProcessorBaseNoHelper) StartInternal(ctx context.Context, name string) context.Context

StartInternal prepares the ProcessorBase for execution. It returns the annotated context that's also stored in pb.Ctx.

It is likely that this method is called from RowSource.Start implementation, and the recommended layout is the following:

ctx = pb.StartInternal(ctx, name)
< inputs >.Start(ctx) // if there are any inputs-RowSources to pb
< other initialization >

so that the caller doesn't mistakenly use old ctx object.

func (*ProcessorBaseNoHelper) StartInternalNoSpan

func (pb *ProcessorBaseNoHelper) StartInternalNoSpan(ctx context.Context) context.Context

StartInternalNoSpan does the same as StartInternal except that it does not start a span. This is used by pass-through components whose goal is to be a silent translation layer for components that actually do work (e.g. a planNodeToRowSource wrapping an insertNode, or a columnarizer wrapping a rowexec flow).

type ProcessorConstructor

type ProcessorConstructor func(
	ctx context.Context,
	flowCtx *FlowCtx,
	processorID int32,
	core *execinfrapb.ProcessorCoreUnion,
	post *execinfrapb.PostProcessSpec,
	inputs []RowSource,
	outputs []RowReceiver,
	localProcessors []LocalProcessor,
) (Processor, error)

ProcessorConstructor is a function that creates a Processor. It is abstracted away so that we could create mixed flows (i.e. a vectorized flow with wrapped processors) without bringing a dependency on sql/rowexec package into sql/colexec package.

type Releasable

type Releasable interface {
	// Release allows this object to be returned to a memory pool. Objects must
	// not be used after Release is called.
	Release()
}

Releasable is an interface for objects than can be Released back into a memory pool when finished.

type RepeatableRowSource

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

RepeatableRowSource is a RowSource used in benchmarks to avoid having to reinitialize a new RowSource every time during multiple passes of the input. It is intended to be initialized with all rows.

func NewRepeatableRowSource

func NewRepeatableRowSource(types []*types.T, rows rowenc.EncDatumRows) *RepeatableRowSource

NewRepeatableRowSource creates a RepeatableRowSource with the given schema and rows. types is optional if at least one row is provided.

func (*RepeatableRowSource) ConsumerClosed

func (r *RepeatableRowSource) ConsumerClosed()

ConsumerClosed is part of the RowSource interface.

func (*RepeatableRowSource) ConsumerDone

func (r *RepeatableRowSource) ConsumerDone()

ConsumerDone is part of the RowSource interface.

func (*RepeatableRowSource) Next

Next is part of the RowSource interface.

func (*RepeatableRowSource) OutputTypes

func (r *RepeatableRowSource) OutputTypes() []*types.T

OutputTypes is part of the RowSource interface.

func (*RepeatableRowSource) Reset

func (r *RepeatableRowSource) Reset()

Reset resets the RepeatableRowSource such that a subsequent call to Next() returns the first row.

func (*RepeatableRowSource) Start

func (r *RepeatableRowSource) Start(ctx context.Context)

Start is part of the RowSource interface.

type RowChannel

type RowChannel struct {

	// The channel on which rows are delivered.
	C <-chan RowChannelMsg
	// contains filtered or unexported fields
}

RowChannel is a thin layer over a RowChannelMsg channel, which can be used to transfer rows between goroutines.

func (*RowChannel) ConsumerClosed

func (rc *RowChannel) ConsumerClosed()

ConsumerClosed is part of the RowSource interface.

func (*RowChannel) ConsumerDone

func (rc *RowChannel) ConsumerDone()

ConsumerDone is part of the RowSource interface.

func (*RowChannel) DoesNotUseTxn

func (rc *RowChannel) DoesNotUseTxn() bool

DoesNotUseTxn implements the DoesNotUseTxn interface. Since the RowChannel's input is run in a different goroutine, the flow will check the RowChannel's input separately.

func (*RowChannel) InitWithBufSizeAndNumSenders

func (rc *RowChannel) InitWithBufSizeAndNumSenders(types []*types.T, chanBufSize, numSenders int)

InitWithBufSizeAndNumSenders initializes the RowChannel with a given buffer size and number of senders.

func (*RowChannel) InitWithNumSenders

func (rc *RowChannel) InitWithNumSenders(types []*types.T, numSenders int)

InitWithNumSenders initializes the RowChannel with the default buffer size. numSenders is the number of producers that will be pushing to this channel. RowChannel will not be closed until it receives numSenders calls to ProducerDone().

func (*RowChannel) Next

Next is part of the RowSource interface.

func (*RowChannel) OutputTypes

func (rc *RowChannel) OutputTypes() []*types.T

OutputTypes is part of the RowSource interface.

func (*RowChannel) ProducerDone

func (rc *RowChannel) ProducerDone()

ProducerDone is part of the RowReceiver interface.

func (*RowChannel) Push

Push is part of the RowReceiver interface.

func (*RowChannel) Start

func (rc *RowChannel) Start(ctx context.Context)

Start is part of the RowSource interface.

type RowChannelMsg

type RowChannelMsg struct {
	// Only one of these fields will be set.
	Row  rowenc.EncDatumRow
	Meta *execinfrapb.ProducerMetadata
}

RowChannelMsg is the message used in the channels that implement local physical streams (i.e. the RowChannel's).

type RowReceiver

type RowReceiver interface {

	// Push sends a record to the consumer of this RowReceiver. Exactly one of the
	// row/meta must be specified (i.e. either row needs to be non-nil or meta
	// needs to be non-Empty()). May block.
	//
	// The return value indicates the current status of the consumer. Depending on
	// it, producers are expected to drain or shut down. In all cases,
	// ProducerDone() needs to be called (after draining is done, if draining was
	// requested).
	//
	// Unless specifically permitted by the underlying implementation, (see
	// copyingRowReceiver, for example), the sender must not modify the row
	// and the metadata after calling this function.
	//
	// After DrainRequested is returned, it is expected that all future calls only
	// carry metadata (however that is not enforced and implementations should be
	// prepared to discard non-metadata rows). If ConsumerClosed is returned,
	// implementations have to ignore further calls to Push() (such calls are
	// allowed because there might be multiple producers for a single RowReceiver
	// and they might not all be aware of the last status returned).
	//
	// Implementations of Push() must be thread-safe.
	Push(row rowenc.EncDatumRow, meta *execinfrapb.ProducerMetadata) ConsumerStatus
	// contains filtered or unexported methods
}

RowReceiver is any component of a flow that receives rows from another component. It can be an input synchronizer, a router, or a mailbox.

type RowSource

type RowSource interface {
	// OutputTypes returns the schema for the rows in this source.
	OutputTypes() []*types.T

	// Start prepares the RowSource for future Next() calls and takes in the
	// context in which these future calls should operate. Start needs to be
	// called before Next/ConsumerDone/ConsumerClosed.
	//
	// RowSources that consume other RowSources are expected to Start() their
	// inputs.
	//
	// Implementations are expected to hold on to the provided context. They may
	// choose to derive and annotate it (Processors generally do, and the
	// updated context is usually available at ProcessorBase.Ctx).
	Start(context.Context)

	// Next returns the next record from the source. At most one of the return
	// values will be non-empty. Both of them can be empty when the RowSource has
	// been exhausted - no more records are coming and any further method calls
	// will be no-ops.
	//
	// EncDatumRows returned by Next() are only valid until the next call to
	// Next(), although the EncDatums inside them stay valid forever.
	//
	// A ProducerMetadata record may contain an error. In that case, this
	// interface is oblivious about the semantics: implementers may continue
	// returning different rows on future calls, or may return an empty record
	// (thus asking the consumer to stop asking for rows). In particular,
	// implementers are not required to only return metadata records from this
	// point on (which means, for example, that they're not required to
	// automatically ask every producer to drain, in case there's multiple
	// producers). Therefore, consumers need to be aware that some rows might have
	// been skipped in case they continue to consume rows. Usually a consumer
	// should react to an error by calling ConsumerDone(), thus asking the
	// RowSource to drain, and separately discard any future data rows. A consumer
	// receiving an error should also call ConsumerDone() on any other input it
	// has.
	Next() (rowenc.EncDatumRow, *execinfrapb.ProducerMetadata)

	// ConsumerDone lets the source know that we will not need any more data
	// rows. The source is expected to start draining and only send metadata
	// rows. May be called multiple times on a RowSource, even after
	// ConsumerClosed has been called.
	//
	// May block. If the consumer of the source stops consuming rows before
	// Next indicates that there are no more rows, ConsumerDone() and/or
	// ConsumerClosed() must be called; it is a no-op to call these methods after
	// all the rows were consumed (i.e. after Next() returned an empty row).
	ConsumerDone()

	// ConsumerClosed informs the source that the consumer is done and will not
	// make any more calls to Next(). Must only be called once on a given
	// RowSource.
	//
	// Like ConsumerDone(), if the consumer of the source stops consuming rows
	// before Next indicates that there are no more rows, ConsumerDone() and/or
	// ConsumerClosed() must be called; it is a no-op to call these methods after
	// all the rows were consumed (i.e. after Next() returned an empty row).
	//
	// Processors that embed ProcessorBase can delegate the implementation to
	// the latter if they only need to perform trivial cleanup (calling
	// ProcessorBase.InternalClose).
	ConsumerClosed()
}

RowSource is any component of a flow that produces rows that can be consumed by another component.

Communication components generally (e.g. RowBuffer, RowChannel) implement this interface. Some processors also implement it (in addition to implementing the Processor interface) - in which case those processors can be "fused" with their consumer (i.e. run in the consumer's goroutine).

type RowSourcedProcessor

type RowSourcedProcessor interface {
	RowSource
	Processor
}

RowSourcedProcessor is the union of RowSource and Processor.

type RuntimeStats

type RuntimeStats interface {
	// GetCPUCombinedPercentNorm returns the recent user+system cpu usage,
	// normalized to 0-1 by number of cores.
	GetCPUCombinedPercentNorm() float64
}

RuntimeStats is an interface through which the rowexec layer can get information about runtime statistics.

type ScanStats

type ScanStats struct {
	// NumInterfaceSteps is the number of times the MVCC step function was called
	// to satisfy a scan.
	NumInterfaceSteps uint64
	// NumInternalSteps is the number of times that MVCC step was invoked
	// internally, including to step over internal, uncompacted Pebble versions.
	NumInternalSteps uint64
	// NumInterfaceSeeks is the number of times the MVCC seek function was called
	// to satisfy a scan.
	NumInterfaceSeeks uint64
	// NumInternalSeeks is the number of times that MVCC seek was invoked
	// internally, including to step over internal, uncompacted Pebble versions.
	NumInternalSeeks uint64
}

ScanStats contains statistics on the internal MVCC operators used to satisfy a scan. See storage/engine.go for a more thorough discussion of the meaning of each stat. TODO(sql-observability): include other fields that are in roachpb.ScanStats, here and in execinfrapb.KVStats.

func GetScanStats

func GetScanStats(ctx context.Context) (ss ScanStats)

GetScanStats is a helper function to calculate scan stats from the tracing span from the context.

type ServerConfig

type ServerConfig struct {
	log.AmbientContext

	Settings     *cluster.Settings
	RuntimeStats RuntimeStats

	ClusterID   *base.ClusterIDContainer
	ClusterName string

	// NodeID is the id of the node on which this Server is running.
	NodeID *base.SQLIDContainer

	// Locality is the locality of the node on which this Server is running.
	Locality roachpb.Locality

	// Codec is capable of encoding and decoding sql table keys.
	Codec keys.SQLCodec

	// DB is a handle to the cluster.
	DB *kv.DB
	// Executor can be used to run "internal queries". Note that Flows also have
	// access to an executor in the EvalContext. That one is "session bound"
	// whereas this one isn't.
	Executor sqlutil.InternalExecutor

	RPCContext   *rpc.Context
	Stopper      *stop.Stopper
	TestingKnobs TestingKnobs

	// ParentMemoryMonitor is normally the root SQL monitor. It should only be
	// used when setting up a server, or in tests.
	ParentMemoryMonitor *mon.BytesMonitor

	// TempStorage is used by some DistSQL processors to store rows when the
	// working set is larger than can be stored in memory.
	TempStorage diskmap.Factory

	// TempStoragePath is the path where the vectorized execution engine should
	// create files using TempFS.
	TempStoragePath string

	// TempFS is used by the vectorized execution engine to store columns when the
	// working set is larger than can be stored in memory.
	TempFS fs.FS

	// VecFDSemaphore is a weighted semaphore that restricts the number of open
	// file descriptors in the vectorized engine.
	VecFDSemaphore semaphore.Semaphore

	// BulkAdder is used by some processors to bulk-ingest data as SSTs.
	BulkAdder kvserverbase.BulkAdderFactory

	// Child monitor of the bulk monitor which will be used to monitor the memory
	// used by the column and index backfillers.
	BackfillerMonitor *mon.BytesMonitor

	// Child monitor of the bulk monitor which will be used to monitor the memory
	// used during backup.
	BackupMonitor *mon.BytesMonitor

	// ParentDiskMonitor is normally the root disk monitor. It should only be used
	// when setting up a server, a child monitor (usually belonging to a sql
	// execution flow), or in tests. It is used to monitor temporary storage disk
	// usage. Actual disk space used will be a small multiple (~1.1) of this
	// because of RocksDB space amplification.
	ParentDiskMonitor *mon.BytesMonitor

	Metrics            *DistSQLMetrics
	RowMetrics         *row.Metrics
	InternalRowMetrics *row.Metrics

	// SQLLivenessReader provides access to reading the liveness of sessions.
	SQLLivenessReader sqlliveness.Reader

	// JobRegistry manages jobs being used by this Server.
	JobRegistry *jobs.Registry

	// LeaseManager is a *lease.Manager. It's stored as an `interface{}` due
	// to package dependency cycles
	LeaseManager interface{}

	// A handle to gossip used to broadcast the node's DistSQL version and
	// draining state.
	Gossip gossip.OptionalGossip

	// Dialer for communication between SQL and KV nodes.
	NodeDialer *nodedialer.Dialer

	// Dialer for communication between SQL nodes/pods.
	PodNodeDialer *nodedialer.Dialer

	// SessionBoundInternalExecutorFactory is used to construct session-bound
	// executors. The idea is that a higher-layer binds some of the arguments
	// required, so that users of ServerConfig don't have to care about them.
	SessionBoundInternalExecutorFactory sqlutil.SessionBoundInternalExecutorFactory

	ExternalStorage        cloud.ExternalStorageFactory
	ExternalStorageFromURI cloud.ExternalStorageFromURIFactory

	// ProtectedTimestampProvider maintains the state of the protected timestamp
	// subsystem. It is queried during the GC process and in the handling of
	// AdminVerifyProtectedTimestampRequest.
	ProtectedTimestampProvider protectedts.Provider

	DistSender *kvcoord.DistSender

	// RangeCache is used by processors that were supposed to have been planned on
	// the leaseholders of the data ranges that they're consuming. These
	// processors query the cache to see if they should communicate updates to the
	// gateway.
	RangeCache *rangecache.RangeCache

	// SQLStatsController is an interface used to reset SQL stats without the need to
	// introduce dependency on the sql package.
	SQLStatsController tree.SQLStatsController

	// IndexUsageStatsController is an interface used to reset index usage stats without
	// the need to introduce dependency on the sql package.
	IndexUsageStatsController tree.IndexUsageStatsController

	// SQLSQLResponseAdmissionQ is the admission queue to use for
	// SQLSQLResponseWork.
	SQLSQLResponseAdmissionQ *admission.WorkQueue

	// CollectionFactory is used to construct descs.Collections.
	CollectionFactory *descs.CollectionFactory
}

ServerConfig encompasses the configuration required to create a DistSQLServer.

type SpansWithCopy

type SpansWithCopy struct {
	Spans     roachpb.Spans
	SpansCopy roachpb.Spans
}

SpansWithCopy tracks a set of spans (which can be modified) along with the copy of the original one if needed. NB: Spans field is **not** owned by SpansWithCopy (it comes from the TableReader spec).

func (*SpansWithCopy) MakeSpansCopy

func (s *SpansWithCopy) MakeSpansCopy()

MakeSpansCopy makes a copy of s.Spans (which are assumed to have already been set).

func (*SpansWithCopy) Reset

func (s *SpansWithCopy) Reset()

Reset deeply resets s.

type TestingKnobs

type TestingKnobs struct {
	// RunBeforeBackfillChunk is called before executing each chunk of a
	// backfill during a schema change operation. It is called with the
	// current span and returns an error which eventually is returned to the
	// caller of SchemaChanger.exec(). In the case of a column backfill, it is
	// called at the start of the backfill function passed into the transaction
	// executing the chunk.
	RunBeforeBackfillChunk func(sp roachpb.Span) error

	// RunAfterBackfillChunk is called after executing each chunk of a backfill
	// during a schema change operation. In the case of a column backfill, it is
	// called just before returning from the backfill function passed into the
	// transaction executing the chunk. It is always called even when the backfill
	// function returns an error, or if the table has already been dropped.
	RunAfterBackfillChunk func()

	// SerializeIndexBackfillCreationAndIngestion ensures that every index batch
	// created during an index backfill is also ingested before moving on to the
	// next batch or returning.
	// Ingesting does not mean that the index entries are necessarily written to
	// storage but instead that they are buffered in the index backfillers' bulk
	// adder.
	SerializeIndexBackfillCreationAndIngestion chan struct{}

	// IndexBackfillProgressReportInterval is the periodic interval at which the
	// processor pushes the spans for which it has successfully backfilled the
	// indexes.
	IndexBackfillProgressReportInterval time.Duration

	// ForceDiskSpill forces any processors/operators that can fall back to disk
	// to fall back to disk immediately.
	//
	// Cannot be set together with MemoryLimitBytes.
	ForceDiskSpill bool

	// MemoryLimitBytes specifies a maximum amount of working memory that a
	// processor that supports falling back to disk can use. Must be >= 1 to
	// enable. This is a more fine-grained knob than ForceDiskSpill when the
	// available memory needs to be controlled. Once this limit is hit,
	// processors employ their on-disk implementation regardless of applicable
	// cluster settings.
	//
	// Cannot be set together with ForceDiskSpill.
	MemoryLimitBytes int64

	// TableReaderBatchBytesLimit, if not 0, overrides the limit that the
	// TableReader will set on the size of results it wants to get for individual
	// requests.
	TableReaderBatchBytesLimit int64
	// JoinReaderBatchBytesLimit, if not 0, overrides the limit that the
	// joinReader will set on the size of results it wants to get for individual
	// lookup requests.
	JoinReaderBatchBytesLimit int64

	// DrainFast, if enabled, causes the server to not wait for any currently
	// running flows to complete or give a grace period of minFlowDrainWait
	// to incoming flows to register.
	DrainFast bool

	// MetadataTestLevel controls whether or not additional metadata test
	// processors are planned, which send additional "RowNum" metadata that is
	// checked by a test receiver on the gateway.
	MetadataTestLevel MetadataTestLevel

	// Changefeed contains testing knobs specific to the changefeed system.
	Changefeed base.ModuleTestingKnobs

	// Flowinfra contains testing knobs specific to the flowinfra system
	Flowinfra base.ModuleTestingKnobs

	// Forces bulk adder flush every time a KV batch is processed.
	BulkAdderFlushesEveryBatch bool

	// JobsTestingKnobs is jobs infra specific testing knobs.
	JobsTestingKnobs base.ModuleTestingKnobs

	// BackupRestoreTestingKnobs are backup and restore specific testing knobs.
	BackupRestoreTestingKnobs base.ModuleTestingKnobs

	// StreamingTestingKnobs are backup and restore specific testing knobs.
	StreamingTestingKnobs base.ModuleTestingKnobs

	// IndexBackfillMergerTestingKnobs are the index backfill merger specific
	// testing knobs.
	IndexBackfillMergerTestingKnobs base.ModuleTestingKnobs
}

TestingKnobs are the testing knobs.

func (*TestingKnobs) ModuleTestingKnobs

func (*TestingKnobs) ModuleTestingKnobs()

ModuleTestingKnobs is part of the base.ModuleTestingKnobs interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL