ssmemstorage

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: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMemoryPressure is returned from the Container when we have reached
	// the memory limit allowed.
	ErrMemoryPressure = errors.New("insufficient sql stats memory")

	// ErrFingerprintLimitReached is returned from the Container when we have
	// more fingerprints than the limit specified in the cluster setting.
	ErrFingerprintLimitReached = errors.New("sql stats fingerprint limit reached")

	// ErrExecStatsFingerprintFlushed is returned from the Container when the
	// stats object for the fingerprint has been flushed to system table before
	// the roachpb.ExecStats can be recorded.
	ErrExecStatsFingerprintFlushed = errors.New("stmtStats flushed before execution stats can be recorded")
)

Functions

This section is empty.

Types

type Container

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

Container holds per-application statement and transaction statistics.

func New

func New(
	st *cluster.Settings,
	uniqueStmtFingerprintLimit *settings.IntSetting,
	uniqueTxnFingerprintLimit *settings.IntSetting,
	uniqueStmtFingerprintCount *int64,
	uniqueTxnFingerprintCount *int64,
	mon *mon.BytesMonitor,
	appName string,
	knobs *sqlstats.TestingKnobs,
) *Container

New returns a new instance of Container.

func NewTempContainerFromExistingStmtStats

func NewTempContainerFromExistingStmtStats(
	statistics []serverpb.StatementsResponse_CollectedStatementStatistics,
) (
	container *Container,
	remaining []serverpb.StatementsResponse_CollectedStatementStatistics,
	err error,
)

NewTempContainerFromExistingStmtStats creates a new Container by ingesting a slice of serverpb.StatementsResponse_CollectedStatementStatistics sorted by Key.KeyData.App field. It consumes the first chunk of the slice where all entries in the chunk contains the identical appName. The remaining slice is returned as the result. It returns a nil slice once all entries in statistics are consumed.

func NewTempContainerFromExistingTxnStats

func NewTempContainerFromExistingTxnStats(
	statistics []serverpb.StatementsResponse_ExtendedCollectedTransactionStatistics,
) (
	container *Container,
	remaining []serverpb.StatementsResponse_ExtendedCollectedTransactionStatistics,
	err error,
)

NewTempContainerFromExistingTxnStats creates a new Container by ingesting a slice of CollectedTransactionStatistics sorted by .StatsData.App field. It consumes the first chunk of the slice where all entries in the chunk contains the identical appName. The remaining slice is returned as the result. It returns a nil slice once all entries in statistics are consumed.

func (*Container) Add

func (s *Container) Add(ctx context.Context, other *Container) (err error)

Add combines one Container into another. Add manages locks on a, so taking a lock on a will cause a deadlock.

func (*Container) Clear

func (s *Container) Clear(ctx context.Context)

Clear clears the data stored in this Container and prepare the Container for reuse.

func (*Container) Free

func (s *Container) Free(ctx context.Context)

Free frees the accounted resources from the Container. The Container is presumed to be no longer in use and its actual allocated memory will eventually be GC'd.

func (*Container) IterateAggregatedTransactionStats

func (s *Container) IterateAggregatedTransactionStats(
	_ context.Context, _ *sqlstats.IteratorOptions, visitor sqlstats.AggregatedTransactionVisitor,
) error

IterateAggregatedTransactionStats implements sqlstats.ApplicationStats interface.

func (*Container) IterateStatementStats

func (s *Container) IterateStatementStats(
	ctx context.Context, options *sqlstats.IteratorOptions, visitor sqlstats.StatementVisitor,
) error

IterateStatementStats implements sqlstats.Provider interface.

func (*Container) IterateTransactionStats

func (s *Container) IterateTransactionStats(
	ctx context.Context, options *sqlstats.IteratorOptions, visitor sqlstats.TransactionVisitor,
) error

IterateTransactionStats implements sqlstats.Provider interface.

func (*Container) MergeApplicationStatementStats

func (s *Container) MergeApplicationStatementStats(
	ctx context.Context,
	other sqlstats.ApplicationStats,
	transformer func(*roachpb.CollectedStatementStatistics),
) (discardedStats uint64)

MergeApplicationStatementStats implements the sqlstats.ApplicationStats interface.

func (*Container) MergeApplicationTransactionStats

func (s *Container) MergeApplicationTransactionStats(
	ctx context.Context, other sqlstats.ApplicationStats,
) (discardedStats uint64)

MergeApplicationTransactionStats implements the sqlstats.ApplicationStats interface.

func (*Container) NewApplicationStatsWithInheritedOptions

func (s *Container) NewApplicationStatsWithInheritedOptions() sqlstats.ApplicationStats

NewApplicationStatsWithInheritedOptions implements the sqlstats.ApplicationStats interface.

func (*Container) RecordStatement

RecordStatement implements sqlstats.Writer interface. RecordStatement saves per-statement statistics.

samplePlanDescription can be nil, as these are only sampled periodically per unique fingerprint. RecordStatement always returns a valid stmtFingerprintID corresponding to the given stmt regardless of whether the statement is actually recorded or not.

If the statement is not actually recorded due to either: 1. the memory budget has been exceeded 2. the unique statement fingerprint limit has been exceeded and error is being returned. Note: This error is only related to the operation of recording the statement statistics into in-memory structs. It is unrelated to the stmtErr in the arguments.

func (*Container) RecordStatementExecStats

func (s *Container) RecordStatementExecStats(
	key roachpb.StatementStatisticsKey, stats execstats.QueryLevelStats,
) error

RecordStatementExecStats implements sqlstats.Writer interface.

func (*Container) RecordTransaction

func (s *Container) RecordTransaction(
	ctx context.Context, key roachpb.TransactionFingerprintID, value sqlstats.RecordedTxnStats,
) error

RecordTransaction implements sqlstats.Writer interface and saves per-transaction statistics.

func (*Container) SaveToLog

func (s *Container) SaveToLog(ctx context.Context, appName string)

SaveToLog saves the existing statement stats into the info log.

func (*Container) ShouldSaveLogicalPlanDesc

func (s *Container) ShouldSaveLogicalPlanDesc(
	fingerprint string, implicitTxn bool, database string,
) bool

ShouldSaveLogicalPlanDesc implements sqlstats.Writer interface.

func (*Container) StmtStatsIterator

func (s *Container) StmtStatsIterator(options *sqlstats.IteratorOptions) *StmtStatsIterator

StmtStatsIterator returns an instance of StmtStatsIterator.

func (*Container) TxnStatsIterator

func (s *Container) TxnStatsIterator(options *sqlstats.IteratorOptions) *TxnStatsIterator

TxnStatsIterator returns an instance of TxnStatsIterator.

type StmtStatsIterator

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

StmtStatsIterator is an iterator that iterates over the statement statistics inside of a ssmemstorage.Container.

func NewStmtStatsIterator

func NewStmtStatsIterator(
	container *Container, options *sqlstats.IteratorOptions,
) *StmtStatsIterator

NewStmtStatsIterator returns a StmtStatsIterator.

func (*StmtStatsIterator) Cur

Cur returns the roachpb.CollectedStatementStatistics at the current internal counter.

func (*StmtStatsIterator) Next

func (s *StmtStatsIterator) Next() bool

Next updates the current value returned by the subsequent Cur() call. Next() returns true if the following Cur() call is valid, false otherwise.

type TxnStatsIterator

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

TxnStatsIterator is an iterator that iterates over the transaction statistics inside a ssmemstorage.Container.

func NewTxnStatsIterator

func NewTxnStatsIterator(
	container *Container, options *sqlstats.IteratorOptions,
) *TxnStatsIterator

NewTxnStatsIterator returns a new instance of TxnStatsIterator.

func (*TxnStatsIterator) Cur

Cur returns the roachpb.CollectedTransactionStatistics at the current internal counter.

func (*TxnStatsIterator) Next

func (t *TxnStatsIterator) Next() bool

Next updates the current value returned by the subsequent Cur() call. Next() returns true if the following Cur() call is valid, false otherwise.

Jump to

Keyboard shortcuts

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